activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r380666 - in /incubator/activemq/trunk/openwire-dotnet: src/OpenWire.Client/Commands/ src/OpenWire.Client/Core/ tests/OpenWire.Client/
Date Fri, 24 Feb 2006 13:16:18 GMT
Author: jstrachan
Date: Fri Feb 24 05:16:09 2006
New Revision: 380666

URL: http://svn.apache.org/viewcvs?rev=380666&view=rev
Log:
added full test for MapMessage together with fixing a bug with long marshalling types and
headers

Modified:
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMapMessage.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMessage.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/DataStreamMarshaller.cs
    incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/JMSPropertyTest.cs
    incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/MapMessageTest.cs

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMapMessage.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMapMessage.cs?rev=380666&r1=380665&r2=380666&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMapMessage.cs
(original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMapMessage.cs
Fri Feb 24 05:16:09 2006
@@ -39,22 +39,26 @@
             get {
                 if (body == null)
                 {
-                        body = PrimitiveMap.Unmarshal(Content);
-                   }
+                    body = PrimitiveMap.Unmarshal(Content);
+                }
                 return body;
             }
         }
         
-        public void BeforeMarshall(OpenWireFormat wireFormat)
+        public override void BeforeMarshall(OpenWireFormat wireFormat)
         {
-            base.BeforeMarshall(wireFormat);
-            
-            if (body == null) {
+            if (body == null)
+            {
                 Content = null;
             }
-            else {
+            else
+            {
                 Content = body.Marshal();
             }
+            
+            Console.WriteLine("BeforeMarshalling, content is: " + Content);
+
+            base.BeforeMarshall(wireFormat);
         }
         
     }

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMessage.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMessage.cs?rev=380666&r1=380665&r2=380666&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMessage.cs
(original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMessage.cs
Fri Feb 24 05:16:09 2006
@@ -277,7 +277,7 @@
             return true;
         }
         
-        public void BeforeMarshall(OpenWireFormat wireFormat)
+        public virtual void BeforeMarshall(OpenWireFormat wireFormat)
         {
             MarshalledProperties = null;
             if (properties != null)
@@ -286,23 +286,23 @@
             }
         }
         
-        public void AfterMarshall(OpenWireFormat wireFormat)
+        public virtual void AfterMarshall(OpenWireFormat wireFormat)
         {
         }
         
-        public void BeforeUnmarshall(OpenWireFormat wireFormat)
+        public virtual void BeforeUnmarshall(OpenWireFormat wireFormat)
         {
         }
         
-        public void AfterUnmarshall(OpenWireFormat wireFormat)
+        public virtual void AfterUnmarshall(OpenWireFormat wireFormat)
         {
         }
         
-        public void SetMarshalledForm(OpenWireFormat wireFormat, byte[] data)
+        public virtual void SetMarshalledForm(OpenWireFormat wireFormat, byte[] data)
         {
         }
         
-        public byte[] GetMarshalledForm(OpenWireFormat wireFormat)
+        public virtual byte[] GetMarshalledForm(OpenWireFormat wireFormat)
         {
             return null;
         }

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/DataStreamMarshaller.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/DataStreamMarshaller.cs?rev=380666&r1=380665&r2=380666&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/DataStreamMarshaller.cs
(original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/DataStreamMarshaller.cs
Fri Feb 24 05:16:09 2006
@@ -331,6 +331,12 @@
             dataOut.Write(SwitchEndian(value));
         }
         
+        public static void WriteLong(long value, BinaryWriter dataOut)
+        {
+            dataOut.Write(SwitchEndian(value));
+        }
+        
+        
         /// <summary>
         /// Switches from one endian to the other
         /// </summary>
@@ -359,11 +365,6 @@
                 answer += lowest;
             }
             return answer;
-        }
-        
-        public static void WriteLong(long value, BinaryWriter dataOut)
-        {
-            dataOut.Write(IPAddress.HostToNetworkOrder(value));
         }
         
         public virtual int Marshal1Long(OpenWireFormat wireFormat, long o, BooleanStream
bs)

Modified: incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/JMSPropertyTest.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/JMSPropertyTest.cs?rev=380666&r1=380665&r2=380666&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/JMSPropertyTest.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/JMSPropertyTest.cs Fri
Feb 24 05:16:09 2006
@@ -104,14 +104,14 @@
             Assert.AreEqual(custom3, message.Properties["custom3"], "custom3");
             Assert.AreEqual(custom4, message.Properties["custom4"], "custom4");
             // TODO
-            //Assert.AreEqual(custom5, message.Properties["custom5"], "custom5");
+            Assert.AreEqual(custom5, message.Properties["custom5"], "custom5");
             Assert.AreEqual(custom6, message.Properties["custom6"], "custom6");
             
             Assert.AreEqual(custom1, message.Properties.GetBool("custom1"), "custom1");
             Assert.AreEqual(custom2, message.Properties.GetByte("custom2"), "custom2");
             Assert.AreEqual(custom3, message.Properties.GetShort("custom3"), "custom3");
             Assert.AreEqual(custom4, message.Properties.GetInt("custom4"), "custom4");
-            //Assert.AreEqual(custom5, message.Properties.GetLong("custom5"), "custom5");
+            Assert.AreEqual(custom5, message.Properties.GetLong("custom5"), "custom5");
             Assert.AreEqual(custom6, message.Properties.GetChar("custom6"), "custom6");
             
             // lets now look at some standard JMS headers

Modified: incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/MapMessageTest.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/MapMessageTest.cs?rev=380666&r1=380665&r2=380666&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/MapMessageTest.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/MapMessageTest.cs Fri Feb
24 05:16:09 2006
@@ -43,23 +43,53 @@
         
         protected override IMessage CreateMessage(ISession session)
         {
-            IMapMessage request = session.CreateMapMessage();
-            return request;
+            IMapMessage message = session.CreateMapMessage();
+            
+            message.Body["a"] = a;
+            message.Body["b"] = b;
+            message.Body["c"] = c;
+            message.Body["d"] = d;
+            message.Body["e"] = e;
+            message.Body["f"] = f;
+            message.Body["g"] = g;
+            
+            return message;
         }
         
         protected override void AssertValidMessage(IMessage message)
         {
             Assert.IsTrue(message is IMapMessage, "Did not receive a MapMessage!");
+            IMapMessage mapMessage = (IMapMessage) message;
             
             Console.WriteLine("Received MapMessage: " + message);
+            Console.WriteLine("Received Count: " + mapMessage.Body.Count);
 
-            IMapMessage mapMessage = (IMapMessage) message;
+            Assert.AreEqual(ToHex(f), ToHex(mapMessage.Body.GetLong("f")), "map entry: f
as hex");
+            
+            // use generic API to access entries
+            Assert.AreEqual(a, mapMessage.Body["a"], "generic map entry: a");
+            Assert.AreEqual(b, mapMessage.Body["b"], "generic map entry: b");
+            Assert.AreEqual(c, mapMessage.Body["c"], "generic map entry: c");
+            Assert.AreEqual(d, mapMessage.Body["d"], "generic map entry: d");
+            Assert.AreEqual(e, mapMessage.Body["e"], "generic map entry: e");
+            Assert.AreEqual(f, mapMessage.Body["f"], "generic map entry: f");
+            Assert.AreEqual(g, mapMessage.Body["g"], "generic map entry: g");
+            
+            // use type safe APIs
+            Assert.AreEqual(a, mapMessage.Body.GetBool("a"), "map entry: a");
+            Assert.AreEqual(b, mapMessage.Body.GetByte("b"), "map entry: b");
+            Assert.AreEqual(c, mapMessage.Body.GetChar("c"), "map entry: c");
+            Assert.AreEqual(d, mapMessage.Body.GetShort("d"), "map entry: d");
+            Assert.AreEqual(e, mapMessage.Body.GetInt("e"), "map entry: e");
+            Assert.AreEqual(f, mapMessage.Body.GetLong("f"), "map entry: f");
+            Assert.AreEqual(g, mapMessage.Body.GetString("g"), "map entry: g");
+            
             
-            /*
-            String text = mapMessage.Text;
-            Assert.AreEqual(expected, text, "the message text");
-             */
         }
         
+        protected string ToHex(long value)
+        {
+            return String.Format("{0:x}", value);
+        }
     }
 }



Mime
View raw message