Fixed the primitive map marhsalling problem that was breaking the tests.

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@386703 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-03-17 20:11:02 +00:00
parent 257f16a0bb
commit 9224eeb0a2
8 changed files with 988 additions and 842 deletions

View File

@ -35,7 +35,6 @@
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets"/> <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets"/>
<ItemGroup> <ItemGroup>
<Compile Include="src\main\csharp\ActiveMQ\BrokerException.cs"/> <Compile Include="src\main\csharp\ActiveMQ\BrokerException.cs"/>
<Compile Include="src\main\csharp\ActiveMQ\Commands\AbstractCommand.cs"/>
<Compile Include="src\main\csharp\ActiveMQ\Commands\ActiveMQBytesMessage.cs"/> <Compile Include="src\main\csharp\ActiveMQ\Commands\ActiveMQBytesMessage.cs"/>
<Compile Include="src\main\csharp\ActiveMQ\Commands\ActiveMQDestination.cs"/> <Compile Include="src\main\csharp\ActiveMQ\Commands\ActiveMQDestination.cs"/>
<Compile Include="src\main\csharp\ActiveMQ\Commands\ActiveMQMapMessage.cs"/> <Compile Include="src\main\csharp\ActiveMQ\Commands\ActiveMQMapMessage.cs"/>
@ -210,6 +209,7 @@
<Compile Include="src\test\csharp\ActiveMQ\Commands\CommandTest.cs"/> <Compile Include="src\test\csharp\ActiveMQ\Commands\CommandTest.cs"/>
<Compile Include="src\test\csharp\ActiveMQ\OpenWire\BooleanStreamTest.cs"/> <Compile Include="src\test\csharp\ActiveMQ\OpenWire\BooleanStreamTest.cs"/>
<Compile Include="src\test\csharp\ActiveMQ\OpenWire\EndianTest.cs"/> <Compile Include="src\test\csharp\ActiveMQ\OpenWire\EndianTest.cs"/>
<Compile Include="src\test\csharp\ActiveMQ\OpenWire\PrimitiveMapTest.cs"/>
<Compile Include="src\test\csharp\ActiveMQ\TestMain.cs"/> <Compile Include="src\test\csharp\ActiveMQ\TestMain.cs"/>
<Compile Include="src\test\csharp\NMS\AsyncConsumeTest.cs"/> <Compile Include="src\test\csharp\NMS\AsyncConsumeTest.cs"/>
<Compile Include="src\test\csharp\NMS\BadConsumeTest.cs"/> <Compile Include="src\test\csharp\NMS\BadConsumeTest.cs"/>

View File

@ -29,17 +29,6 @@ namespace ActiveMQ.OpenWire
/// </summary> /// </summary>
public abstract class BaseDataStreamMarshaller public abstract class BaseDataStreamMarshaller
{ {
public const byte NULL = 0;
public const byte BOOLEAN_TYPE = 1;
public const byte BYTE_TYPE = 2;
public const byte CHAR_TYPE = 3;
public const byte SHORT_TYPE = 4;
public const byte INTEGER_TYPE = 5;
public const byte LONG_TYPE = 6;
public const byte DOUBLE_TYPE = 7;
public const byte FLOAT_TYPE = 8;
public const byte STRING_TYPE = 9;
public const byte BYTE_ARRAY_TYPE = 10;
private static String[] HEX_TABLE = new String[]{ private static String[] HEX_TABLE = new String[]{
"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f",
@ -713,183 +702,6 @@ namespace ActiveMQ.OpenWire
} }
/// <summary>
/// Marshals the primitive type map to a byte array
/// </summary>
public static byte[] MarshalPrimitiveMap(IDictionary map)
{
if (map == null)
{
return null;
}
else
{
MemoryStream memoryStream = new MemoryStream();
MarshalPrimitiveMap(map, new OpenWireBinaryWriter(memoryStream));
return memoryStream.GetBuffer();
}
}
public static void MarshalPrimitiveMap(IDictionary map, BinaryWriter dataOut)
{
if (map == null)
{
dataOut.Write((int)-1);
}
else
{
dataOut.Write(map.Count);
foreach (DictionaryEntry entry in map)
{
String name = (String) entry.Key;
dataOut.Write(name);
Object value = entry.Value;
MarshalPrimitive(dataOut, value);
}
}}
/// <summary>
/// Unmarshals the primitive type map from the given byte array
/// </summary>
public static IDictionary UnmarshalPrimitiveMap(byte[] data)
{
if (data == null)
{
return new Hashtable();
}
else
{
return UnmarshalPrimitiveMap(new OpenWireBinaryReader(new MemoryStream(data)));
}
}
public static IDictionary UnmarshalPrimitiveMap(BinaryReader dataIn)
{
int size = dataIn.ReadInt32();
if (size < 0)
{
return null;
}
else
{
IDictionary answer = new Hashtable(size);
for (int i=0; i < size; i++)
{
String name = dataIn.ReadString();
answer[name] = UnmarshalPrimitive(dataIn);
}
return answer;
}
}
public static void MarshalPrimitive(BinaryWriter dataOut, Object value)
{
if (value == null)
{
dataOut.Write(NULL);
}
else if (value is bool)
{
dataOut.Write(BOOLEAN_TYPE);
dataOut.Write((bool) value);
}
else if (value is byte)
{
dataOut.Write(BYTE_TYPE);
dataOut.Write(((Byte)value));
}
else if (value is char)
{
dataOut.Write(CHAR_TYPE);
dataOut.Write((char) value);
}
else if (value is short)
{
dataOut.Write(SHORT_TYPE);
dataOut.Write((short) value);
}
else if (value is int)
{
dataOut.Write(INTEGER_TYPE);
dataOut.Write((int) value);
}
else if (value is long)
{
dataOut.Write(LONG_TYPE);
dataOut.Write((long) value);
}
else if (value is float)
{
dataOut.Write(FLOAT_TYPE);
dataOut.Write((float) value);
}
else if (value is double)
{
dataOut.Write(DOUBLE_TYPE);
dataOut.Write((double) value);
}
else if (value is byte[])
{
byte[] data = (byte[]) value;
dataOut.Write(BYTE_ARRAY_TYPE);
dataOut.Write(data.Length);
dataOut.Write(data);
}
else if (value is string)
{
dataOut.Write(STRING_TYPE);
dataOut.Write((string) value);
}
else
{
throw new IOException("Object is not a primitive: " + value);
}
}
public static Object UnmarshalPrimitive(BinaryReader dataIn)
{
Object value=null;
switch (dataIn.ReadByte())
{
case BYTE_TYPE:
value = dataIn.ReadByte();
break;
case BOOLEAN_TYPE:
value = dataIn.ReadBoolean();
break;
case CHAR_TYPE:
value = dataIn.ReadChar();
break;
case SHORT_TYPE:
value = dataIn.ReadInt16();
break;
case INTEGER_TYPE:
value = dataIn.ReadInt32();
break;
case LONG_TYPE:
value = dataIn.ReadInt64();
break;
case FLOAT_TYPE:
value = dataIn.ReadSingle();
break;
case DOUBLE_TYPE:
value = dataIn.ReadDouble();
break;
case BYTE_ARRAY_TYPE:
int size = dataIn.ReadInt32();
byte[] data = new byte[size];
dataIn.Read(data, 0, size);
value = data;
break;
case STRING_TYPE:
value = dataIn.ReadString();
break;
}
return value;
}
/// <summary> /// <summary>
/// Converts the object to a String /// Converts the object to a String

View File

@ -1,99 +1,99 @@
/* /*
* Copyright 2006 The Apache Software Foundation or its licensors, as * Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable. * applicable.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
using System.IO; using System.IO;
using System; using System;
namespace ActiveMQ.OpenWire namespace ActiveMQ.OpenWire
{ {
/// <summary> /// <summary>
/// Support class that switches from one endian to the other. /// Support class that switches from one endian to the other.
/// </summary> /// </summary>
[CLSCompliant(false)] [CLSCompliant(false)]
public class EndianSupport public class EndianSupport
{ {
public static char SwitchEndian(char x) public static char SwitchEndian(char x)
{ {
return (char) ( return (char) (
(((char)( (byte)(x) )) << 8 ) | (((char)( (byte)(x) )) << 8 ) |
(((char)( (byte)(x >> 8) )) ) (((char)( (byte)(x >> 8) )) )
); );
} }
public static short SwitchEndian(short x) public static short SwitchEndian(short x)
{ {
return (short) ( return (short) (
(((ushort)( (byte)(x) )) << 8 ) | (((ushort)( (byte)(x) )) << 8 ) |
(((ushort)( (byte)(x >> 8) )) ) (((ushort)( (byte)(x >> 8) )) )
); );
} }
public static int SwitchEndian(int x) public static int SwitchEndian(int x)
{ {
return return
(((int)( (byte)(x) )) << 24 ) | (((int)( (byte)(x) )) << 24 ) |
(((int)( (byte)(x >> 8) )) << 16 ) | (((int)( (byte)(x >> 8) )) << 16 ) |
(((int)( (byte)(x >> 16) )) << 8 ) | (((int)( (byte)(x >> 16) )) << 8 ) |
(((int)( (byte)(x >> 24) )) ); (((int)( (byte)(x >> 24) )) );
} }
public static long SwitchEndian(long x) public static long SwitchEndian(long x)
{ {
return return
(((long)( (byte)(x ) )) << 56 ) | (((long)( (byte)(x ) )) << 56 ) |
(((long)( (byte)(x >> 8) )) << 48 ) | (((long)( (byte)(x >> 8) )) << 48 ) |
(((long)( (byte)(x >> 16) )) << 40 ) | (((long)( (byte)(x >> 16) )) << 40 ) |
(((long)( (byte)(x >> 24) )) << 32 ) | (((long)( (byte)(x >> 24) )) << 32 ) |
(((long)( (byte)(x >> 32) )) << 24 ) | (((long)( (byte)(x >> 32) )) << 24 ) |
(((long)( (byte)(x >> 40) )) << 16 ) | (((long)( (byte)(x >> 40) )) << 16 ) |
(((long)( (byte)(x >> 48) )) << 8 ) | (((long)( (byte)(x >> 48) )) << 8 ) |
(((long)( (byte)(x >> 56) )) ); (((long)( (byte)(x >> 56) )) );
} }
public static ushort SwitchEndian(ushort x) public static ushort SwitchEndian(ushort x)
{ {
return (ushort) ( return (ushort) (
(((ushort)( (byte)(x) )) << 8 ) | (((ushort)( (byte)(x) )) << 8 ) |
(((ushort)( (byte)(x >> 8) )) ) (((ushort)( (byte)(x >> 8) )) )
); );
} }
public static uint SwitchEndian(uint x) public static uint SwitchEndian(uint x)
{ {
return return
(((uint)( (byte)(x ) )) << 24 ) | (((uint)( (byte)(x ) )) << 24 ) |
(((uint)( (byte)(x >> 8) )) << 16 ) | (((uint)( (byte)(x >> 8) )) << 16 ) |
(((uint)( (byte)(x >> 16) )) << 8 ) | (((uint)( (byte)(x >> 16) )) << 8 ) |
(((uint)( (byte)(x >> 24) )) ); (((uint)( (byte)(x >> 24) )) );
} }
public static ulong SwitchEndian(ulong x) public static ulong SwitchEndian(ulong x)
{ {
return return
(((ulong)( (byte)(x ) )) << 56 ) | (((ulong)( (byte)(x ) )) << 56 ) |
(((ulong)( (byte)(x >> 8) )) << 48 ) | (((ulong)( (byte)(x >> 8) )) << 48 ) |
(((ulong)( (byte)(x >> 16) )) << 40 ) | (((ulong)( (byte)(x >> 16) )) << 40 ) |
(((ulong)( (byte)(x >> 24) )) << 32 ) | (((ulong)( (byte)(x >> 24) )) << 32 ) |
(((ulong)( (byte)(x >> 32) )) << 24 ) | (((ulong)( (byte)(x >> 32) )) << 24 ) |
(((ulong)( (byte)(x >> 40) )) << 16 ) | (((ulong)( (byte)(x >> 40) )) << 16 ) |
(((ulong)( (byte)(x >> 48) )) << 8 ) | (((ulong)( (byte)(x >> 48) )) << 8 ) |
(((ulong)( (byte)(x >> 56) )) ); (((ulong)( (byte)(x >> 56) )) );
} }
} }
} }

View File

@ -1,219 +1,224 @@
/* /*
* Copyright 2006 The Apache Software Foundation or its licensors, as * Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable. * applicable.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
using System; using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
namespace ActiveMQ.OpenWire namespace ActiveMQ.OpenWire
{ {
/// <summary> /// <summary>
/// A BinaryWriter that switches the endian orientation of the read opperations so that they /// A BinaryWriter that switches the endian orientation of the read opperations so that they
/// are compatible with marshalling used by OpenWire. /// are compatible with marshalling used by OpenWire.
/// </summary> /// </summary>
[CLSCompliant(false)] [CLSCompliant(false)]
public class OpenWireBinaryReader : BinaryReader public class OpenWireBinaryReader : BinaryReader
{ {
public OpenWireBinaryReader(Stream input) : base(input) public OpenWireBinaryReader(Stream input) : base(input)
{ {
} }
/// <summary> /// <summary>
/// Method Read /// Method Read
/// </summary> /// </summary>
/// <returns>An int</returns> /// <returns>An int</returns>
/// <param name="buffer">A char[]</param> /// <param name="buffer">A char[]</param>
/// <param name="index">An int</param> /// <param name="index">An int</param>
/// <param name="count">An int</param> /// <param name="count">An int</param>
public override int Read(char[] buffer, int index, int count) public override int Read(char[] buffer, int index, int count)
{ {
int size = base.Read(buffer, index, count); int size = base.Read(buffer, index, count);
for( int i=0; i < size; i++ ) { for( int i=0; i < size; i++ ) {
buffer[index+i] = EndianSupport.SwitchEndian(buffer[index+i]); buffer[index+i] = EndianSupport.SwitchEndian(buffer[index+i]);
} }
return size; return size;
} }
/// <summary> /// <summary>
/// Method ReadChars /// Method ReadChars
/// </summary> /// </summary>
/// <returns>A char[]</returns> /// <returns>A char[]</returns>
/// <param name="count">An int</param> /// <param name="count">An int</param>
public override char[] ReadChars(int count) public override char[] ReadChars(int count)
{ {
char[] rc = base.ReadChars(count); char[] rc = base.ReadChars(count);
if( rc!=null ) { if( rc!=null ) {
for( int i=0; i < rc.Length; i++ ) { for( int i=0; i < rc.Length; i++ ) {
rc[i] = EndianSupport.SwitchEndian(rc[i]); rc[i] = EndianSupport.SwitchEndian(rc[i]);
} }
} }
return rc; return rc;
} }
/// <summary> /// <summary>
/// Method ReadInt16 /// Method ReadInt16
/// </summary> /// </summary>
/// <returns>A short</returns> /// <returns>A short</returns>
public override short ReadInt16() public override short ReadInt16()
{ {
return EndianSupport.SwitchEndian(base.ReadInt16()); return EndianSupport.SwitchEndian(base.ReadInt16());
} }
/// <summary> /// <summary>
/// Method ReadChar /// Method ReadChar
/// </summary> /// </summary>
/// <returns>A char</returns> /// <returns>A char</returns>
public override char ReadChar() public override char ReadChar()
{ {
return EndianSupport.SwitchEndian(base.ReadChar()); return (char) (
} (((char)( (byte)(base.ReadByte()) )) << 8 ) |
(((char)( (byte)(base.ReadByte()) )) )
/// <summary> );
/// Method ReadInt64
/// </summary> // return EndianSupport.SwitchEndian(base.ReadChar());
/// <returns>A long</returns> }
public override long ReadInt64()
{ /// <summary>
return EndianSupport.SwitchEndian(base.ReadInt64()); /// Method ReadInt64
} /// </summary>
/// <returns>A long</returns>
/// <summary> public override long ReadInt64()
/// Method ReadUInt64 {
/// </summary> return EndianSupport.SwitchEndian(base.ReadInt64());
/// <returns>An ulong</returns> }
public override ulong ReadUInt64()
{ /// <summary>
return EndianSupport.SwitchEndian(base.ReadUInt64()); /// Method ReadUInt64
} /// </summary>
/// <returns>An ulong</returns>
/// <summary> public override ulong ReadUInt64()
/// Method ReadUInt32 {
/// </summary> return EndianSupport.SwitchEndian(base.ReadUInt64());
/// <returns>An uint</returns> }
public override uint ReadUInt32()
{ /// <summary>
return EndianSupport.SwitchEndian(base.ReadUInt32()); /// Method ReadUInt32
} /// </summary>
/// <returns>An uint</returns>
/// <summary> public override uint ReadUInt32()
/// Method ReadUInt16 {
/// </summary> return EndianSupport.SwitchEndian(base.ReadUInt32());
/// <returns>An ushort</returns> }
public override ushort ReadUInt16()
{ /// <summary>
return EndianSupport.SwitchEndian(base.ReadUInt16()); /// Method ReadUInt16
} /// </summary>
/// <returns>An ushort</returns>
/// <summary> public override ushort ReadUInt16()
/// Method ReadInt32 {
/// </summary> return EndianSupport.SwitchEndian(base.ReadUInt16());
/// <returns>An int</returns> }
public override int ReadInt32()
{ /// <summary>
int x = base.ReadInt32(); /// Method ReadInt32
int y = EndianSupport.SwitchEndian(x); /// </summary>
return y; /// <returns>An int</returns>
} public override int ReadInt32()
{
/// <summary> int x = base.ReadInt32();
/// Method ReadString int y = EndianSupport.SwitchEndian(x);
/// </summary> return y;
/// <returns>A string</returns> }
public override String ReadString()
{ /// <summary>
short utflen = ReadInt16(); /// Method ReadString
if (utflen > -1) /// </summary>
{ /// <returns>A string</returns>
StringBuilder str = new StringBuilder(utflen); public override String ReadString()
{
byte[] bytearr = new byte[utflen]; short utflen = ReadInt16();
int c, char2, char3; if (utflen > -1)
int count = 0; {
StringBuilder str = new StringBuilder(utflen);
Read(bytearr, 0, utflen);
byte[] bytearr = new byte[utflen];
while (count < utflen) int c, char2, char3;
{ int count = 0;
c = bytearr[count] & 0xff;
switch (c >> 4) Read(bytearr, 0, utflen);
{
case 0: while (count < utflen)
case 1: {
case 2: c = bytearr[count] & 0xff;
case 3: switch (c >> 4)
case 4: {
case 5: case 0:
case 6: case 1:
case 7: case 2:
/* 0xxxxxxx */ case 3:
count++; case 4:
str.Append((char) c); case 5:
break; case 6:
case 12: case 7:
case 13: /* 0xxxxxxx */
/* 110x xxxx 10xx xxxx */ count++;
count += 2; str.Append((char) c);
if (count > utflen) break;
{ case 12:
throw CreateDataFormatException(); case 13:
} /* 110x xxxx 10xx xxxx */
char2 = bytearr[count - 1]; count += 2;
if ((char2 & 0xC0) != 0x80) if (count > utflen)
{ {
throw CreateDataFormatException(); throw CreateDataFormatException();
} }
str.Append((char) (((c & 0x1F) << 6) | (char2 & 0x3F))); char2 = bytearr[count - 1];
break; if ((char2 & 0xC0) != 0x80)
case 14: {
/* 1110 xxxx 10xx xxxx 10xx xxxx */ throw CreateDataFormatException();
count += 3; }
if (count > utflen) str.Append((char) (((c & 0x1F) << 6) | (char2 & 0x3F)));
{ break;
throw CreateDataFormatException(); case 14:
} /* 1110 xxxx 10xx xxxx 10xx xxxx */
char2 = bytearr[count - 2]; count += 3;
char3 = bytearr[count - 1]; if (count > utflen)
if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) {
{ throw CreateDataFormatException();
throw CreateDataFormatException(); }
} char2 = bytearr[count - 2];
str.Append((char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0))); char3 = bytearr[count - 1];
break; if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
default : {
/* 10xx xxxx, 1111 xxxx */ throw CreateDataFormatException();
throw CreateDataFormatException(); }
} str.Append((char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)));
} break;
// The number of chars produced may be less than utflen default :
return str.ToString(); /* 10xx xxxx, 1111 xxxx */
} throw CreateDataFormatException();
else }
{ }
return null; // The number of chars produced may be less than utflen
} return str.ToString();
} }
else
private static Exception CreateDataFormatException() {
{ return null;
// TODO: implement a better exception }
return new IOException("Data format error!"); }
}
private static Exception CreateDataFormatException()
{
} // TODO: implement a better exception
} return new IOException("Data format error!");
}
}
}

View File

@ -1,195 +1,196 @@
/* /*
* Copyright 2006 The Apache Software Foundation or its licensors, as * Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable. * applicable.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
using ActiveMQ.Commands; using ActiveMQ.Commands;
using System; using System;
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using System.Text; using System.Text;
namespace ActiveMQ.OpenWire namespace ActiveMQ.OpenWire
{ {
/// <summary> /// <summary>
/// A BinaryWriter that switches the endian orientation of the write opperations so that they /// A BinaryWriter that switches the endian orientation of the write opperations so that they
/// are compatible with marshalling used by OpenWire. /// are compatible with marshalling used by OpenWire.
/// </summary> /// </summary>
[CLSCompliant(false)] [CLSCompliant(false)]
public class OpenWireBinaryWriter : BinaryWriter public class OpenWireBinaryWriter : BinaryWriter
{ {
public OpenWireBinaryWriter(Stream output) : base(output) public OpenWireBinaryWriter(Stream output) : base(output)
{ {
} }
/// <summary> /// <summary>
/// Method Write /// Method Write
/// </summary> /// </summary>
/// <param name="value">A long</param> /// <param name="value">A long</param>
public override void Write(long value) public override void Write(long value)
{ {
base.Write(EndianSupport.SwitchEndian(value)); base.Write(EndianSupport.SwitchEndian(value));
} }
/// <summary> /// <summary>
/// Method Write /// Method Write
/// </summary> /// </summary>
/// <param name="value">An ushort</param> /// <param name="value">An ushort</param>
public override void Write(ushort value) public override void Write(ushort value)
{ {
base.Write(EndianSupport.SwitchEndian(value)); base.Write(EndianSupport.SwitchEndian(value));
} }
/// <summary> /// <summary>
/// Method Write /// Method Write
/// </summary> /// </summary>
/// <param name="value">An int</param> /// <param name="value">An int</param>
public override void Write(int value) public override void Write(int value)
{ {
int x = EndianSupport.SwitchEndian(value); int x = EndianSupport.SwitchEndian(value);
base.Write(x); base.Write(x);
} }
/// <summary> /// <summary>
/// Method Write /// Method Write
/// </summary> /// </summary>
/// <param name="chars">A char[]</param> /// <param name="chars">A char[]</param>
/// <param name="index">An int</param> /// <param name="index">An int</param>
/// <param name="count">An int</param> /// <param name="count">An int</param>
public override void Write(char[] chars, int index, int count) public override void Write(char[] chars, int index, int count)
{ {
char[] t = new char[count]; char[] t = new char[count];
for( int i=0; i < count; i++ ) { for( int i=0; i < count; i++ ) {
t[index+i] = EndianSupport.SwitchEndian(t[index+i]); t[index+i] = EndianSupport.SwitchEndian(t[index+i]);
} }
base.Write(t); base.Write(t);
} }
/// <summary> /// <summary>
/// Method Write /// Method Write
/// </summary> /// </summary>
/// <param name="chars">A char[]</param> /// <param name="chars">A char[]</param>
public override void Write(char[] chars) public override void Write(char[] chars)
{ {
Write(chars, 0, chars.Length); Write(chars, 0, chars.Length);
} }
/// <summary> /// <summary>
/// Method Write /// Method Write
/// </summary> /// </summary>
/// <param name="value">An uint</param> /// <param name="value">An uint</param>
public override void Write(uint value) public override void Write(uint value)
{ {
base.Write(EndianSupport.SwitchEndian(value)); base.Write(EndianSupport.SwitchEndian(value));
} }
/// <summary> /// <summary>
/// Method Write /// Method Write
/// </summary> /// </summary>
/// <param name="ch">A char</param> /// <param name="ch">A char</param>
public override void Write(char ch) public override void Write(char ch)
{ {
base.Write(EndianSupport.SwitchEndian(ch)); base.Write( (byte)( ( ch>>8 ) & 0xFF ) );
} base.Write( (byte)( ch & 0xFF ) );
}
/// <summary>
/// Method Write /// <summary>
/// </summary> /// Method Write
/// <param name="value">An ulong</param> /// </summary>
public override void Write(ulong value) /// <param name="value">An ulong</param>
{ public override void Write(ulong value)
base.Write(EndianSupport.SwitchEndian(value)); {
} base.Write(EndianSupport.SwitchEndian(value));
}
/// <summary>
/// Method Write /// <summary>
/// </summary> /// Method Write
/// <param name="value">A short</param> /// </summary>
public override void Write(short value) /// <param name="value">A short</param>
{ public override void Write(short value)
base.Write(EndianSupport.SwitchEndian(value)); {
} base.Write(EndianSupport.SwitchEndian(value));
}
/// <summary>
/// Method Write /// <summary>
/// </summary> /// Method Write
/// <param name="text">A string</param> /// </summary>
public override void Write(String text) /// <param name="text">A string</param>
{ public override void Write(String text)
if (text != null) {
{ if (text != null)
if( text.Length > short.MaxValue ) { {
throw new IOException("Cannot marshall string longer than: "+short.MaxValue+" characters, supplied steing was: "+text.Length+" characters"); if( text.Length > short.MaxValue ) {
} throw new IOException("Cannot marshall string longer than: "+short.MaxValue+" characters, supplied steing was: "+text.Length+" characters");
short strlen = (short)text.Length; }
short utflen = 0; short strlen = (short)text.Length;
int c, count = 0; short utflen = 0;
int c, count = 0;
char[] charr = text.ToCharArray();
char[] charr = text.ToCharArray();
for (int i = 0; i < strlen; i++)
{ for (int i = 0; i < strlen; i++)
c = charr[i]; {
if ((c >= 0x0001) && (c <= 0x007F)) c = charr[i];
{ if ((c >= 0x0001) && (c <= 0x007F))
utflen++; {
} utflen++;
else if (c > 0x07FF) }
{ else if (c > 0x07FF)
utflen += 3; {
} utflen += 3;
else }
{ else
utflen += 2; {
} utflen += 2;
} }
}
Write(utflen);
byte[] bytearr = new byte[utflen]; Write(utflen);
for (int i = 0; i < strlen; i++) byte[] bytearr = new byte[utflen];
{ for (int i = 0; i < strlen; i++)
c = charr[i]; {
if ((c >= 0x0001) && (c <= 0x007F)) c = charr[i];
{ if ((c >= 0x0001) && (c <= 0x007F))
bytearr[count++] = (byte) c; {
} bytearr[count++] = (byte) c;
else if (c > 0x07FF) }
{ else if (c > 0x07FF)
bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F)); {
bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F)); bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
} bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
else }
{ else
bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F)); {
bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
} bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
} }
}
Write(bytearr);
Write(bytearr);
}
else }
{ else
Write((short)-1); {
} Write((short)-1);
} }
} }
}
}
}

View File

@ -17,6 +17,7 @@
using NMS; using NMS;
using System; using System;
using System.Collections; using System.Collections;
using System.IO;
namespace ActiveMQ.OpenWire namespace ActiveMQ.OpenWire
{ {
@ -25,26 +26,20 @@ namespace ActiveMQ.OpenWire
/// </summary> /// </summary>
public class PrimitiveMap : IPrimitiveMap public class PrimitiveMap : IPrimitiveMap
{ {
public const byte NULL = 0;
public const byte BOOLEAN_TYPE = 1;
public const byte BYTE_TYPE = 2;
public const byte CHAR_TYPE = 3;
public const byte SHORT_TYPE = 4;
public const byte INTEGER_TYPE = 5;
public const byte LONG_TYPE = 6;
public const byte DOUBLE_TYPE = 7;
public const byte FLOAT_TYPE = 8;
public const byte STRING_TYPE = 9;
public const byte BYTE_ARRAY_TYPE = 10;
private IDictionary dictionary = new Hashtable(); private IDictionary dictionary = new Hashtable();
/// <summary>
/// Unmarshalls the map from the given data or if the data is null just
/// return an empty map
/// </summary>
public static PrimitiveMap Unmarshal(byte[] data)
{
PrimitiveMap answer = new PrimitiveMap();
answer.dictionary = BaseDataStreamMarshaller.UnmarshalPrimitiveMap(data);
return answer;
}
public byte[] Marshal()
{
return BaseDataStreamMarshaller.MarshalPrimitiveMap(dictionary);
}
public void Clear() public void Clear()
{ {
dictionary.Clear(); dictionary.Clear();
@ -234,6 +229,227 @@ namespace ActiveMQ.OpenWire
} }
} }
} }
/// <summary>
/// Method ToString
/// </summary>
/// <returns>A string</returns>
public override String ToString()
{
String s="{";
bool first=true;
foreach (DictionaryEntry entry in dictionary)
{
if( !first ) {
s+=", ";
}
first=false;
String name = (String) entry.Key;
Object value = entry.Value;
s+=name+"="+value;
}
s += "}";
return s;
}
/// <summary>
/// Unmarshalls the map from the given data or if the data is null just
/// return an empty map
/// </summary>
public static PrimitiveMap Unmarshal(byte[] data)
{
PrimitiveMap answer = new PrimitiveMap();
answer.dictionary = UnmarshalPrimitiveMap(data);
return answer;
}
public byte[] Marshal()
{
return MarshalPrimitiveMap(dictionary);
}
/// <summary>
/// Marshals the primitive type map to a byte array
/// </summary>
public static byte[] MarshalPrimitiveMap(IDictionary map)
{
if (map == null)
{
return null;
}
else
{
MemoryStream memoryStream = new MemoryStream();
MarshalPrimitiveMap(map, new OpenWireBinaryWriter(memoryStream));
return memoryStream.GetBuffer();
}
}
public static void MarshalPrimitiveMap(IDictionary map, BinaryWriter dataOut)
{
if (map == null)
{
dataOut.Write((int)-1);
}
else
{
dataOut.Write(map.Count);
foreach (DictionaryEntry entry in map)
{
String name = (String) entry.Key;
dataOut.Write(name);
Object value = entry.Value;
MarshalPrimitive(dataOut, value);
}
}}
/// <summary>
/// Unmarshals the primitive type map from the given byte array
/// </summary>
public static IDictionary UnmarshalPrimitiveMap(byte[] data)
{
if (data == null)
{
return new Hashtable();
}
else
{
return UnmarshalPrimitiveMap(new OpenWireBinaryReader(new MemoryStream(data)));
}
}
public static IDictionary UnmarshalPrimitiveMap(BinaryReader dataIn)
{
int size = dataIn.ReadInt32();
if (size < 0)
{
return null;
}
else
{
IDictionary answer = new Hashtable(size);
for (int i=0; i < size; i++)
{
String name = dataIn.ReadString();
answer[name] = UnmarshalPrimitive(dataIn);
}
return answer;
}
}
public static void MarshalPrimitive(BinaryWriter dataOut, Object value)
{
if (value == null)
{
dataOut.Write(NULL);
}
else if (value is bool)
{
dataOut.Write(BOOLEAN_TYPE);
dataOut.Write((bool) value);
}
else if (value is byte)
{
dataOut.Write(BYTE_TYPE);
dataOut.Write(((byte)value));
}
else if (value is char)
{
dataOut.Write(CHAR_TYPE);
dataOut.Write((char) value);
}
else if (value is short)
{
dataOut.Write(SHORT_TYPE);
dataOut.Write((short) value);
}
else if (value is int)
{
dataOut.Write(INTEGER_TYPE);
dataOut.Write((int) value);
}
else if (value is long)
{
dataOut.Write(LONG_TYPE);
dataOut.Write((long) value);
}
else if (value is float)
{
dataOut.Write(FLOAT_TYPE);
dataOut.Write((float) value);
}
else if (value is double)
{
dataOut.Write(DOUBLE_TYPE);
dataOut.Write((double) value);
}
else if (value is byte[])
{
byte[] data = (byte[]) value;
dataOut.Write(BYTE_ARRAY_TYPE);
dataOut.Write(data.Length);
dataOut.Write(data);
}
else if (value is string)
{
dataOut.Write(STRING_TYPE);
dataOut.Write((string) value);
}
else
{
throw new IOException("Object is not a primitive: " + value);
}
}
public static Object UnmarshalPrimitive(BinaryReader dataIn)
{
Object value=null;
switch (dataIn.ReadByte())
{
case BYTE_TYPE:
value = dataIn.ReadByte();
break;
case BOOLEAN_TYPE:
value = dataIn.ReadBoolean();
break;
case CHAR_TYPE:
value = dataIn.ReadChar();
break;
case SHORT_TYPE:
value = dataIn.ReadInt16();
break;
case INTEGER_TYPE:
value = dataIn.ReadInt32();
break;
case LONG_TYPE:
value = dataIn.ReadInt64();
break;
case FLOAT_TYPE:
value = dataIn.ReadSingle();
break;
case DOUBLE_TYPE:
value = dataIn.ReadDouble();
break;
case BYTE_ARRAY_TYPE:
int size = dataIn.ReadInt32();
byte[] data = new byte[size];
dataIn.Read(data, 0, size);
value = data;
break;
case STRING_TYPE:
value = dataIn.ReadString();
break;
}
return value;
}
} }
} }

View File

@ -0,0 +1,112 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using NUnit.Framework;
using System;
using System.IO;
using ActiveMQ.OpenWire;
namespace ActiveMQ.OpenWire
{
[TestFixture]
public class PrimitiveMapTest
{
bool a = true;
byte b = 123;
char c = 'c';
short d = 0x1234;
int e = 0x12345678;
long f = 0x1234567812345678;
string g = "Hello World!";
bool h = false;
byte i = 0xFF;
short j = -0x1234;
int k = -0x12345678;
long l = -0x1234567812345678;
[Test]
public void TestNotMarshalled()
{
PrimitiveMap map = CreatePrimitiveMap();
AssertPrimitiveMap(map);
}
[Test]
public void TestMarshalled()
{
PrimitiveMap map = CreatePrimitiveMap();
Console.WriteLine("data: "+map);
byte[] data = map.Marshal();
map = PrimitiveMap.Unmarshal(data);
Console.WriteLine("data: "+map);
AssertPrimitiveMap(map);
}
protected PrimitiveMap CreatePrimitiveMap()
{
PrimitiveMap map = new PrimitiveMap();
map["a"] = a;
map["b"] = b;
map["c"] = c;
map["d"] = d;
map["e"] = e;
map["f"] = f;
map["g"] = g;
map["h"] = h;
map["i"] = i;
map["j"] = j;
map["k"] = k;
map["l"] = l;
return map;
}
protected void AssertPrimitiveMap(PrimitiveMap map) {
// use generic API to access entries
Assert.AreEqual(a, map["a"], "generic map entry: a");
Assert.AreEqual(b, map["b"], "generic map entry: b");
Assert.AreEqual(c, map["c"], "generic map entry: c");
Assert.AreEqual(d, map["d"], "generic map entry: d");
Assert.AreEqual(e, map["e"], "generic map entry: e");
Assert.AreEqual(f, map["f"], "generic map entry: f");
Assert.AreEqual(g, map["g"], "generic map entry: g");
Assert.AreEqual(h, map["h"], "generic map entry: h");
Assert.AreEqual(i, map["i"], "generic map entry: i");
Assert.AreEqual(j, map["j"], "generic map entry: j");
Assert.AreEqual(k, map["k"], "generic map entry: k");
Assert.AreEqual(l, map["l"], "generic map entry: l");
// use type safe APIs
Assert.AreEqual(a, map.GetBool("a"), "map entry: a");
Assert.AreEqual(b, map.GetByte("b"), "map entry: b");
Assert.AreEqual(c, map.GetChar("c"), "map entry: c");
Assert.AreEqual(d, map.GetShort("d"), "map entry: d");
Assert.AreEqual(e, map.GetInt("e"), "map entry: e");
Assert.AreEqual(f, map.GetLong("f"), "map entry: f");
Assert.AreEqual(g, map.GetString("g"), "map entry: g");
Assert.AreEqual(h, map.GetBool("h"), "map entry: h");
Assert.AreEqual(i, map.GetByte("i"), "map entry: i");
Assert.AreEqual(j, map.GetShort("j"), "map entry: j");
Assert.AreEqual(k, map.GetInt("k"), "map entry: k");
Assert.AreEqual(l, map.GetLong("l"), "map entry: l");
}
}
}

View File

@ -1,122 +1,122 @@
/* /*
* Copyright 2006 The Apache Software Foundation or its licensors, as * Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable. * applicable.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
using NMS; using NMS;
using NUnit.Framework; using NUnit.Framework;
using System; using System;
namespace NMS namespace NMS
{ {
[ TestFixture ] [ TestFixture ]
public class MessageTest : JMSTestSupport public class MessageTest : JMSTestSupport
{ {
bool a = true; bool a = true;
byte b = 123; byte b = 123;
char c = 'c'; char c = 'c';
short d = 0x1234; short d = 0x1234;
int e = 0x12345678; int e = 0x12345678;
long f = 0x1234567812345678; long f = 0x1234567812345678;
string g = "Hello World!"; string g = "Hello World!";
bool h = false; bool h = false;
byte i = 0xFF; byte i = 0xFF;
short j = -0x1234; short j = -0x1234;
int k = -0x12345678; int k = -0x12345678;
long l = -0x1234567812345678; long l = -0x1234567812345678;
[SetUp] [SetUp]
override public void SetUp() override public void SetUp()
{ {
base.SetUp(); base.SetUp();
} }
[TearDown] [TearDown]
override public void TearDown() override public void TearDown()
{ {
base.TearDown(); base.TearDown();
} }
[ Test ] [ Test ]
public override void SendAndSyncReceive() public override void SendAndSyncReceive()
{ {
base.SendAndSyncReceive(); base.SendAndSyncReceive();
} }
protected override IMessage CreateMessage() protected override IMessage CreateMessage()
{ {
IMessage message = session.CreateMessage(); IMessage message = session.CreateMessage();
message.Properties["a"] = a; message.Properties["a"] = a;
message.Properties["b"] = b; message.Properties["b"] = b;
message.Properties["c"] = c; message.Properties["c"] = c;
message.Properties["d"] = d; message.Properties["d"] = d;
message.Properties["e"] = e; message.Properties["e"] = e;
message.Properties["f"] = f; message.Properties["f"] = f;
message.Properties["g"] = g; message.Properties["g"] = g;
message.Properties["h"] = h; message.Properties["h"] = h;
message.Properties["i"] = i; message.Properties["i"] = i;
message.Properties["j"] = j; message.Properties["j"] = j;
message.Properties["k"] = k; message.Properties["k"] = k;
message.Properties["l"] = l; message.Properties["l"] = l;
return message; return message;
} }
protected override void AssertValidMessage(IMessage message) protected override void AssertValidMessage(IMessage message)
{ {
Console.WriteLine("Received message: " + message); Console.WriteLine("Received message: " + message);
Console.WriteLine("Received Count: " + message.Properties.Count); Console.WriteLine("Received Count: " + message.Properties.Count);
Assert.AreEqual(ToHex(f), ToHex(message.Properties.GetLong("f")), "map entry: f as hex"); Assert.AreEqual(ToHex(f), ToHex(message.Properties.GetLong("f")), "map entry: f as hex");
// use generic API to access entries // use generic API to access entries
Assert.AreEqual(a, message.Properties["a"], "generic map entry: a"); Assert.AreEqual(a, message.Properties["a"], "generic map entry: a");
Assert.AreEqual(b, message.Properties["b"], "generic map entry: b"); Assert.AreEqual(b, message.Properties["b"], "generic map entry: b");
Assert.AreEqual(c, message.Properties["c"], "generic map entry: c"); Assert.AreEqual(c, message.Properties["c"], "generic map entry: c");
Assert.AreEqual(d, message.Properties["d"], "generic map entry: d"); Assert.AreEqual(d, message.Properties["d"], "generic map entry: d");
Assert.AreEqual(e, message.Properties["e"], "generic map entry: e"); Assert.AreEqual(e, message.Properties["e"], "generic map entry: e");
Assert.AreEqual(f, message.Properties["f"], "generic map entry: f"); Assert.AreEqual(f, message.Properties["f"], "generic map entry: f");
Assert.AreEqual(g, message.Properties["g"], "generic map entry: g"); Assert.AreEqual(g, message.Properties["g"], "generic map entry: g");
Assert.AreEqual(h, message.Properties["h"], "generic map entry: h"); Assert.AreEqual(h, message.Properties["h"], "generic map entry: h");
Assert.AreEqual(i, message.Properties["i"], "generic map entry: i"); Assert.AreEqual(i, message.Properties["i"], "generic map entry: i");
Assert.AreEqual(j, message.Properties["j"], "generic map entry: j"); Assert.AreEqual(j, message.Properties["j"], "generic map entry: j");
Assert.AreEqual(k, message.Properties["k"], "generic map entry: k"); Assert.AreEqual(k, message.Properties["k"], "generic map entry: k");
Assert.AreEqual(l, message.Properties["l"], "generic map entry: l"); Assert.AreEqual(l, message.Properties["l"], "generic map entry: l");
// use type safe APIs // use type safe APIs
Assert.AreEqual(a, message.Properties.GetBool("a"), "map entry: a"); Assert.AreEqual(a, message.Properties.GetBool("a"), "map entry: a");
Assert.AreEqual(b, message.Properties.GetByte("b"), "map entry: b"); Assert.AreEqual(b, message.Properties.GetByte("b"), "map entry: b");
Assert.AreEqual(c, message.Properties.GetChar("c"), "map entry: c"); Assert.AreEqual(c, message.Properties.GetChar("c"), "map entry: c");
Assert.AreEqual(d, message.Properties.GetShort("d"), "map entry: d"); Assert.AreEqual(d, message.Properties.GetShort("d"), "map entry: d");
Assert.AreEqual(e, message.Properties.GetInt("e"), "map entry: e"); Assert.AreEqual(e, message.Properties.GetInt("e"), "map entry: e");
Assert.AreEqual(f, message.Properties.GetLong("f"), "map entry: f"); Assert.AreEqual(f, message.Properties.GetLong("f"), "map entry: f");
Assert.AreEqual(g, message.Properties.GetString("g"), "map entry: g"); Assert.AreEqual(g, message.Properties.GetString("g"), "map entry: g");
Assert.AreEqual(h, message.Properties.GetBool("h"), "map entry: h"); Assert.AreEqual(h, message.Properties.GetBool("h"), "map entry: h");
Assert.AreEqual(i, message.Properties.GetByte("i"), "map entry: i"); Assert.AreEqual(i, message.Properties.GetByte("i"), "map entry: i");
Assert.AreEqual(j, message.Properties.GetShort("j"), "map entry: j"); Assert.AreEqual(j, message.Properties.GetShort("j"), "map entry: j");
Assert.AreEqual(k, message.Properties.GetInt("k"), "map entry: k"); Assert.AreEqual(k, message.Properties.GetInt("k"), "map entry: k");
Assert.AreEqual(l, message.Properties.GetLong("l"), "map entry: l"); Assert.AreEqual(l, message.Properties.GetLong("l"), "map entry: l");
} }
protected string ToHex(long value) protected string ToHex(long value)
{ {
return String.Format("{0:x}", value); return String.Format("{0:x}", value);
} }
} }
} }