activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r940919 - in /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk: ./ src/main/csharp/Commands/ src/main/csharp/Protocol/ src/test/csharp/ src/test/csharp/Commands/
Date Tue, 04 May 2010 15:52:23 GMT
Author: tabish
Date: Tue May  4 15:52:22 2010
New Revision: 940919

URL: http://svn.apache.org/viewvc?rev=940919&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQNET-248

Fix issue with MessageID not getting converted to a String correctly.

Added:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs
  (with props)
Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseDataStructure.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerId.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompHelper.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/MessageTest.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/StompHelperTest.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseDataStructure.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseDataStructure.cs?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseDataStructure.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseDataStructure.cs
Tue May  4 15:52:22 2010
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Text;
 using Apache.NMS.Stomp.Protocol;
 
 namespace Apache.NMS.Stomp.Commands
@@ -82,5 +83,6 @@ namespace Apache.NMS.Stomp.Commands
             // if we had any.
             return this.MemberwiseClone();
         }
+
     }
 }

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerId.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerId.cs?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerId.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerId.cs
Tue May  4 15:52:22 2010
@@ -24,6 +24,8 @@ namespace Apache.NMS.Stomp.Commands
     {
         public const byte ID_CONSUMERID = 122;
 
+        private string key;
+
         private SessionId parentId = null;
 
         string connectionId;
@@ -34,6 +36,43 @@ namespace Apache.NMS.Stomp.Commands
         {
         }
 
+        public ConsumerId( string consumerKey )
+        {
+            this.key = consumerKey;
+
+            // We give the Connection ID the key for now so there's at least some
+            // data stored into the Id.
+            this.ConnectionId = consumerKey;
+
+            int idx = consumerKey.LastIndexOf(':');
+            if( idx >= 0 )
+            {
+                try
+                {
+                    this.Value = Int32.Parse(consumerKey.Substring(idx + 1));
+                    consumerKey = consumerKey.Substring(0, idx);
+                    idx = consumerKey.LastIndexOf(':');
+                    if (idx >= 0)
+                    {
+                        try
+                        {
+                            this.SessionId = Int32.Parse(consumerKey.Substring(idx + 1));
+                            consumerKey = consumerKey.Substring(0, idx);
+                        }
+                        catch(Exception ex)
+                        {
+                            Tracer.Debug(ex.Message);
+                        }
+                    }
+                    this.ConnectionId = consumerKey;
+                }
+                catch(Exception ex)
+                {
+                    Tracer.Debug(ex.Message);
+                }
+            }
+        }
+
         public ConsumerId( SessionId sessionId, long consumerId )
         {
             this.connectionId = sessionId.ConnectionId;
@@ -60,7 +99,12 @@ namespace Apache.NMS.Stomp.Commands
         ///
         public override string ToString()
         {
-            return ConnectionId + ":" + SessionId + ":" + Value;
+            if( key == null )
+            {
+                this.key = ConnectionId + ":" + SessionId + ":" + Value;
+            }
+
+            return key;
         }
 
         public SessionId ParentId
@@ -114,6 +158,11 @@ namespace Apache.NMS.Stomp.Commands
 
         public virtual bool Equals(ConsumerId that)
         {
+            if(this.key != null && that.key != null)
+            {
+                return this.key.Equals(that.key);
+            }
+
             if(!Equals(this.ConnectionId, that.ConnectionId))
             {
                 return false;

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs Tue
May  4 15:52:22 2010
@@ -208,9 +208,7 @@ namespace Apache.NMS.Stomp.Commands
             {
                 if(null != MessageId)
                 {
-                    return MessageId.ProducerId.ConnectionId + ":" +
-                           MessageId.ProducerId.SessionId + ":" +
-                           MessageId.ProducerId.Value;
+                    return MessageId.ToString();
                 }
 
                 return String.Empty;

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs
Tue May  4 15:52:22 2010
@@ -62,7 +62,7 @@ namespace Apache.NMS.Stomp.Commands
         ///
         public override string ToString()
         {
-            if(key == null)
+            if( key == null )
             {
                 key = producerId.ToString() + ":" + producerSequenceId;
             }

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs
Tue May  4 15:52:22 2010
@@ -24,6 +24,8 @@ namespace Apache.NMS.Stomp.Commands
     {
         private SessionId parentId;
 
+        private string key = null;
+
         string connectionId;
         long value;
         long sessionId;
@@ -41,13 +43,30 @@ namespace Apache.NMS.Stomp.Commands
 
         public ProducerId(string producerKey)
         {
-            // Parse off the producerId
-            int p = producerKey.LastIndexOf(":");
-            if(p >= 0)
-            {
-                value = Int64.Parse(producerKey.Substring(p + 1));
-                producerKey = producerKey.Substring(0, p);
+            // Store the original.
+            this.key = producerKey;
+
+            // Try and get back the AMQ version of the data.
+            int idx = producerKey.LastIndexOf(':');
+            if(idx >= 0)
+            {
+                try
+                {
+                    this.Value = Int32.Parse(producerKey.Substring(idx + 1));
+                    producerKey = producerKey.Substring(0, idx);
+                    idx = producerKey.LastIndexOf(':');
+                    if(idx >= 0)
+                    {
+                        this.SessionId = Int32.Parse(producerKey.Substring(idx + 1));
+                        producerKey = producerKey.Substring(0, idx);
+                    }
+                }
+                catch(Exception ex)
+                {
+                    Tracer.Debug(ex.Message);
+                }
             }
+            this.ConnectionId = producerKey;
         }
 
         ///
@@ -69,7 +88,12 @@ namespace Apache.NMS.Stomp.Commands
         ///
         public override string ToString()
         {
-            return ConnectionId + ":" + SessionId + ":" + Value;
+            if( this.key == null )
+            {
+                this.key = ConnectionId + ":" + SessionId + ":" + Value;
+            }
+
+            return this.key;
         }
 
         public SessionId ParentId

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompHelper.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompHelper.cs?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompHelper.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompHelper.cs
Tue May  4 15:52:22 2010
@@ -26,30 +26,6 @@ namespace Apache.NMS.Stomp.Protocol
     /// </summary>
     public class StompHelper
     {
-        private static int ParseInt(string text)
-        {
-            StringBuilder sbtext = new StringBuilder();
-
-            for(int idx = 0; idx < text.Length; idx++)
-            {
-                if(char.IsNumber(text, idx) || text[idx] == '-')
-                {
-                    sbtext.Append(text[idx]);
-                }
-                else
-                {
-                    break;
-                }
-            }
-
-            if(sbtext.Length > 0)
-            {
-                return Int32.Parse(sbtext.ToString());
-            }
-
-            return 0;
-        }
-
         public static Destination ToDestination(string text)
         {
             if(text == null)
@@ -134,135 +110,6 @@ namespace Apache.NMS.Stomp.Protocol
                 return "client";
             }
         }
-        
-        public static string ToStomp(ConsumerId id)
-        {
-            return id.ConnectionId + ":" + id.SessionId + ":" + id.Value;
-        }
-
-        public static ConsumerId ToConsumerId(string text)
-        {
-            if(text == null)
-            {
-                return null;
-            }
-
-            ConsumerId answer = new ConsumerId();
-            int idx = text.LastIndexOf(':');
-            if (idx >= 0)
-            {
-                try
-                {
-                    answer.Value = ParseInt(text.Substring(idx + 1));
-                    text = text.Substring(0, idx);
-                    idx = text.LastIndexOf(':');
-                    if (idx >= 0)
-                    {
-                        try
-                        {
-                            answer.SessionId = ParseInt(text.Substring(idx + 1));
-                            text = text.Substring(0, idx);
-                        }
-                        catch(Exception ex)
-                        {
-                            Tracer.Debug(ex.Message);
-                        }
-                    }
-                }
-                catch(Exception ex)
-                {
-                    Tracer.Debug(ex.Message);
-                }
-            }
-            answer.ConnectionId = text;
-            return answer;
-        }
-
-        public static string ToStomp(ProducerId id)
-        {
-            StringBuilder producerBuilder = new StringBuilder();
-
-            producerBuilder.Append(id.ConnectionId);
-            producerBuilder.Append(":");
-            producerBuilder.Append(id.SessionId);
-            producerBuilder.Append(":");
-            producerBuilder.Append(id.Value);
-
-            return producerBuilder.ToString();
-        }
-
-        public static ProducerId ToProducerId(string text)
-        {
-            if(text == null)
-            {
-                return null;
-            }
-
-            ProducerId answer = new ProducerId();
-            int idx = text.LastIndexOf(':');
-            if(idx >= 0)
-            {
-                try
-                {
-                    answer.Value = ParseInt(text.Substring(idx + 1));
-                    text = text.Substring(0, idx);
-                    idx = text.LastIndexOf(':');
-                    if(idx >= 0)
-                    {
-                        answer.SessionId = ParseInt(text.Substring(idx + 1));
-                        text = text.Substring(0, idx);
-                    }
-                }
-                catch(Exception ex)
-                {
-                    Tracer.Debug(ex.Message);
-                }
-            }
-            answer.ConnectionId = text;
-            return answer;
-        }
-
-        public static string ToStomp(MessageId id)
-        {
-            StringBuilder messageBuilder = new StringBuilder();
-
-            messageBuilder.Append(ToStomp(id.ProducerId));
-            messageBuilder.Append(":");
-            messageBuilder.Append(id.ProducerSequenceId);
-
-            return messageBuilder.ToString();
-        }
-
-        public static MessageId ToMessageId(string text)
-        {
-            if(text == null)
-            {
-                return null;
-            }
-
-            MessageId answer = new MessageId();
-            int idx = text.LastIndexOf(':');
-            if (idx >= 0)
-            {
-                try
-                {
-                    answer.ProducerSequenceId = ParseInt(text.Substring(idx + 1));
-                    text = text.Substring(0, idx);
-                }
-                catch(Exception ex)
-                {
-                    Tracer.Debug(ex.Message);
-                }
-            }
-            answer.ProducerId = ToProducerId(text);
-
-            return answer;
-        }
-
-        public static string ToStomp(TransactionId id)
-        {
-            return id.ConnectionId.Value + ":" + id.Value;
-        }
 
         public static bool ToBool(string text, bool defaultValue)
         {

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
Tue May  4 15:52:22 2010
@@ -216,12 +216,12 @@ namespace Apache.NMS.Stomp.Protocol
             message.Type = frame.RemoveProperty("type");
             message.Destination = StompHelper.ToDestination(frame.RemoveProperty("destination"));
             message.ReplyTo = StompHelper.ToDestination(frame.RemoveProperty("reply-to"));
-            message.TargetConsumerId = StompHelper.ToConsumerId(frame.RemoveProperty("subscription"));
+            message.TargetConsumerId = new ConsumerId(frame.RemoveProperty("subscription"));
             message.CorrelationId = frame.RemoveProperty("correlation-id");
 
             Tracer.Debug("RECV - Inbound MessageId = " + frame.GetProperty("message-id"));
           
-            message.MessageId = StompHelper.ToMessageId(frame.RemoveProperty("message-id"));
+            message.MessageId = new MessageId(frame.RemoveProperty("message-id"));
             message.Persistent = StompHelper.ToBool(frame.RemoveProperty("persistent"), false);
 
             // If it came from NMS.Stomp we added this header to ensure its reported on the
@@ -320,7 +320,7 @@ namespace Apache.NMS.Stomp.Protocol
             }
             if(command.TransactionId!=null)
             {
-                frame.SetProperty("transaction", StompHelper.ToStomp(command.TransactionId));
+                frame.SetProperty("transaction", command.TransactionId.ToString());
             }
 
             frame.SetProperty("persistent", command.Persistent.ToString().ToLower());
@@ -372,13 +372,13 @@ namespace Apache.NMS.Stomp.Protocol
                 frame.SetProperty("receipt", "ignore:" + command.CommandId);
             }   
 
-            frame.SetProperty("message-id", StompHelper.ToStomp(command.LastMessageId));
+            frame.SetProperty("message-id", command.LastMessageId.ToString());
 
             Tracer.Debug("ACK - Outbound MessageId = " + frame.GetProperty("message-id"));
             
             if(command.TransactionId != null)
             {
-                frame.SetProperty("transaction", StompHelper.ToStomp(command.TransactionId));
+                frame.SetProperty("transaction", command.TransactionId.ToString());
             }
 
             frame.ToStream(dataOut);
@@ -415,7 +415,7 @@ namespace Apache.NMS.Stomp.Protocol
             }
             
             frame.SetProperty("destination", StompHelper.ToStomp(command.Destination));
-            frame.SetProperty("id", StompHelper.ToStomp(command.ConsumerId));
+            frame.SetProperty("id", command.ConsumerId.ToString());
             frame.SetProperty("durable-subscriber-name", command.SubscriptionName);
             frame.SetProperty("selector", command.Selector);
             frame.SetProperty("ack", StompHelper.ToStomp(command.AckMode));
@@ -477,7 +477,7 @@ namespace Apache.NMS.Stomp.Protocol
                 {
                     frame.SetProperty("receipt", command.CommandId);
                 }                
-                frame.SetProperty("id", StompHelper.ToStomp(consumerId));
+                frame.SetProperty("id", consumerId.ToString() );
                 frame.ToStream(dataOut);
             }
         }
@@ -507,7 +507,7 @@ namespace Apache.NMS.Stomp.Protocol
                 frame.SetProperty("receipt", command.CommandId);
             }
             
-            frame.SetProperty("transaction", StompHelper.ToStomp(command.TransactionId));
+            frame.SetProperty("transaction", command.TransactionId.ToString());
             frame.ToStream(dataOut);
         }
 

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs?rev=940919&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs
Tue May  4 15:52:22 2010
@@ -0,0 +1,67 @@
+// /*
+//  * Licensed to the Apache Software Foundation (ASF) under one or more
+//  * contributor license agreements.  See the NOTICE file distributed with
+//  * this work for additional information regarding copyright ownership.
+//  * The ASF licenses this file to You 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 NUnit.Framework;
+using Apache.NMS.Stomp.Commands;
+
+namespace Apache.NMS.Stomp.Test.Commands
+{
+    [TestFixture()]
+    public class ConsumerIdTest
+    {
+        [Test()]
+        public void TestAmqTypeProcessing()
+        {
+            ConsumerId id = new ConsumerId();
+            id.ConnectionId = "cheese";
+            id.SessionId = 2;
+            id.Value = 3;
+
+            string text = id.ToString();
+            Assert.AreEqual("cheese:2:3", text, "ConsumerId as stomp");
+
+            ConsumerId another = new ConsumerId("abc:5:6");
+            Assert.AreEqual("abc", another.ConnectionId, "extracting consumerId.ConnectionId");
+            Assert.AreEqual(5, another.SessionId, "extracting consumerId.SessionId");
+            Assert.AreEqual(6, another.Value, "extracting consumerId.Value");
+        }
+
+        [Test()]
+        public void TestNonAmqTypeProcessing()
+        {
+            ConsumerId id = new ConsumerId();
+            id.ConnectionId = "cheese";
+            id.SessionId = 2;
+            id.Value = 3;
+
+            string text = id.ToString();
+            Assert.AreEqual("cheese:2:3", text, "ConsumerId as stomp");
+
+            ConsumerId another = new ConsumerId("abc56");
+            Assert.AreEqual("abc56", another.ConnectionId, "extracting consumerId.ConnectionId");
+            Assert.AreEqual(0, another.SessionId, "extracting consumerId.SessionId");
+            Assert.AreEqual(0, another.Value, "extracting consumerId.Value");
+
+            another = new ConsumerId("abc:def");
+            Assert.AreEqual("abc:def", another.ConnectionId, "extracting consumerId.ConnectionId");
+            Assert.AreEqual(0, another.SessionId, "extracting consumerId.SessionId");
+            Assert.AreEqual(0, another.Value, "extracting consumerId.Value");
+        }
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs?rev=940919&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs
Tue May  4 15:52:22 2010
@@ -0,0 +1,67 @@
+// /*
+//  * Licensed to the Apache Software Foundation (ASF) under one or more
+//  * contributor license agreements.  See the NOTICE file distributed with
+//  * this work for additional information regarding copyright ownership.
+//  * The ASF licenses this file to You 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 NUnit.Framework;
+using Apache.NMS.Stomp.Commands;
+
+namespace Apache.NMS.Stomp.Test.Commands
+{
+    [TestFixture]
+    public class ProducerIdTest
+    {
+        [Test]
+        public void TestAmqTypeProcessing()
+        {
+            ProducerId id = new ProducerId();
+            id.ConnectionId = "cheese";
+            id.SessionId = 2;
+            id.Value = 3;
+
+            string text = id.ToString();
+            Assert.AreEqual("cheese:2:3", text, "ConsumerId as stomp");
+
+            ProducerId another = new ProducerId("abc:5:6");
+            Assert.AreEqual("abc", another.ConnectionId, "extracting consumerId.ConnectionId");
+            Assert.AreEqual(5, another.SessionId, "extracting consumerId.SessionId");
+            Assert.AreEqual(6, another.Value, "extracting consumerId.Value");
+        }
+
+        [Test]
+        public void TestNonAmqTypeProcessing()
+        {
+            ProducerId id = new ProducerId();
+            id.ConnectionId = "cheese";
+            id.SessionId = 2;
+            id.Value = 3;
+
+            string text = id.ToString();
+            Assert.AreEqual("cheese:2:3", text, "ConsumerId as stomp");
+
+            ProducerId another = new ProducerId("abc56");
+            Assert.AreEqual("abc56", another.ConnectionId, "extracting consumerId.ConnectionId");
+            Assert.AreEqual(0, another.SessionId, "extracting consumerId.SessionId");
+            Assert.AreEqual(0, another.Value, "extracting consumerId.Value");
+
+            another = new ProducerId("abc:def");
+            Assert.AreEqual("abc:def", another.ConnectionId, "extracting consumerId.ConnectionId");
+            Assert.AreEqual(0, another.SessionId, "extracting consumerId.SessionId");
+            Assert.AreEqual(0, another.Value, "extracting consumerId.Value");
+        }
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/MessageTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/MessageTest.cs?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/MessageTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/MessageTest.cs Tue May
 4 15:52:22 2010
@@ -47,6 +47,45 @@ namespace Apache.NMS.Stomp.Test
         [RowTest]
         [Row(MsgDeliveryMode.Persistent)]
         [Row(MsgDeliveryMode.NonPersistent)]
+        public void SendReceiveMessageIdComparisonTest(MsgDeliveryMode deliveryMode)
+        {
+            using(IConnection connection = CreateConnection(TEST_CLIENT_ID + ":" + new Random().Next()))
+            {
+                connection.Start();
+                using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+                {
+                    IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME);
+                    using(IMessageConsumer consumer = session.CreateConsumer(destination))
+                    using(IMessageProducer producer = session.CreateProducer(destination))
+                    {
+                        producer.DeliveryMode = deliveryMode;
+                        producer.RequestTimeout = receiveTimeout;
+                        IMessage request1 = session.CreateMessage();
+                        IMessage request2 = session.CreateMessage();
+                        IMessage request3 = session.CreateMessage();
+
+                        producer.Send(request1);
+                        producer.Send(request2);
+                        producer.Send(request3);
+
+                        IMessage message1 = consumer.Receive(receiveTimeout);
+                        Assert.IsNotNull(message1, "No message returned!");
+                        IMessage message2 = consumer.Receive(receiveTimeout);
+                        Assert.IsNotNull(message2, "No message returned!");
+                        IMessage message3 = consumer.Receive(receiveTimeout);
+                        Assert.IsNotNull(message3, "No message returned!");
+
+                        Assert.AreNotEqual(message1.NMSMessageId, message2.NMSMessageId);
+                        Assert.AreNotEqual(message1.NMSMessageId, message3.NMSMessageId);
+                        Assert.AreNotEqual(message2.NMSMessageId, message3.NMSMessageId);
+                    }
+                }
+            }
+        }
+
+        [RowTest]
+        [Row(MsgDeliveryMode.Persistent)]
+        [Row(MsgDeliveryMode.NonPersistent)]
         public void SendReceiveMessageProperties(MsgDeliveryMode deliveryMode)
         {
             using(IConnection connection = CreateConnection(TEST_CLIENT_ID + ":" + new Random().Next()))

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/StompHelperTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/StompHelperTest.cs?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/StompHelperTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/StompHelperTest.cs Tue
May  4 15:52:22 2010
@@ -31,10 +31,10 @@ namespace Apache.NMS.Stomp.Test
             id.SessionId = 2;
             id.Value = 3;
 
-            string text = StompHelper.ToStomp(id);
+            string text = id.ToString();
             Assert.AreEqual("cheese:2:3", text, "ConsumerId as stomp");
 
-            ConsumerId another = StompHelper.ToConsumerId("abc:5:6");
+            ConsumerId another = new ConsumerId("abc:5:6");
             Assert.AreEqual("abc", another.ConnectionId, "extracting consumerId.ConnectionId");
             Assert.AreEqual(5, another.SessionId, "extracting consumerId.SessionId");
             Assert.AreEqual(6, another.Value, "extracting consumerId.Value");
@@ -53,10 +53,10 @@ namespace Apache.NMS.Stomp.Test
             mid.BrokerSequenceId = 5;
             mid.ProducerSequenceId = 6;
 
-            string text = StompHelper.ToStomp(mid);
+            string text = mid.ToString();
             Assert.AreEqual("cheese:2:3:6", text, "MessageId as stomp");
 
-            MessageId mid2 = StompHelper.ToMessageId("abc:5:6:7:8");
+            MessageId mid2 = new MessageId("abc:5:6:7:8");
             Assert.AreEqual(8, mid2.ProducerSequenceId, "extracting mid2.ProducerSequenceId");
 
             ProducerId another = mid2.ProducerId;

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj Tue May  4 15:52:22
2010
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="3.5">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -31,6 +31,7 @@
     <BootstrapperEnabled>true</BootstrapperEnabled>
     <SignAssembly>true</SignAssembly>
     <AssemblyOriginatorKeyFile>keyfile\NMSKey.snk</AssemblyOriginatorKeyFile>
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -52,14 +53,6 @@
     <DefineConstants>NET,NET_2_0</DefineConstants>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Apache.NMS, Version=1.3.0.1865, Culture=neutral, PublicKeyToken=82756feee3957618,
processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.dll</HintPath>
-    </Reference>
-    <Reference Include="Apache.NMS.Test, Version=1.3.0.1865, Culture=neutral, PublicKeyToken=82756feee3957618,
processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.Test.dll</HintPath>
-    </Reference>
     <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77,
processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>lib\NUnit\net-2.0\nunit.framework.dll</HintPath>
@@ -70,6 +63,14 @@
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Xml" />
+    <Reference Include="Apache.NMS, Version=1.3.0.1946, Culture=neutral, PublicKeyToken=82756feee3957618">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>build\mono-2.0\debug\Apache.NMS.dll</HintPath>
+    </Reference>
+    <Reference Include="Apache.NMS.Stomp, Version=1.3.0.1949, Culture=neutral, PublicKeyToken=82756feee3957618">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>build\mono-2.0\debug\Apache.NMS.Stomp.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
@@ -133,5 +134,7 @@
     <Compile Include="src\test\csharp\Commands\MapMessageTest.cs" />
     <Compile Include="src\test\csharp\Protocol\XmlPrimitiveMapMarshalerTest.cs" />
     <Compile Include="src\test\csharp\MapMessageTest.cs" />
+    <Compile Include="src\test\csharp\Commands\ConsumerIdTest.cs" />
+    <Compile Include="src\test\csharp\Commands\ProducerIdTest.cs" />
   </ItemGroup>
 </Project>
\ No newline at end of file

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj?rev=940919&r1=940918&r2=940919&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj Tue May  4 15:52:22
2010
@@ -53,12 +53,12 @@
     <DefineConstants>TRACE;NET,NET_2_0</DefineConstants>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Apache.NMS, Version=1.3.0.1865, Culture=neutral, PublicKeyToken=82756feee3957618,
processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.dll</HintPath>
-    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Xml" />
+    <Reference Include="Apache.NMS, Version=1.3.0.1893, Culture=neutral, PublicKeyToken=82756feee3957618">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>build\mono-2.0\debug\Apache.NMS.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">



Mime
View raw message