diff --git a/activemq-dotnet/activemq-dotnet.csproj b/activemq-dotnet/activemq-dotnet.csproj
index ec727de1e3..b9f979fa38 100644
--- a/activemq-dotnet/activemq-dotnet.csproj
+++ b/activemq-dotnet/activemq-dotnet.csproj
@@ -35,7 +35,6 @@
-
@@ -210,6 +209,7 @@
+
diff --git a/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/BaseDataStreamMarshaller.cs b/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/BaseDataStreamMarshaller.cs
index 5f17ae4c0e..88df033d99 100755
--- a/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/BaseDataStreamMarshaller.cs
+++ b/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/BaseDataStreamMarshaller.cs
@@ -29,17 +29,6 @@ namespace ActiveMQ.OpenWire
///
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[]{
"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f",
@@ -713,183 +702,6 @@ namespace ActiveMQ.OpenWire
}
- ///
- /// Marshals the primitive type map to a byte array
- ///
- 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);
- }
- }}
-
-
-
- ///
- /// Unmarshals the primitive type map from the given byte array
- ///
- 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;
- }
///
/// Converts the object to a String
diff --git a/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/EndianSupport.cs b/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/EndianSupport.cs
index ad8b997895..c198f1f9a2 100644
--- a/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/EndianSupport.cs
+++ b/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/EndianSupport.cs
@@ -1,99 +1,99 @@
-/*
- * 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 System.IO;
-using System;
-
-namespace ActiveMQ.OpenWire
-{
- ///
- /// Support class that switches from one endian to the other.
- ///
- [CLSCompliant(false)]
- public class EndianSupport
- {
-
- public static char SwitchEndian(char x)
- {
- return (char) (
- (((char)( (byte)(x) )) << 8 ) |
- (((char)( (byte)(x >> 8) )) )
- );
- }
-
- public static short SwitchEndian(short x)
- {
- return (short) (
- (((ushort)( (byte)(x) )) << 8 ) |
- (((ushort)( (byte)(x >> 8) )) )
- );
- }
-
- public static int SwitchEndian(int x)
- {
- return
- (((int)( (byte)(x) )) << 24 ) |
- (((int)( (byte)(x >> 8) )) << 16 ) |
- (((int)( (byte)(x >> 16) )) << 8 ) |
- (((int)( (byte)(x >> 24) )) );
- }
-
- public static long SwitchEndian(long x)
- {
- return
- (((long)( (byte)(x ) )) << 56 ) |
- (((long)( (byte)(x >> 8) )) << 48 ) |
- (((long)( (byte)(x >> 16) )) << 40 ) |
- (((long)( (byte)(x >> 24) )) << 32 ) |
- (((long)( (byte)(x >> 32) )) << 24 ) |
- (((long)( (byte)(x >> 40) )) << 16 ) |
- (((long)( (byte)(x >> 48) )) << 8 ) |
- (((long)( (byte)(x >> 56) )) );
- }
-
- public static ushort SwitchEndian(ushort x)
- {
- return (ushort) (
- (((ushort)( (byte)(x) )) << 8 ) |
- (((ushort)( (byte)(x >> 8) )) )
- );
- }
-
- public static uint SwitchEndian(uint x)
- {
- return
- (((uint)( (byte)(x ) )) << 24 ) |
- (((uint)( (byte)(x >> 8) )) << 16 ) |
- (((uint)( (byte)(x >> 16) )) << 8 ) |
- (((uint)( (byte)(x >> 24) )) );
- }
-
- public static ulong SwitchEndian(ulong x)
- {
- return
- (((ulong)( (byte)(x ) )) << 56 ) |
- (((ulong)( (byte)(x >> 8) )) << 48 ) |
- (((ulong)( (byte)(x >> 16) )) << 40 ) |
- (((ulong)( (byte)(x >> 24) )) << 32 ) |
- (((ulong)( (byte)(x >> 32) )) << 24 ) |
- (((ulong)( (byte)(x >> 40) )) << 16 ) |
- (((ulong)( (byte)(x >> 48) )) << 8 ) |
- (((ulong)( (byte)(x >> 56) )) );
- }
-
- }
-}
-
+/*
+ * 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 System.IO;
+using System;
+
+namespace ActiveMQ.OpenWire
+{
+ ///
+ /// Support class that switches from one endian to the other.
+ ///
+ [CLSCompliant(false)]
+ public class EndianSupport
+ {
+
+ public static char SwitchEndian(char x)
+ {
+ return (char) (
+ (((char)( (byte)(x) )) << 8 ) |
+ (((char)( (byte)(x >> 8) )) )
+ );
+ }
+
+ public static short SwitchEndian(short x)
+ {
+ return (short) (
+ (((ushort)( (byte)(x) )) << 8 ) |
+ (((ushort)( (byte)(x >> 8) )) )
+ );
+ }
+
+ public static int SwitchEndian(int x)
+ {
+ return
+ (((int)( (byte)(x) )) << 24 ) |
+ (((int)( (byte)(x >> 8) )) << 16 ) |
+ (((int)( (byte)(x >> 16) )) << 8 ) |
+ (((int)( (byte)(x >> 24) )) );
+ }
+
+ public static long SwitchEndian(long x)
+ {
+ return
+ (((long)( (byte)(x ) )) << 56 ) |
+ (((long)( (byte)(x >> 8) )) << 48 ) |
+ (((long)( (byte)(x >> 16) )) << 40 ) |
+ (((long)( (byte)(x >> 24) )) << 32 ) |
+ (((long)( (byte)(x >> 32) )) << 24 ) |
+ (((long)( (byte)(x >> 40) )) << 16 ) |
+ (((long)( (byte)(x >> 48) )) << 8 ) |
+ (((long)( (byte)(x >> 56) )) );
+ }
+
+ public static ushort SwitchEndian(ushort x)
+ {
+ return (ushort) (
+ (((ushort)( (byte)(x) )) << 8 ) |
+ (((ushort)( (byte)(x >> 8) )) )
+ );
+ }
+
+ public static uint SwitchEndian(uint x)
+ {
+ return
+ (((uint)( (byte)(x ) )) << 24 ) |
+ (((uint)( (byte)(x >> 8) )) << 16 ) |
+ (((uint)( (byte)(x >> 16) )) << 8 ) |
+ (((uint)( (byte)(x >> 24) )) );
+ }
+
+ public static ulong SwitchEndian(ulong x)
+ {
+ return
+ (((ulong)( (byte)(x ) )) << 56 ) |
+ (((ulong)( (byte)(x >> 8) )) << 48 ) |
+ (((ulong)( (byte)(x >> 16) )) << 40 ) |
+ (((ulong)( (byte)(x >> 24) )) << 32 ) |
+ (((ulong)( (byte)(x >> 32) )) << 24 ) |
+ (((ulong)( (byte)(x >> 40) )) << 16 ) |
+ (((ulong)( (byte)(x >> 48) )) << 8 ) |
+ (((ulong)( (byte)(x >> 56) )) );
+ }
+
+ }
+}
+
diff --git a/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryReader.cs b/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryReader.cs
index 5059ee2fc9..10420e16ca 100644
--- a/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryReader.cs
+++ b/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryReader.cs
@@ -1,219 +1,224 @@
-/*
- * 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 System;
-using System.IO;
-using System.Text;
-
-namespace ActiveMQ.OpenWire
-{
- ///
- /// A BinaryWriter that switches the endian orientation of the read opperations so that they
- /// are compatible with marshalling used by OpenWire.
- ///
- [CLSCompliant(false)]
- public class OpenWireBinaryReader : BinaryReader
- {
-
- public OpenWireBinaryReader(Stream input) : base(input)
- {
- }
-
- ///
- /// Method Read
- ///
- /// An int
- /// A char[]
- /// An int
- /// An int
- public override int Read(char[] buffer, int index, int count)
- {
- int size = base.Read(buffer, index, count);
- for( int i=0; i < size; i++ ) {
- buffer[index+i] = EndianSupport.SwitchEndian(buffer[index+i]);
- }
- return size;
- }
-
- ///
- /// Method ReadChars
- ///
- /// A char[]
- /// An int
- public override char[] ReadChars(int count)
- {
- char[] rc = base.ReadChars(count);
- if( rc!=null ) {
- for( int i=0; i < rc.Length; i++ ) {
- rc[i] = EndianSupport.SwitchEndian(rc[i]);
- }
- }
- return rc;
- }
-
- ///
- /// Method ReadInt16
- ///
- /// A short
- public override short ReadInt16()
- {
- return EndianSupport.SwitchEndian(base.ReadInt16());
- }
-
- ///
- /// Method ReadChar
- ///
- /// A char
- public override char ReadChar()
- {
- return EndianSupport.SwitchEndian(base.ReadChar());
- }
-
- ///
- /// Method ReadInt64
- ///
- /// A long
- public override long ReadInt64()
- {
- return EndianSupport.SwitchEndian(base.ReadInt64());
- }
-
- ///
- /// Method ReadUInt64
- ///
- /// An ulong
- public override ulong ReadUInt64()
- {
- return EndianSupport.SwitchEndian(base.ReadUInt64());
- }
-
- ///
- /// Method ReadUInt32
- ///
- /// An uint
- public override uint ReadUInt32()
- {
- return EndianSupport.SwitchEndian(base.ReadUInt32());
- }
-
- ///
- /// Method ReadUInt16
- ///
- /// An ushort
- public override ushort ReadUInt16()
- {
- return EndianSupport.SwitchEndian(base.ReadUInt16());
- }
-
- ///
- /// Method ReadInt32
- ///
- /// An int
- public override int ReadInt32()
- {
- int x = base.ReadInt32();
- int y = EndianSupport.SwitchEndian(x);
- return y;
- }
-
- ///
- /// Method ReadString
- ///
- /// A string
- public override String ReadString()
- {
- short utflen = ReadInt16();
- if (utflen > -1)
- {
- StringBuilder str = new StringBuilder(utflen);
-
- byte[] bytearr = new byte[utflen];
- int c, char2, char3;
- int count = 0;
-
- Read(bytearr, 0, utflen);
-
- while (count < utflen)
- {
- c = bytearr[count] & 0xff;
- switch (c >> 4)
- {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- /* 0xxxxxxx */
- count++;
- str.Append((char) c);
- break;
- case 12:
- case 13:
- /* 110x xxxx 10xx xxxx */
- count += 2;
- if (count > utflen)
- {
- throw CreateDataFormatException();
- }
- char2 = bytearr[count - 1];
- if ((char2 & 0xC0) != 0x80)
- {
- throw CreateDataFormatException();
- }
- str.Append((char) (((c & 0x1F) << 6) | (char2 & 0x3F)));
- break;
- case 14:
- /* 1110 xxxx 10xx xxxx 10xx xxxx */
- count += 3;
- if (count > utflen)
- {
- throw CreateDataFormatException();
- }
- char2 = bytearr[count - 2];
- char3 = bytearr[count - 1];
- if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
- {
- throw CreateDataFormatException();
- }
- str.Append((char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)));
- break;
- default :
- /* 10xx xxxx, 1111 xxxx */
- throw CreateDataFormatException();
- }
- }
- // The number of chars produced may be less than utflen
- return str.ToString();
- }
- else
- {
- return null;
- }
- }
-
- private static Exception CreateDataFormatException()
- {
- // TODO: implement a better exception
- return new IOException("Data format error!");
- }
-
-
- }
-}
-
+/*
+ * 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 System;
+using System.IO;
+using System.Text;
+
+namespace ActiveMQ.OpenWire
+{
+ ///
+ /// A BinaryWriter that switches the endian orientation of the read opperations so that they
+ /// are compatible with marshalling used by OpenWire.
+ ///
+ [CLSCompliant(false)]
+ public class OpenWireBinaryReader : BinaryReader
+ {
+
+ public OpenWireBinaryReader(Stream input) : base(input)
+ {
+ }
+
+ ///
+ /// Method Read
+ ///
+ /// An int
+ /// A char[]
+ /// An int
+ /// An int
+ public override int Read(char[] buffer, int index, int count)
+ {
+ int size = base.Read(buffer, index, count);
+ for( int i=0; i < size; i++ ) {
+ buffer[index+i] = EndianSupport.SwitchEndian(buffer[index+i]);
+ }
+ return size;
+ }
+
+ ///
+ /// Method ReadChars
+ ///
+ /// A char[]
+ /// An int
+ public override char[] ReadChars(int count)
+ {
+ char[] rc = base.ReadChars(count);
+ if( rc!=null ) {
+ for( int i=0; i < rc.Length; i++ ) {
+ rc[i] = EndianSupport.SwitchEndian(rc[i]);
+ }
+ }
+ return rc;
+ }
+
+ ///
+ /// Method ReadInt16
+ ///
+ /// A short
+ public override short ReadInt16()
+ {
+ return EndianSupport.SwitchEndian(base.ReadInt16());
+ }
+
+ ///
+ /// Method ReadChar
+ ///
+ /// A char
+ public override char ReadChar()
+ {
+ return (char) (
+ (((char)( (byte)(base.ReadByte()) )) << 8 ) |
+ (((char)( (byte)(base.ReadByte()) )) )
+ );
+
+// return EndianSupport.SwitchEndian(base.ReadChar());
+ }
+
+ ///
+ /// Method ReadInt64
+ ///
+ /// A long
+ public override long ReadInt64()
+ {
+ return EndianSupport.SwitchEndian(base.ReadInt64());
+ }
+
+ ///
+ /// Method ReadUInt64
+ ///
+ /// An ulong
+ public override ulong ReadUInt64()
+ {
+ return EndianSupport.SwitchEndian(base.ReadUInt64());
+ }
+
+ ///
+ /// Method ReadUInt32
+ ///
+ /// An uint
+ public override uint ReadUInt32()
+ {
+ return EndianSupport.SwitchEndian(base.ReadUInt32());
+ }
+
+ ///
+ /// Method ReadUInt16
+ ///
+ /// An ushort
+ public override ushort ReadUInt16()
+ {
+ return EndianSupport.SwitchEndian(base.ReadUInt16());
+ }
+
+ ///
+ /// Method ReadInt32
+ ///
+ /// An int
+ public override int ReadInt32()
+ {
+ int x = base.ReadInt32();
+ int y = EndianSupport.SwitchEndian(x);
+ return y;
+ }
+
+ ///
+ /// Method ReadString
+ ///
+ /// A string
+ public override String ReadString()
+ {
+ short utflen = ReadInt16();
+ if (utflen > -1)
+ {
+ StringBuilder str = new StringBuilder(utflen);
+
+ byte[] bytearr = new byte[utflen];
+ int c, char2, char3;
+ int count = 0;
+
+ Read(bytearr, 0, utflen);
+
+ while (count < utflen)
+ {
+ c = bytearr[count] & 0xff;
+ switch (c >> 4)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ /* 0xxxxxxx */
+ count++;
+ str.Append((char) c);
+ break;
+ case 12:
+ case 13:
+ /* 110x xxxx 10xx xxxx */
+ count += 2;
+ if (count > utflen)
+ {
+ throw CreateDataFormatException();
+ }
+ char2 = bytearr[count - 1];
+ if ((char2 & 0xC0) != 0x80)
+ {
+ throw CreateDataFormatException();
+ }
+ str.Append((char) (((c & 0x1F) << 6) | (char2 & 0x3F)));
+ break;
+ case 14:
+ /* 1110 xxxx 10xx xxxx 10xx xxxx */
+ count += 3;
+ if (count > utflen)
+ {
+ throw CreateDataFormatException();
+ }
+ char2 = bytearr[count - 2];
+ char3 = bytearr[count - 1];
+ if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
+ {
+ throw CreateDataFormatException();
+ }
+ str.Append((char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)));
+ break;
+ default :
+ /* 10xx xxxx, 1111 xxxx */
+ throw CreateDataFormatException();
+ }
+ }
+ // The number of chars produced may be less than utflen
+ return str.ToString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private static Exception CreateDataFormatException()
+ {
+ // TODO: implement a better exception
+ return new IOException("Data format error!");
+ }
+
+
+ }
+}
+
diff --git a/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryWriter.cs b/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryWriter.cs
index 87c0494132..7b8ab846ea 100644
--- a/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryWriter.cs
+++ b/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryWriter.cs
@@ -1,195 +1,196 @@
-/*
- * 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 ActiveMQ.Commands;
-using System;
-using System.Collections;
-using System.IO;
-using System.Text;
-
-namespace ActiveMQ.OpenWire
-{
- ///
- /// A BinaryWriter that switches the endian orientation of the write opperations so that they
- /// are compatible with marshalling used by OpenWire.
- ///
- [CLSCompliant(false)]
- public class OpenWireBinaryWriter : BinaryWriter
- {
-
- public OpenWireBinaryWriter(Stream output) : base(output)
- {
- }
-
- ///
- /// Method Write
- ///
- /// A long
- public override void Write(long value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
-
- ///
- /// Method Write
- ///
- /// An ushort
- public override void Write(ushort value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
-
- ///
- /// Method Write
- ///
- /// An int
- public override void Write(int value)
- {
- int x = EndianSupport.SwitchEndian(value);
- base.Write(x);
- }
-
- ///
- /// Method Write
- ///
- /// A char[]
- /// An int
- /// An int
- public override void Write(char[] chars, int index, int count)
- {
- char[] t = new char[count];
- for( int i=0; i < count; i++ ) {
- t[index+i] = EndianSupport.SwitchEndian(t[index+i]);
- }
- base.Write(t);
- }
-
- ///
- /// Method Write
- ///
- /// A char[]
- public override void Write(char[] chars)
- {
- Write(chars, 0, chars.Length);
- }
-
- ///
- /// Method Write
- ///
- /// An uint
- public override void Write(uint value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
-
-
- ///
- /// Method Write
- ///
- /// A char
- public override void Write(char ch)
- {
- base.Write(EndianSupport.SwitchEndian(ch));
- }
-
- ///
- /// Method Write
- ///
- /// An ulong
- public override void Write(ulong value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
-
- ///
- /// Method Write
- ///
- /// A short
- public override void Write(short value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
-
-
- ///
- /// Method Write
- ///
- /// A string
- public override void Write(String text)
- {
- 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");
- }
- short strlen = (short)text.Length;
- short utflen = 0;
- int c, count = 0;
-
- char[] charr = text.ToCharArray();
-
- for (int i = 0; i < strlen; i++)
- {
- c = charr[i];
- if ((c >= 0x0001) && (c <= 0x007F))
- {
- utflen++;
- }
- else if (c > 0x07FF)
- {
- utflen += 3;
- }
- else
- {
- utflen += 2;
- }
- }
-
- Write(utflen);
- byte[] bytearr = new byte[utflen];
- for (int i = 0; i < strlen; i++)
- {
- c = charr[i];
- if ((c >= 0x0001) && (c <= 0x007F))
- {
- bytearr[count++] = (byte) c;
- }
- else if (c > 0x07FF)
- {
- bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
- bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
- bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
- }
- else
- {
- bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
- bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
- }
- }
-
- Write(bytearr);
-
- }
- else
- {
- Write((short)-1);
- }
- }
- }
-
-
-}
-
+/*
+ * 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 ActiveMQ.Commands;
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+
+namespace ActiveMQ.OpenWire
+{
+ ///
+ /// A BinaryWriter that switches the endian orientation of the write opperations so that they
+ /// are compatible with marshalling used by OpenWire.
+ ///
+ [CLSCompliant(false)]
+ public class OpenWireBinaryWriter : BinaryWriter
+ {
+
+ public OpenWireBinaryWriter(Stream output) : base(output)
+ {
+ }
+
+ ///
+ /// Method Write
+ ///
+ /// A long
+ public override void Write(long value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
+
+ ///
+ /// Method Write
+ ///
+ /// An ushort
+ public override void Write(ushort value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
+
+ ///
+ /// Method Write
+ ///
+ /// An int
+ public override void Write(int value)
+ {
+ int x = EndianSupport.SwitchEndian(value);
+ base.Write(x);
+ }
+
+ ///
+ /// Method Write
+ ///
+ /// A char[]
+ /// An int
+ /// An int
+ public override void Write(char[] chars, int index, int count)
+ {
+ char[] t = new char[count];
+ for( int i=0; i < count; i++ ) {
+ t[index+i] = EndianSupport.SwitchEndian(t[index+i]);
+ }
+ base.Write(t);
+ }
+
+ ///
+ /// Method Write
+ ///
+ /// A char[]
+ public override void Write(char[] chars)
+ {
+ Write(chars, 0, chars.Length);
+ }
+
+ ///
+ /// Method Write
+ ///
+ /// An uint
+ public override void Write(uint value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
+
+
+ ///
+ /// Method Write
+ ///
+ /// A char
+ public override void Write(char ch)
+ {
+ base.Write( (byte)( ( ch>>8 ) & 0xFF ) );
+ base.Write( (byte)( ch & 0xFF ) );
+ }
+
+ ///
+ /// Method Write
+ ///
+ /// An ulong
+ public override void Write(ulong value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
+
+ ///
+ /// Method Write
+ ///
+ /// A short
+ public override void Write(short value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
+
+
+ ///
+ /// Method Write
+ ///
+ /// A string
+ public override void Write(String text)
+ {
+ 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");
+ }
+ short strlen = (short)text.Length;
+ short utflen = 0;
+ int c, count = 0;
+
+ char[] charr = text.ToCharArray();
+
+ for (int i = 0; i < strlen; i++)
+ {
+ c = charr[i];
+ if ((c >= 0x0001) && (c <= 0x007F))
+ {
+ utflen++;
+ }
+ else if (c > 0x07FF)
+ {
+ utflen += 3;
+ }
+ else
+ {
+ utflen += 2;
+ }
+ }
+
+ Write(utflen);
+ byte[] bytearr = new byte[utflen];
+ for (int i = 0; i < strlen; i++)
+ {
+ c = charr[i];
+ if ((c >= 0x0001) && (c <= 0x007F))
+ {
+ bytearr[count++] = (byte) c;
+ }
+ else if (c > 0x07FF)
+ {
+ bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
+ bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
+ bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+ }
+ else
+ {
+ bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
+ bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+ }
+ }
+
+ Write(bytearr);
+
+ }
+ else
+ {
+ Write((short)-1);
+ }
+ }
+ }
+
+
+}
+
diff --git a/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/PrimitiveMap.cs b/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/PrimitiveMap.cs
index c0ff877bdf..a91e27e1c5 100644
--- a/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/PrimitiveMap.cs
+++ b/activemq-dotnet/src/main/csharp/ActiveMQ/OpenWire/PrimitiveMap.cs
@@ -17,6 +17,7 @@
using NMS;
using System;
using System.Collections;
+using System.IO;
namespace ActiveMQ.OpenWire
{
@@ -25,26 +26,20 @@ namespace ActiveMQ.OpenWire
///
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();
-
- ///
- /// Unmarshalls the map from the given data or if the data is null just
- /// return an empty map
- ///
- 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()
{
dictionary.Clear();
@@ -234,6 +229,227 @@ namespace ActiveMQ.OpenWire
}
}
}
+
+ ///
+ /// Method ToString
+ ///
+ /// A string
+ 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;
+ }
+
+
+
+
+ ///
+ /// Unmarshalls the map from the given data or if the data is null just
+ /// return an empty map
+ ///
+ public static PrimitiveMap Unmarshal(byte[] data)
+ {
+ PrimitiveMap answer = new PrimitiveMap();
+ answer.dictionary = UnmarshalPrimitiveMap(data);
+ return answer;
+ }
+
+ public byte[] Marshal()
+ {
+ return MarshalPrimitiveMap(dictionary);
+ }
+
+
+ ///
+ /// Marshals the primitive type map to a byte array
+ ///
+ 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);
+ }
+ }}
+
+
+
+ ///
+ /// Unmarshals the primitive type map from the given byte array
+ ///
+ 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;
+ }
+
}
}
diff --git a/activemq-dotnet/src/test/csharp/ActiveMQ/OpenWire/PrimitiveMapTest.cs b/activemq-dotnet/src/test/csharp/ActiveMQ/OpenWire/PrimitiveMapTest.cs
new file mode 100644
index 0000000000..01ce5faaa2
--- /dev/null
+++ b/activemq-dotnet/src/test/csharp/ActiveMQ/OpenWire/PrimitiveMapTest.cs
@@ -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");
+ }
+
+
+ }
+}
+
diff --git a/activemq-dotnet/src/test/csharp/NMS/MessageTest.cs b/activemq-dotnet/src/test/csharp/NMS/MessageTest.cs
index de3f12e092..e1aabbbd2f 100644
--- a/activemq-dotnet/src/test/csharp/NMS/MessageTest.cs
+++ b/activemq-dotnet/src/test/csharp/NMS/MessageTest.cs
@@ -1,122 +1,122 @@
-/*
- * 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 NMS;
-using NUnit.Framework;
-using System;
-
-
-namespace NMS
-{
- [ TestFixture ]
- public class MessageTest : JMSTestSupport
- {
- 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;
-
- [SetUp]
- override public void SetUp()
- {
- base.SetUp();
- }
-
- [TearDown]
- override public void TearDown()
- {
- base.TearDown();
- }
-
- [ Test ]
- public override void SendAndSyncReceive()
- {
- base.SendAndSyncReceive();
- }
-
- protected override IMessage CreateMessage()
- {
- IMessage message = session.CreateMessage();
-
- message.Properties["a"] = a;
- message.Properties["b"] = b;
- message.Properties["c"] = c;
- message.Properties["d"] = d;
- message.Properties["e"] = e;
- message.Properties["f"] = f;
- message.Properties["g"] = g;
- message.Properties["h"] = h;
- message.Properties["i"] = i;
- message.Properties["j"] = j;
- message.Properties["k"] = k;
- message.Properties["l"] = l;
-
- return message;
- }
-
- protected override void AssertValidMessage(IMessage message)
- {
- Console.WriteLine("Received message: " + message);
- Console.WriteLine("Received Count: " + message.Properties.Count);
-
- Assert.AreEqual(ToHex(f), ToHex(message.Properties.GetLong("f")), "map entry: f as hex");
-
- // use generic API to access entries
- Assert.AreEqual(a, message.Properties["a"], "generic map entry: a");
- Assert.AreEqual(b, message.Properties["b"], "generic map entry: b");
- Assert.AreEqual(c, message.Properties["c"], "generic map entry: c");
- Assert.AreEqual(d, message.Properties["d"], "generic map entry: d");
- Assert.AreEqual(e, message.Properties["e"], "generic map entry: e");
- Assert.AreEqual(f, message.Properties["f"], "generic map entry: f");
- Assert.AreEqual(g, message.Properties["g"], "generic map entry: g");
- Assert.AreEqual(h, message.Properties["h"], "generic map entry: h");
- Assert.AreEqual(i, message.Properties["i"], "generic map entry: i");
- Assert.AreEqual(j, message.Properties["j"], "generic map entry: j");
- Assert.AreEqual(k, message.Properties["k"], "generic map entry: k");
- Assert.AreEqual(l, message.Properties["l"], "generic map entry: l");
-
- // use type safe APIs
- Assert.AreEqual(a, message.Properties.GetBool("a"), "map entry: a");
- Assert.AreEqual(b, message.Properties.GetByte("b"), "map entry: b");
- Assert.AreEqual(c, message.Properties.GetChar("c"), "map entry: c");
- Assert.AreEqual(d, message.Properties.GetShort("d"), "map entry: d");
- Assert.AreEqual(e, message.Properties.GetInt("e"), "map entry: e");
- Assert.AreEqual(f, message.Properties.GetLong("f"), "map entry: f");
- Assert.AreEqual(g, message.Properties.GetString("g"), "map entry: g");
- Assert.AreEqual(h, message.Properties.GetBool("h"), "map entry: h");
- Assert.AreEqual(i, message.Properties.GetByte("i"), "map entry: i");
- Assert.AreEqual(j, message.Properties.GetShort("j"), "map entry: j");
- Assert.AreEqual(k, message.Properties.GetInt("k"), "map entry: k");
- Assert.AreEqual(l, message.Properties.GetLong("l"), "map entry: l");
-
- }
-
- protected string ToHex(long value)
- {
- return String.Format("{0:x}", value);
- }
-
- }
-}
-
+/*
+ * 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 NMS;
+using NUnit.Framework;
+using System;
+
+
+namespace NMS
+{
+ [ TestFixture ]
+ public class MessageTest : JMSTestSupport
+ {
+ 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;
+
+ [SetUp]
+ override public void SetUp()
+ {
+ base.SetUp();
+ }
+
+ [TearDown]
+ override public void TearDown()
+ {
+ base.TearDown();
+ }
+
+ [ Test ]
+ public override void SendAndSyncReceive()
+ {
+ base.SendAndSyncReceive();
+ }
+
+ protected override IMessage CreateMessage()
+ {
+ IMessage message = session.CreateMessage();
+
+ message.Properties["a"] = a;
+ message.Properties["b"] = b;
+ message.Properties["c"] = c;
+ message.Properties["d"] = d;
+ message.Properties["e"] = e;
+ message.Properties["f"] = f;
+ message.Properties["g"] = g;
+ message.Properties["h"] = h;
+ message.Properties["i"] = i;
+ message.Properties["j"] = j;
+ message.Properties["k"] = k;
+ message.Properties["l"] = l;
+
+ return message;
+ }
+
+ protected override void AssertValidMessage(IMessage message)
+ {
+ Console.WriteLine("Received message: " + message);
+ Console.WriteLine("Received Count: " + message.Properties.Count);
+
+ Assert.AreEqual(ToHex(f), ToHex(message.Properties.GetLong("f")), "map entry: f as hex");
+
+ // use generic API to access entries
+ Assert.AreEqual(a, message.Properties["a"], "generic map entry: a");
+ Assert.AreEqual(b, message.Properties["b"], "generic map entry: b");
+ Assert.AreEqual(c, message.Properties["c"], "generic map entry: c");
+ Assert.AreEqual(d, message.Properties["d"], "generic map entry: d");
+ Assert.AreEqual(e, message.Properties["e"], "generic map entry: e");
+ Assert.AreEqual(f, message.Properties["f"], "generic map entry: f");
+ Assert.AreEqual(g, message.Properties["g"], "generic map entry: g");
+ Assert.AreEqual(h, message.Properties["h"], "generic map entry: h");
+ Assert.AreEqual(i, message.Properties["i"], "generic map entry: i");
+ Assert.AreEqual(j, message.Properties["j"], "generic map entry: j");
+ Assert.AreEqual(k, message.Properties["k"], "generic map entry: k");
+ Assert.AreEqual(l, message.Properties["l"], "generic map entry: l");
+
+ // use type safe APIs
+ Assert.AreEqual(a, message.Properties.GetBool("a"), "map entry: a");
+ Assert.AreEqual(b, message.Properties.GetByte("b"), "map entry: b");
+ Assert.AreEqual(c, message.Properties.GetChar("c"), "map entry: c");
+ Assert.AreEqual(d, message.Properties.GetShort("d"), "map entry: d");
+ Assert.AreEqual(e, message.Properties.GetInt("e"), "map entry: e");
+ Assert.AreEqual(f, message.Properties.GetLong("f"), "map entry: f");
+ Assert.AreEqual(g, message.Properties.GetString("g"), "map entry: g");
+ Assert.AreEqual(h, message.Properties.GetBool("h"), "map entry: h");
+ Assert.AreEqual(i, message.Properties.GetByte("i"), "map entry: i");
+ Assert.AreEqual(j, message.Properties.GetShort("j"), "map entry: j");
+ Assert.AreEqual(k, message.Properties.GetInt("k"), "map entry: k");
+ Assert.AreEqual(l, message.Properties.GetLong("l"), "map entry: l");
+
+ }
+
+ protected string ToHex(long value)
+ {
+ return String.Format("{0:x}", value);
+ }
+
+ }
+}
+