activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r508490 - in /activemq/activemq-dotnet/trunk/src: main/csharp/ActiveMQ/Commands/ main/csharp/ActiveMQ/Transport/Stomp/ test/csharp/ActiveMQ/ test/csharp/NMS/Test/ test/csharp/Stomp/
Date Fri, 16 Feb 2007 16:56:18 GMT
Author: jstrachan
Date: Fri Feb 16 08:56:17 2007
New Revision: 508490

URL: http://svn.apache.org/viewvc?view=rev&rev=508490
Log:
Almost got NMS-stomp working, just needs a little more tweaking to get all the test cases
running

Added:
    activemq/activemq-dotnet/trunk/src/test/csharp/ActiveMQ/NMSPropertyTest.cs
    activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/NMSPropertyTest.cs
Removed:
    activemq/activemq-dotnet/trunk/src/test/csharp/ActiveMQ/JMSPropertyTest.cs
    activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/JMSPropertyTest.cs
Modified:
    activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/ActiveMQDestination.cs
    activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompHelper.cs
    activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompWireFormat.cs
    activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSPropertyTest.cs
    activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs
    activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/StompHelperTest.cs

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/ActiveMQDestination.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/ActiveMQDestination.cs?view=diff&rev=508490&r1=508489&r2=508490
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/ActiveMQDestination.cs
(original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/ActiveMQDestination.cs
Fri Feb 16 08:56:17 2007
@@ -485,7 +485,19 @@
         
         public override String ToString()
         {
-            return this.physicalName;
+			switch (DestinationType) {
+				case DestinationType.Topic:
+					return "topic://" + PhysicalName;
+				
+				case DestinationType.TemporaryTopic:
+					return "temp-topic://" + PhysicalName;
+				
+				case DestinationType.TemporaryQueue:
+					return "temp-queue://" + PhysicalName;
+				
+				default:
+					return "queue://" + PhysicalName;
+			}
         }
         
         /**

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompHelper.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompHelper.cs?view=diff&rev=508490&r1=508489&r2=508490
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompHelper.cs
(original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompHelper.cs
Fri Feb 16 08:56:17 2007
@@ -43,14 +43,14 @@
 				text = text.Substring("/topic/".Length);
 				type = ActiveMQDestination.ACTIVEMQ_TOPIC;
 			}
-			else if (text.StartsWith("/temptopic/"))
+			else if (text.StartsWith("/temp-topic/"))
 			{
-				text = text.Substring("/temptopic/".Length);
+				text = text.Substring("/temp-topic/".Length);
 				type = ActiveMQDestination.ACTIVEMQ_TEMPORARY_TOPIC;
 			}
-			else if (text.StartsWith("/tempqueue/"))
+			else if (text.StartsWith("/temp-queue/"))
 			{
-				text = text.Substring("/tempqueue/".Length);
+				text = text.Substring("/temp-queue/".Length);
 				type = ActiveMQDestination.ACTIVEMQ_TEMPORARY_QUEUE;
 			}
 			return ActiveMQDestination.CreateDestination(type, text);
@@ -64,16 +64,16 @@
 			}
 			else 
 			{
-				switch (destination.GetDestinationType())
+				switch (destination.DestinationType)
 				{
-					case ActiveMQDestination.ACTIVEMQ_TOPIC:
+					case DestinationType.Topic:
 						return "/topic/" + destination.PhysicalName;
 					
-					case ActiveMQDestination.ACTIVEMQ_TEMPORARY_TOPIC:
-						return "/temptopic/" + destination.PhysicalName;
+					case DestinationType.TemporaryTopic:
+						return "/temp-topic/" + destination.PhysicalName;
 					
-					case ActiveMQDestination.ACTIVEMQ_TEMPORARY_QUEUE:
-						return "/tempqueue/" + destination.PhysicalName;
+					case DestinationType.TemporaryQueue:
+						return "/temp-queue/" + destination.PhysicalName;
 					
 					default:
 						return "/queue/" + destination.PhysicalName;
@@ -157,6 +157,18 @@
 			}
 			answer.ProducerId = ToProducerId(text);
 			return answer;
+		}
+		
+		public static bool ToBool(string text, bool defaultValue)
+		{
+			if (text == null)
+			{
+				return defaultValue;
+			}
+			else 
+			{
+				return "true" == text || "TRUE" == text;
+			}
 		}
     }
 }

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompWireFormat.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompWireFormat.cs?view=diff&rev=508490&r1=508489&r2=508490
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompWireFormat.cs
(original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompWireFormat.cs
Fri Feb 16 08:56:17 2007
@@ -57,15 +57,7 @@
 			{
 				WriteConnectionInfo((ConnectionInfo) o, ds);
 			}
-/*			else if (o is SessionInfo) 
-			{
-				SessionInfo info = (SessionInfo) o;
-				if (info.ResponseRequired) 
-				{
-					Console.WriteLine("Response required from Session!!");
-				}
-			}
-*/			else if (o is ActiveMQMessage)
+			else if (o is ActiveMQMessage)
 			{
 				WriteMessage((ActiveMQMessage) o, ds);
 			}
@@ -122,8 +114,6 @@
 					// lets ignore this bad header!
 				}
 			}
-			Console.Out.Flush();
-
 			byte[] content = null;
 			string length = ToString(headers["content-length"]);
 			if (length != null) 
@@ -142,9 +132,6 @@
 				string text = body.ToString().TrimEnd('\r', '\n');
 				content = encoding.GetBytes(text);
 			}
-			Console.WriteLine(">>>>> read content: " + content.Length);
-			Console.Out.Flush();
-			
 			Object answer = CreateCommand(command, headers, content);
 			Console.WriteLine(">>>>> received: " + answer);
 			Console.Out.Flush();
@@ -163,10 +150,6 @@
 				}
 				return answer; 
 			}
-			else if (command == "MESSAGE")
-			{
-				return ReadMessage(command, headers, content);
-			}
 			else if (command == "ERROR")
 			{
 				ExceptionResponse answer = new ExceptionResponse();
@@ -182,6 +165,10 @@
 				answer.Exception = error;
 				return answer; 
 			}
+			else if (command == "MESSAGE")
+			{
+				return ReadMessage(command, headers, content);
+			}
 			else
 			{
 				Console.WriteLine("Unknown command: " + command + " headers: " + headers);
@@ -202,12 +189,9 @@
 				message = new ActiveMQTextMessage(encoding.GetString(content));
 			}
 
-			Console.WriteLine("Content is: " + content.Length + " byte(s)");
-			
 			if (message is ActiveMQTextMessage)
 			{
 				ActiveMQTextMessage textMessage = message as ActiveMQTextMessage;
-				Console.WriteLine("Text is: " + textMessage.Text);
 			}
 			
 			// TODO now lets set the various headers
@@ -218,6 +202,7 @@
 			message.TargetConsumerId = StompHelper.ToConsumerId(RemoveHeader(headers, "subscription"));
 			message.CorrelationId = ToString(headers["correlation-id"]);
 			message.MessageId = StompHelper.ToMessageId(RemoveHeader(headers, "message-id"));
+			message.Persistent = StompHelper.ToBool(RemoveHeader(headers, "persistent"), true);
 			
 			string header = RemoveHeader(headers, "priority");
 			if (header != null) message.Priority = Byte.Parse(header);
@@ -230,6 +215,7 @@
 			
 			header = RemoveHeader(headers, "timestamp");
 			if (header != null) message.Timestamp = Int64.Parse(header);
+
 			
 			// now lets add the generic headers
 			foreach (string key in headers.Keys)
@@ -289,6 +275,7 @@
 			ss.WriteHeader("priority", command.Priority);
 			ss.WriteHeader("type", command.Type);
 			ss.WriteHeader("transaction", command.TransactionId);
+			ss.WriteHeader("persistent", command.Persistent);
 			
 			// lets force the content to be marshalled
 			
@@ -297,8 +284,6 @@
 			{
 				ActiveMQTextMessage textMessage = command as ActiveMQTextMessage;
 				ss.Content = encoding.GetBytes(textMessage.Text);
-				
-				Console.WriteLine("============ the text is : " + textMessage.Text + " which is: " +
ss.Content.Length + " bytes for: " + command);
 			}
 			else 
 			{

Added: activemq/activemq-dotnet/trunk/src/test/csharp/ActiveMQ/NMSPropertyTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/test/csharp/ActiveMQ/NMSPropertyTest.cs?view=auto&rev=508490
==============================================================================
--- activemq/activemq-dotnet/trunk/src/test/csharp/ActiveMQ/NMSPropertyTest.cs (added)
+++ activemq/activemq-dotnet/trunk/src/test/csharp/ActiveMQ/NMSPropertyTest.cs Fri Feb 16
08:56:17 2007
@@ -0,0 +1,37 @@
+/*
+ * 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 ActiveMQ;
+using ActiveMQ;
+using NMS;
+using NUnit.Framework;
+using System;
+
+namespace ActiveMQ
+{
+    [ TestFixture ]
+    public class NMSPropertyTest : NMS.Test.NMSPropertyTest
+    {
+        private String brokerURI = "tcp://localhost:61616";
+        protected override IConnectionFactory CreateConnectionFactory()
+        {
+            return new ConnectionFactory(new Uri(brokerURI));
+        }
+    }
+}
+
+
+

Modified: activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSPropertyTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSPropertyTest.cs?view=diff&rev=508490&r1=508489&r2=508490
==============================================================================
--- activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSPropertyTest.cs (original)
+++ activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSPropertyTest.cs Fri Feb 16
08:56:17 2007
@@ -25,14 +25,13 @@
     abstract public class NMSPropertyTest : NMSTestSupport
     {
         // standard NMS properties
-        string expectedText = "Hey this works!";
-        string correlationID = "abc";
-        ITemporaryQueue replyTo;
-        bool persistent = true;
-        byte priority = 5;
-        String type = "FooType";
-        String groupID = "MyGroup";
-        int groupSeq = 1;
+        protected string expectedText = "Hey this works!";
+        protected string correlationID = "abc";
+        protected ITemporaryQueue replyTo;
+        protected byte priority = 5;
+        protected String type = "FooType";
+        protected String groupID = "MyGroup";
+        protected int groupSeq = 1;
         
         // custom properties
         string customText = "Cheese";

Modified: activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs?view=diff&rev=508490&r1=508489&r2=508490
==============================================================================
--- activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs (original)
+++ activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs Fri Feb 16 08:56:17
2007
@@ -38,6 +38,7 @@
 
         protected int receiveTimeout = 1000;
         protected string clientId;
+        protected bool persistent = true;
         protected DestinationType destinationType = DestinationType.Queue;
         protected AcknowledgementMode acknowledgementMode = AcknowledgementMode.ClientAcknowledge;
 
@@ -146,6 +147,7 @@
 
                 IMessageConsumer consumer = session.CreateConsumer(Destination);
                 IMessageProducer producer = session.CreateProducer(Destination);
+				producer.Persistent = persistent;
 
                 IMessage request = CreateMessage();
                 producer.Send(request);

Added: activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/NMSPropertyTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/NMSPropertyTest.cs?view=auto&rev=508490
==============================================================================
--- activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/NMSPropertyTest.cs (added)
+++ activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/NMSPropertyTest.cs Fri Feb 16 08:56:17
2007
@@ -0,0 +1,37 @@
+/*
+ * 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 NMS;
+using NUnit.Framework;
+using Stomp;
+using System;
+
+namespace Stomp
+{
+    [ TestFixture ]
+    public class NMSPropertyTest : NMS.Test.NMSPropertyTest
+    {
+        protected override IConnectionFactory CreateConnectionFactory()
+        {
+			Console.WriteLine("##### using the NMS STOMP client!");
+			
+            return new ConnectionFactory();
+        }
+    }
+}
+
+
+

Modified: activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/StompHelperTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/StompHelperTest.cs?view=diff&rev=508490&r1=508489&r2=508490
==============================================================================
--- activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/StompHelperTest.cs (original)
+++ activemq/activemq-dotnet/trunk/src/test/csharp/Stomp/StompHelperTest.cs Fri Feb 16 08:56:17
2007
@@ -69,6 +69,20 @@
 		}
 
 		// TODO destination stuff
+		
+		[ Test ]
+		public void DestinationMarshallingWorks()
+		{
+			Assert.AreEqual("/queue/FOO.BAR", StompHelper.ToStomp(new ActiveMQQueue("FOO.BAR")), "queue");
+			Assert.AreEqual("/topic/FOO.BAR", StompHelper.ToStomp(new ActiveMQTopic("FOO.BAR")), "topic");
+			Assert.AreEqual("/temp-queue/FOO.BAR", StompHelper.ToStomp(new ActiveMQTempQueue("FOO.BAR")),
"temporary queue");
+			Assert.AreEqual("/temp-topic/FOO.BAR", StompHelper.ToStomp(new ActiveMQTempTopic("FOO.BAR")),
"temporary topic");
+			
+			Assert.AreEqual(new ActiveMQQueue("FOO.BAR"), StompHelper.ToDestination("/queue/FOO.BAR"),
"queue from Stomp");
+			Assert.AreEqual(new ActiveMQTopic("FOO.BAR"), StompHelper.ToDestination("/topic/FOO.BAR"),
"topic from Stomp");
+			Assert.AreEqual(new ActiveMQTempQueue("FOO.BAR"), StompHelper.ToDestination("/temp-queue/FOO.BAR"),
"temporary queue from Stomp");
+			Assert.AreEqual(new ActiveMQTempTopic("FOO.BAR"), StompHelper.ToDestination("/temp-topic/FOO.BAR"),
"temporary topic from Stomp");
+		}
     }
 }
 



Mime
View raw message