activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r683452 - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/ Apache.NMS/trunk/src/main/csharp/ Apache.NMS/trunk/src/main/csharp/Util/ Apache.NMS/trunk/src/test/csharp/
Date Thu, 07 Aug 2008 00:22:23 GMT
Author: jgomes
Date: Wed Aug  6 17:22:22 2008
New Revision: 683452

URL: http://svn.apache.org/viewvc?rev=683452&view=rev
Log:
All unit tests pass, except for one which appears to be a bug in the broker.  Further investigation will be necessary.
Refactoring of the unit tests continues.  Several functions have been marked with the [Obsolete] attribute, which will cause compiler warnings until those unit tests are refactored.
Refactored the IMessage base interface to remove the setters for NMSPersistent and NMSPriority, since these can not be set directly on a message.  They are set on the MessageProducer.
Fixes [AMQNET-92]. (See https://issues.apache.org/activemq/browse/AMQNET-92)

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BooleanStreamTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/SessionUtils.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BadConsumeTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TemporaryQueueTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BooleanStreamTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BooleanStreamTest.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BooleanStreamTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BooleanStreamTest.cs Wed Aug  6 17:22:22 2008
@@ -14,118 +14,119 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-using NUnit.Framework;
+
 using System;
 using System.IO;
 using Apache.NMS.ActiveMQ.OpenWire;
+using NUnit.Framework;
 
 namespace Apache.NMS.ActiveMQ.Test.OpenWire
 {
-        [ TestFixture ]
-        public class BooleanStreamTest
-        {
-                protected int endOfStreamMarker = 0x12345678;
-                int numberOfBytes = 8 * 200;
-
-                public delegate bool GetBooleanValueDelegate(int index, int count);
-
-                [ Test ]
-                public void TestBooleanMarshallingUsingAllTrue()
-                {
-                        DoTestBooleanStream(numberOfBytes, new GetBooleanValueDelegate(GetBooleanValueAllTrue));
-                }
-                public bool GetBooleanValueAllTrue(int index, int count)
-                {
-                        return true;
-                }
-
-                [ Test ]
-                public void TestBooleanMarshallingUsingAllFalse()
-                {
-                        DoTestBooleanStream(numberOfBytes, new GetBooleanValueDelegate(GetBooleanValueAllFalse));
-                }
-                public bool GetBooleanValueAllFalse(int index, int count)
-                {
-                        return false;
-                }
-
-                [ Test ]
-                public void TestBooleanMarshallingUsingAlternateTrueFalse()
-                {
-                        DoTestBooleanStream(
-                                numberOfBytes, new GetBooleanValueDelegate(GetBooleanValueAlternateTrueFalse));
-                }
-                public bool GetBooleanValueAlternateTrueFalse(int index, int count)
-                {
-                        return (index & 1) == 0;
-                }
-
-                [ Test ]
-                public void TestBooleanMarshallingUsingAlternateFalseTrue()
-                {
-                        DoTestBooleanStream(
-                                numberOfBytes, new GetBooleanValueDelegate(GetBooleanValueAlternateFalseTrue));
-                }
-                public bool GetBooleanValueAlternateFalseTrue(int index, int count)
-                {
-                        return (index & 1) != 0;
-                }
-
-                protected void DoTestBooleanStream(int numberOfBytes, GetBooleanValueDelegate valueDelegate)
-                {
-                        for (int i = 1017; i < numberOfBytes; i++)
-                        {
-                                AssertMarshalBooleans(i, valueDelegate);
-                        }
-                }
-
-                protected void AssertMarshalBooleans(int count, GetBooleanValueDelegate valueDelegate)
-                {
-                        BooleanStream bs = new BooleanStream();
-                        for (int i = 0; i < count; i++)
-                        {
-                                bs.WriteBoolean(valueDelegate(i, count));
-                        }
-                        MemoryStream buffer = new MemoryStream();
-                        BinaryWriter ds = new OpenWireBinaryWriter(buffer);
-                        bs.Marshal(ds);
-                        ds.Write(endOfStreamMarker);
-
-                        // now lets read from the stream
-
-                        MemoryStream ins = new MemoryStream(buffer.ToArray());
-                        BinaryReader dis = new OpenWireBinaryReader(ins);
-                        bs = new BooleanStream();
-                        bs.Unmarshal(dis);
-
-                        for (int i = 0; i < count; i++)
-                        {
-                                bool expected = valueDelegate(i, count);
-
-                                try
-                                {
-                                        bool actual = bs.ReadBoolean();
-                                        Assert.AreEqual(expected, actual);
-                                }
-                                catch (Exception e)
-                                {
-                                        Assert.Fail(
-                                                "Failed to parse bool: " + i + " out of: " + count + " due to: " + e);
-                                }
-                        }
-                        int marker = dis.ReadInt32();
-                        Assert.AreEqual(
-                                endOfStreamMarker, marker, "did not match: " + endOfStreamMarker + " and " + marker);
-
-                        // lets try read and we should get an exception
-                        try
-                        {
-                                dis.ReadByte();
-                                Assert.Fail("Should have reached the end of the stream");
-                        }
-                        catch (IOException)
-                        {
-                        }
-                }
-        }
+	[TestFixture]
+	public class BooleanStreamTest
+	{
+		protected int endOfStreamMarker = 0x12345678;
+		int numberOfBytes = 8 * 200;
+
+		public delegate bool GetBooleanValueDelegate(int index, int count);
+
+		[Test]
+		public void TestBooleanMarshallingUsingAllTrue()
+		{
+			DoTestBooleanStream(numberOfBytes, new GetBooleanValueDelegate(GetBooleanValueAllTrue));
+		}
+		public bool GetBooleanValueAllTrue(int index, int count)
+		{
+			return true;
+		}
+
+		[Test]
+		public void TestBooleanMarshallingUsingAllFalse()
+		{
+			DoTestBooleanStream(numberOfBytes, new GetBooleanValueDelegate(GetBooleanValueAllFalse));
+		}
+		public bool GetBooleanValueAllFalse(int index, int count)
+		{
+			return false;
+		}
+
+		[Test]
+		public void TestBooleanMarshallingUsingAlternateTrueFalse()
+		{
+			DoTestBooleanStream(
+					numberOfBytes, new GetBooleanValueDelegate(GetBooleanValueAlternateTrueFalse));
+		}
+		public bool GetBooleanValueAlternateTrueFalse(int index, int count)
+		{
+			return (index & 1) == 0;
+		}
+
+		[Test]
+		public void TestBooleanMarshallingUsingAlternateFalseTrue()
+		{
+			DoTestBooleanStream(
+					numberOfBytes, new GetBooleanValueDelegate(GetBooleanValueAlternateFalseTrue));
+		}
+		public bool GetBooleanValueAlternateFalseTrue(int index, int count)
+		{
+			return (index & 1) != 0;
+		}
+
+		protected void DoTestBooleanStream(int numberOfBytes, GetBooleanValueDelegate valueDelegate)
+		{
+			for(int i = 1017; i < numberOfBytes; i++)
+			{
+				AssertMarshalBooleans(i, valueDelegate);
+			}
+		}
+
+		protected void AssertMarshalBooleans(int count, GetBooleanValueDelegate valueDelegate)
+		{
+			BooleanStream bs = new BooleanStream();
+			for(int i = 0; i < count; i++)
+			{
+				bs.WriteBoolean(valueDelegate(i, count));
+			}
+			MemoryStream buffer = new MemoryStream();
+			BinaryWriter ds = new OpenWireBinaryWriter(buffer);
+			bs.Marshal(ds);
+			ds.Write(endOfStreamMarker);
+
+			// now lets read from the stream
+
+			MemoryStream ins = new MemoryStream(buffer.ToArray());
+			BinaryReader dis = new OpenWireBinaryReader(ins);
+			bs = new BooleanStream();
+			bs.Unmarshal(dis);
+
+			for(int i = 0; i < count; i++)
+			{
+				bool expected = valueDelegate(i, count);
+
+				try
+				{
+					bool actual = bs.ReadBoolean();
+					Assert.AreEqual(expected, actual);
+				}
+				catch(Exception e)
+				{
+					Assert.Fail(
+							"Failed to parse bool: " + i + " out of: " + count + " due to: " + e);
+				}
+			}
+			int marker = dis.ReadInt32();
+			Assert.AreEqual(
+					endOfStreamMarker, marker, "did not match: " + endOfStreamMarker + " and " + marker);
+
+			// lets try read and we should get an exception
+			try
+			{
+				dis.ReadByte();
+				Assert.Fail("Should have reached the end of the stream");
+			}
+			catch(IOException)
+			{
+			}
+		}
+	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs Wed Aug  6 17:22:22 2008
@@ -40,7 +40,7 @@
 		string NMSCorrelationID { get; set; }
 		
 		/// <summary>
-		/// The destination of the message.
+		/// The destination of the message.  This property is set by the IMessageProducer.
 		/// </summary>
 		IDestination NMSDestination { get; }
 		
@@ -55,14 +55,14 @@
 		string NMSMessageId { get; }
 		
 		/// <summary>
-		/// Whether or not this message is persistent.
+		/// Whether or not this message is persistent.  This property is set by the IMessageProducer.
 		/// </summary>
-		bool NMSPersistent { get; set; }
+		bool NMSPersistent { get; }
 		
 		/// <summary>
-		/// The Priority of this message.
+		/// The Priority of this message.  This property is set by the IMessageProducer.
 		/// </summary>
-		byte NMSPriority { get; set; }
+		byte NMSPriority { get; }
 		
 		/// <summary>
 		/// Returns true if this message has been redelivered to this or another consumer before being acknowledged successfully.

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/SessionUtils.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/SessionUtils.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/SessionUtils.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/SessionUtils.cs Wed Aug  6 17:22:22 2008
@@ -42,9 +42,9 @@
 		///		</list>
 		///	</param>
 		/// <returns></returns>
-		public static IDestination GetDestinationByType(ISession session, string destinationName)
+		public static IDestination GetDestination(ISession session, string destinationName)
 		{
-			return SessionUtil.GetDestinationByType(session, destinationName, DestinationType.Queue);
+			return SessionUtil.GetDestination(session, destinationName, DestinationType.Queue);
 		}
 
 		/// <summary>
@@ -61,7 +61,7 @@
 		///	</param>
 		/// <param name="defaultType">Default type if no embedded prefix is specified.</param>
 		/// <returns></returns>
-		public static IDestination GetDestinationByType(ISession session, string destinationName, DestinationType defaultType)
+		public static IDestination GetDestination(ISession session, string destinationName, DestinationType defaultType)
 		{
 			IDestination destination = null;
 			DestinationType destinationType = defaultType;
@@ -111,12 +111,12 @@
 
 		public static IQueue GetQueue(ISession session, string queueName)
 		{
-			return GetDestinationByType(session, queueName, DestinationType.Queue) as IQueue;
+			return GetDestination(session, queueName, DestinationType.Queue) as IQueue;
 		}
 
 		public static ITopic GetTopic(ISession session, string topicName)
 		{
-			return GetDestinationByType(session, topicName, DestinationType.Topic) as ITopic;
+			return GetDestination(session, topicName, DestinationType.Topic) as ITopic;
 		}
 	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BadConsumeTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BadConsumeTest.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BadConsumeTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BadConsumeTest.cs Wed Aug  6 17:22:22 2008
@@ -19,35 +19,47 @@
 
 namespace Apache.NMS.Test
 {
-    [TestFixture]
-    public abstract class BadConsumeTest : NMSTestSupport
-    {
-        [SetUp]
-        public override void SetUp()
-        {
-            base.SetUp();
-        }
-
-        [TearDown]
-        public override void TearDown()
-        {
-            base.TearDown();
-        }
-
-        [Test]
-        public void TestBadConsumeOperationToTestExceptions()
-        {
-            try
-            {
-                IMessageConsumer consumer = Session.CreateConsumer(null);
-                Console.WriteLine("Created consumer: " + consumer);
-                Assert.Fail("Should  have thrown an exception!");
-            }
-            catch (Exception e)
-            {
-                Console.WriteLine("Caught expected exception: " + e);
-                Console.WriteLine("Stack: " + e.StackTrace);
-            }
-        }
-    }
-}
\ No newline at end of file
+	[TestFixture]
+	public abstract class BadConsumeTest : NMSTestSupport
+	{
+		protected static string TEST_CLIENT_ID = "BadConsumeTestClientId";
+		protected IConnection connection;
+		protected ISession session;
+
+		[SetUp]
+		public override void SetUp()
+		{
+			connection = CreateConnection(TEST_CLIENT_ID);
+			connection.Start();
+			session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+		}
+
+		[TearDown]
+		public override void TearDown()
+		{
+			if(null != session)
+			{
+				session.Dispose();
+				session = null;
+			}
+
+			if(null != connection)
+			{
+				connection.Dispose();
+				connection = null;
+			}
+		}
+
+		[Test]
+		[ExpectedException(Handler="ExceptionValidationCheck")]
+		public void TestBadConsumerException()
+		{
+			IMessageConsumer consumer = session.CreateConsumer(null);
+		}
+
+		public void ExceptionValidationCheck(Exception ex)
+		{
+			Assert.IsNotNull(ex as NMSException, "Invalid exception was thrown.");
+		}
+	}
+}

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs Wed Aug  6 17:22:22 2008
@@ -21,27 +21,27 @@
 
 namespace Apache.NMS.Test
 {
-    [TestFixture]
-    public abstract class ConsumerTest : NMSTestSupport
-    {
-		private static string TEST_CLIENT_ID = "ConsumerTestClientId";
-		private static string TOPIC = "TestTopicConsumerTest";
-		private static string CONSUMER_ID = "ConsumerTestConsumerId";
-
-        [Test]
-        public void TestDurableConsumerSelectorChangePersistent()
-        {
-            doTestDurableConsumerSelectorChange(true);
-        }
-
-        [Test]
-        public void TestDurableConsumerSelectorChangeNonPersistent()
-        {
-            doTestDurableConsumerSelectorChange(false);
-        }
+	[TestFixture]
+	public abstract class ConsumerTest : NMSTestSupport
+	{
+		protected static string TEST_CLIENT_ID = "ConsumerTestClientId";
+		protected static string TOPIC = "TestTopicConsumerTest";
+		protected static string CONSUMER_ID = "ConsumerTestConsumerId";
 
-        public void doTestDurableConsumerSelectorChange(bool persistent)
-        {
+		[Test]
+		public void TestDurableConsumerSelectorChange()
+		{
+			doTestDurableConsumerSelectorChange(false);
+		}
+
+		[Test]
+		public void TestDurableConsumerSelectorChangePersistent()
+		{
+			doTestDurableConsumerSelectorChange(true);
+		}
+
+		public void doTestDurableConsumerSelectorChange(bool persistent)
+		{
 			try
 			{
 				using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
@@ -63,7 +63,7 @@
 						ITextMessage receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage;
 						Assert.IsNotNull(receiveMsg, "Failed to retrieve 1st durable message.");
 						Assert.AreEqual("1st", receiveMsg.Text);
-						Assert.IsTrue(receiveMsg.NMSPersistent == persistent, "message does not match persistent setting.");
+						Assert.AreEqual(persistent, receiveMsg.NMSPersistent, "NMSPersistent does not match");
 
 						// Change the subscription.
 						consumer.Dispose();
@@ -80,23 +80,26 @@
 						receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage;
 						Assert.IsNotNull(receiveMsg, "Failed to retrieve durable message.");
 						Assert.AreEqual("3rd", receiveMsg.Text, "Retrieved the wrong durable message.");
-						Assert.IsTrue(receiveMsg.NMSPersistent == persistent, "message does not match persistent setting.");
+						Assert.AreEqual(persistent, receiveMsg.NMSPersistent, "NMSPersistent does not match");
 
 						// Make sure there are no pending messages.
 						Assert.IsNull(consumer.ReceiveNoWait(), "Wrong number of messages in durable subscription.");
 					}
 				}
 			}
+			catch(Exception ex)
+			{
+				Assert.Fail(ex.Message);
+			}
 			finally
 			{
 				UnregisterDurableConsumer(TEST_CLIENT_ID, CONSUMER_ID);
 			}
-        }
+		}
 
 		[Test]
 		public void TestNoTimeoutConsumer()
 		{
-			destinationType = DestinationType.Queue;
 			// Launch a thread to perform IMessageConsumer.Receive().
 			// If it doesn't fail in less than three seconds, no exception was thrown.
 			Thread receiveThread = new Thread(new ThreadStart(TimeoutConsumerThreadProc));
@@ -146,5 +149,5 @@
 				Assert.Fail("Test failed with exception: " + e.Message);
 			}
 		}
-    }
-}
\ No newline at end of file
+	}
+}

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs Wed Aug  6 17:22:22 2008
@@ -23,11 +23,11 @@
 	[TestFixture]
 	public abstract class DurableTest : NMSTestSupport
 	{
-		private static string TOPIC = "TestTopicDurableConsumer";
-		private static string SEND_CLIENT_ID = "SendDurableTestClientId";
-		private static string TEST_CLIENT_ID = "DurableTestClientId";
-		private static string CONSUMER_ID = "DurableTestConsumerId";
-		private static string DURABLE_SELECTOR = "2 > 1";
+		protected static string TOPIC = "TestTopicDurableConsumer";
+		protected static string SEND_CLIENT_ID = "SendDurableTestClientId";
+		protected static string TEST_CLIENT_ID = "DurableTestClientId";
+		protected static string CONSUMER_ID = "DurableTestConsumerId";
+		protected static string DURABLE_SELECTOR = "2 > 1";
 
 		protected void SendPersistentMessage()
 		{
@@ -37,11 +37,12 @@
 				using(ISession session = connection.CreateSession(AcknowledgementMode.DupsOkAcknowledge))
 				{
 					ITopic topic = SessionUtil.GetTopic(session, TOPIC);
-					ITextMessage message = session.CreateTextMessage("Persistent Hello");
-					using(IMessageProducer producer = session.CreateProducer(topic))
+					using(IMessageProducer producer = session.CreateProducer(topic, receiveTimeout))
 					{
+						ITextMessage message = session.CreateTextMessage("Persistent Hello");
+
 						producer.Persistent = true;
-						producer.RequestTimeout = TimeSpan.FromSeconds(5);
+						producer.RequestTimeout = receiveTimeout;
 						producer.Send(message);
 					}
 				}

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs Wed Aug  6 17:22:22 2008
@@ -14,110 +14,114 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-using Apache.NMS;
-using NUnit.Framework;
-using System;
 
+using System;
+using NUnit.Framework;
+using Apache.NMS.Util;
 
 namespace Apache.NMS.Test
 {
-	[ TestFixture ]
+	[TestFixture]
 	abstract public class MessageTest : NMSTestSupport
 	{
-	    
-		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);
-        }
-		
+		protected static string DESTINATION_NAME = "MessagePropsDestination";
+		protected static string TEST_CLIENT_ID = "MessagePropsClientId";
+
+		protected bool		a = true;
+		protected byte		b = 123;
+		protected char		c = 'c';
+		protected short		d = 0x1234;
+		protected int		e = 0x12345678;
+		protected long		f = 0x1234567812345678;
+		protected string	g = "Hello World!";
+		protected bool		h = false;
+		protected byte		i = 0xFF;
+		protected short		j = -0x1234;
+		protected int		k = -0x12345678;
+		protected long		l = -0x1234567812345678;
+
+		[Test]
+		public void SendReceiveMessageProperties()
+		{
+			doSendReceiveMessageProperties(false);
+		}
+
+		[Test]
+		public void SendReceiveMessagePropertiesPersistent()
+		{
+			doSendReceiveMessageProperties(true);
+		}
+
+		protected void doSendReceiveMessageProperties(bool persistent)
+		{
+			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			{
+				connection.Start();
+				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+				{
+					IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME);
+					using(IMessageConsumer consumer = session.CreateConsumer(destination, receiveTimeout))
+					using(IMessageProducer producer = session.CreateProducer(destination, receiveTimeout))
+					{
+						producer.Persistent = persistent;
+						producer.RequestTimeout = receiveTimeout;
+						IMessage request = session.CreateMessage();
+						request.Properties["a"] = a;
+						request.Properties["b"] = b;
+						request.Properties["c"] = c;
+						request.Properties["d"] = d;
+						request.Properties["e"] = e;
+						request.Properties["f"] = f;
+						request.Properties["g"] = g;
+						request.Properties["h"] = h;
+						request.Properties["i"] = i;
+						request.Properties["j"] = j;
+						request.Properties["k"] = k;
+						request.Properties["l"] = l;
+						producer.Send(request);
+
+						IMessage message = consumer.Receive(receiveTimeout);
+						Assert.IsNotNull(message, "No message returned!");
+						Assert.AreEqual(12, message.Properties.Count, "Invalid number of properties.");
+						Assert.AreEqual(persistent, message.NMSPersistent, "NMSPersistent does not match");
+						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 static string ToHex(long value)
+		{
+			return String.Format("{0:x}", value);
+		}
 	}
 }
 

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs Wed Aug  6 17:22:22 2008
@@ -14,152 +14,81 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-//using Apache.ActiveMQ;
-using Apache.NMS;
-using NUnit.Framework;
+
 using System;
+using Apache.NMS.Util;
+using NUnit.Framework;
 
 namespace Apache.NMS.Test
 {
-    [ TestFixture ]
-    abstract public class NMSPropertyTest : NMSTestSupport
-    {
-        // standard NMS properties
-        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";
-        bool custom1 = true;
-        byte custom2 = 12;
-        short custom3 = 0x1234;
-        int custom4 = 0x12345678;
-        long custom5 = 0x1234567812345678;
-        char custom6 = 'J';
-		float custom7 = 2.1F;
-		double custom8 = 2.3;
-        
-        [SetUp]
-        override public void SetUp()
-        {
-            base.SetUp();
-        }
-        
-        [TearDown]
-        override public void TearDown()
-        {
-            base.TearDown();
-        }
-        
-        [ Test ]
-        public override void SendAndSyncReceive()
-        {
-            base.Drain();
-            base.SendAndSyncReceive();
-        }
-        
-        protected override IMessage CreateMessage()
-        {
-            ITextMessage message = Session.CreateTextMessage(expectedText);
-            replyTo = Session.CreateTemporaryQueue();
-            
-            // lets set the headers
-            message.NMSCorrelationID = correlationID;
-            message.NMSReplyTo = replyTo;
-            message.NMSPersistent = persistent;
-            message.NMSPriority = priority;
-            message.NMSType = type;
-            message.Properties["NMSXGroupID"] = groupID;
-            message.Properties["NMSXGroupSeq"] = groupSeq;
-            
-            // lets set the custom headers
-            message.Properties["customText"] = customText;
-            message.Properties["custom1"] = custom1;
-            message.Properties["custom2"] = custom2;
-            message.Properties["custom3"] = custom3;
-            message.Properties["custom4"] = custom4;
-            message.Properties["custom5"] = custom5;
-            message.Properties["custom6"] = custom6;
-            message.Properties["custom7"] = custom7;
-            message.Properties["custom8"] = custom8;
-            
-            return message;
-        }
-        
-        protected override void AssertValidMessage(IMessage message)
-        {
-            Assert.IsTrue(message is ITextMessage, "Did not receive a ITextMessage!");
-            
-            Console.WriteLine("Received Message: " + message);
-            
-            ITextMessage textMessage = (ITextMessage) message;
-            String text = textMessage.Text;
-            Assert.AreEqual(expectedText, text, "the message text");
-            
-            // compare standard NMS headers
-            Assert.AreEqual(correlationID, message.NMSCorrelationID, "NMSCorrelationID");
-            Assert.AreEqual(persistent, message.NMSPersistent, "NMSPersistent");
-            Assert.AreEqual(priority, message.NMSPriority, "NMSPriority");
-            Assert.AreEqual(type, message.NMSType, "NMSType");
-            Assert.AreEqual(groupID, message.Properties["NMSXGroupID"], "NMSXGroupID");
-            Assert.AreEqual(groupSeq, message.Properties["NMSXGroupSeq"], "NMSXGroupSeq");
-            
-            // compare custom headers
-            Assert.AreEqual(customText, message.Properties["customText"], "customText");
-			
-            AssertReplyToValid(message);
-			
-            AssertNonStringProperties(message);
-            
-            // lets now look at some standard NMS headers
-            Console.WriteLine("NMSTimeToLive: " + message.NMSTimeToLive);
-            Console.WriteLine("NMSMessageId: " + message.NMSMessageId);
-            Console.WriteLine("NMSRedelivered: " + message.NMSRedelivered);
-            Console.WriteLine("NMSTimestamp: " + message.NMSTimestamp);
-            Console.WriteLine("NMSXDeliveryCount: " + message.Properties["NMSXDeliveryCount"]);
-            Console.WriteLine("NMSXProducerTXID: " + message.Properties["NMSXProducerTXID"]);
-        }
+	[TestFixture]
+	abstract public class NMSPropertyTest : NMSTestSupport
+	{
+		protected static string DESTINATION_NAME = "NMSPropsDestination";
+		protected static string TEST_CLIENT_ID = "NMSPropsClientId";
+
+		// standard NMS properties
+		protected string	expectedText = "Hey this works!";
+		protected string	correlationID = "FooBar";
+		protected byte		priority = 4;
+		protected String	type = "FooType";
+		protected String	groupID = "BarGroup";
+		protected int		groupSeq = 1;
 
-		protected virtual void AssertReplyToValid(IMessage message)
+		[Test]
+		public void SendReceiveNMSProperties()
 		{
-			Assert.AreEqual(replyTo, message.NMSReplyTo, "NMSReplyTo");
+			doSendReceiveNMSProperties(false);
 		}
 
-		protected virtual void AssertNonStringProperties(IMessage message)
+		[Test]
+		public void SendReceiveNMSPropertiesPersistent()
 		{
-			Assert.AreEqual(custom1, message.Properties["custom1"], "custom1");
-            Assert.AreEqual(custom2, message.Properties["custom2"], "custom2");
-            Assert.AreEqual(custom3, message.Properties["custom3"], "custom3");
-            Assert.AreEqual(custom4, message.Properties["custom4"], "custom4");
-			
-            Assert.AreEqual(custom5, message.Properties["custom5"], "custom5");
-            Object value6 = message.Properties["custom6"];
-            Object expected6 = custom6;
-            Console.WriteLine("actual type is: " + value6.GetType() + " value: " + value6);
-            Console.WriteLine("expected type is: " + expected6.GetType() + " value: " + expected6);
-            Assert.AreEqual(custom6, value6, "custom6 which is of type: " + value6.GetType());
-			
-            Assert.AreEqual(custom6, message.Properties["custom6"], "custom6");
-            Assert.AreEqual(custom7, message.Properties["custom7"], "custom7");
-			Assert.AreEqual(custom8, message.Properties["custom8"], "custom8");
-			
-			// compare generic headers
-            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(custom6, message.Properties.GetChar("custom6"), "custom6");
-            Assert.AreEqual(custom7, message.Properties.GetFloat("custom7"), "custom7");
-			Assert.AreEqual(custom8, message.Properties.GetDouble("custom8"), "custom8");
+			doSendReceiveNMSProperties(true);
 		}
-    }
-}
-
-
 
+		protected void doSendReceiveNMSProperties(bool persistent)
+		{
+			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			{
+				connection.Start();
+				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+				{
+					IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME);
+					using(IMessageConsumer consumer = session.CreateConsumer(destination, receiveTimeout))
+					using(IMessageProducer producer = session.CreateProducer(destination, receiveTimeout))
+					{
+						producer.Priority = priority;
+						producer.Persistent = persistent;
+						producer.RequestTimeout = receiveTimeout;
+						ITextMessage request = session.CreateTextMessage(expectedText);
+						ITemporaryQueue	replyTo = session.CreateTemporaryQueue();
+
+						// Set the headers
+						request.NMSCorrelationID = correlationID;
+						request.NMSReplyTo = replyTo;
+						request.NMSType = type;
+						request.Properties["NMSXGroupID"] = groupID;
+						request.Properties["NMSXGroupSeq"] = groupSeq;
+
+						producer.Send(request);
+
+						ITextMessage message = consumer.Receive(receiveTimeout) as ITextMessage;
+
+						Assert.IsNotNull(message, "Did not receive an ITextMessage!");
+						Assert.AreEqual(expectedText, message.Text, "Message text does not match.");
+
+						// compare standard NMS headers
+						Assert.AreEqual(correlationID, message.NMSCorrelationID, "NMSCorrelationID does not match");
+						Assert.AreEqual(persistent, message.NMSPersistent, "NMSPersistent does not match");
+						Assert.AreEqual(priority, message.NMSPriority, "NMSPriority does not match");
+						Assert.AreEqual(type, message.NMSType, "NMSType does not match");
+						Assert.AreEqual(groupID, message.Properties["NMSXGroupID"], "NMSXGroupID does not match");
+						Assert.AreEqual(groupSeq, message.Properties["NMSXGroupSeq"], "NMSXGroupSeq does not match");
+						Assert.AreEqual(replyTo, message.NMSReplyTo, "NMSReplyTo does not match");
+					}
+				}
+			}
+		}
+	}
+}

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs Wed Aug  6 17:22:22 2008
@@ -30,23 +30,28 @@
 	[TestFixture]
 	public abstract class NMSTestSupport
 	{
+		[Obsolete]
 		protected static object destinationLock = new object();
+		[Obsolete]
 		protected static int destinationCounter;
 
-		// enable/disable logging of message flows
-		protected bool logging = true;
-
 		private NMSConnectionFactory NMSFactory;
+		[Obsolete]
 		private IConnection connection;
+		[Obsolete]
 		private ISession session;
+		[Obsolete]
 		private IDestination destination;
 
 		protected TimeSpan receiveTimeout = TimeSpan.FromMilliseconds(5000);
 		protected virtual string clientId { get; set; }
 		protected virtual string passWord { get; set; }
 		protected virtual string userName { get; set; }
+		[Obsolete]
 		protected bool persistent = true;
+		[Obsolete]
 		protected DestinationType destinationType = DestinationType.Queue;
+		[Obsolete]
 		protected AcknowledgementMode acknowledgementMode = AcknowledgementMode.ClientAcknowledge;
 
 		public NMSTestSupport()
@@ -66,6 +71,7 @@
 		}
 
 		// Properties
+		[Obsolete]
 		public bool Connected
 		{
 			get { return connection != null; }
@@ -85,6 +91,9 @@
 			}
 		}
 
+		/// <summary>
+		/// The connection factory interface property.
+		/// </summary>
 		public IConnectionFactory Factory
 		{
 			get
@@ -98,6 +107,7 @@
 			}
 		}
 
+		[Obsolete]
 		public IConnection Connection
 		{
 			get
@@ -111,6 +121,7 @@
 			}
 		}
 
+		[Obsolete]
 		public ISession Session
 		{
 			get
@@ -125,15 +136,17 @@
 			}
 		}
 
+		[Obsolete]
 		protected virtual void Connect()
 		{
-			WriteLine("Connecting...");
+			Console.WriteLine("Connecting...");
 			connection = CreateConnection(this.clientId);
 			Assert.IsNotNull(connection, "no connection created");
 			connection.Start();
-			WriteLine("Connected.");
+			Console.WriteLine("Connected.");
 		}
 
+		[Obsolete]
 		protected virtual void Disconnect()
 		{
 			destination = null;
@@ -145,19 +158,14 @@
 
 			if(connection != null)
 			{
-				WriteLine("Disconnecting...");
+				Console.WriteLine("Disconnecting...");
 				connection.Dispose();
 				connection = null;
-				WriteLine("Disconnected.");
+				Console.WriteLine("Disconnected.");
 			}
 		}
 
-		protected virtual void Reconnect()
-		{
-			Disconnect();
-			Connect();
-		}
-
+		[Obsolete]
 		protected virtual void Drain()
 		{
 			using(ISession drainSession = Connection.CreateSession())
@@ -173,6 +181,7 @@
 			}
 		}
 
+		[Obsolete]
 		public virtual void SendAndSyncReceive()
 		{
 			// IDestination sendDestination = CreateDestination(Session);
@@ -189,15 +198,33 @@
 			AssertValidMessage(message);
 		}
 
+		/// <summary>
+		/// Name of the connection configuration filename.
+		/// </summary>
+		/// <returns></returns>
 		protected virtual string GetConnectionConfigFileName() { return "nmsprovider-test.config"; }
 
+		/// <summary>
+		/// The name of the connection configuration that CreateNMSFactory() will load.
+		/// </summary>
+		/// <returns></returns>
 		protected virtual string GetNameTestURI() { return "defaultURI"; }
 
+		/// <summary>
+		/// Create the NMS Factory that can create NMS Connections.
+		/// </summary>
+		/// <returns></returns>
 		protected bool CreateNMSFactory()
 		{
 			return CreateNMSFactory(GetNameTestURI());
 		}
 
+		/// <summary>
+		/// Create the NMS Factory that can create NMS Connections.  This function loads the
+		/// connection settings from the configuration file.
+		/// </summary>
+		/// <param name="nameTestURI">The named connection configuration.</param>
+		/// <returns></returns>
 		protected bool CreateNMSFactory(string nameTestURI)
 		{
 			Uri brokerUri = null;
@@ -250,6 +277,11 @@
 			return (null != NMSFactory);
 		}
 
+		/// <summary>
+		/// Get the parameters for the ConnectionFactory from the configuration file.
+		/// </summary>
+		/// <param name="uriNode">Parent node of the factoryParams node.</param>
+		/// <returns>Object array of parameter objects to be passsed to provider factory object.  Null if no parameters are specified in configuration file.</returns>
 		protected object[] GetFactoryParams(XmlElement uriNode)
 		{
 			ArrayList factoryParams = new ArrayList();
@@ -290,6 +322,11 @@
 			return null;
 		}
 
+		/// <summary>
+		/// Create a new connection to the broker.
+		/// </summary>
+		/// <param name="newClientId">Client ID of the new connection.</param>
+		/// <returns></returns>
 		public virtual IConnection CreateConnection(string newClientId)
 		{
 			IConnection newConnection = Factory.CreateConnection(userName, passWord);
@@ -305,6 +342,7 @@
 		/// <summary>
 		/// Register a durable consumer
 		/// </summary>
+		/// <param name="connectionID">Connection ID of the consumer.</param>
 		/// <param name="destination">Destination name to register.  Supports embedded prefix names.</param>
 		/// <param name="consumerID">Name of the durable consumer.</param>
 		/// <param name="selector">Selector parameters for consumer.</param>
@@ -325,6 +363,11 @@
 			}
 		}
 
+		/// <summary>
+		/// Unregister a durable consumer for the given connection ID.
+		/// </summary>
+		/// <param name="connectionID">Connection ID of the consumer.</param>
+		/// <param name="consumerID">Name of the durable consumer.</param>
 		protected void UnregisterDurableConsumer(string connectionID, string consumerID)
 		{
 			using(IConnection connection = CreateConnection(connectionID))
@@ -337,21 +380,25 @@
 			}
 		}
 
+		[Obsolete]
 		protected virtual IMessageProducer CreateProducer()
 		{
 			return Session.CreateProducer(Destination);
 		}
 
+		[Obsolete]
 		protected virtual IMessageConsumer CreateConsumer()
 		{
 			return Session.CreateConsumer(Destination);
 		}
 
+		[Obsolete]
 		protected virtual IDestination CreateDestination()
 		{
 			return CreateDestination(Session);
 		}
 
+		[Obsolete]
 		protected virtual IDestination CreateDestination(ISession curSession)
 		{
 			if(destinationType == DestinationType.Queue)
@@ -376,6 +423,7 @@
 			}
 		}
 
+		[Obsolete]
 		protected virtual string CreateDestinationName()
 		{
 			return "Test.DotNet." + GetType().Name + "." + NextNumber.ToString();
@@ -392,6 +440,7 @@
 			}
 		}
 
+		[Obsolete]
 		protected virtual IMessage CreateMessage()
 		{
 			return Session.CreateMessage();
@@ -402,6 +451,7 @@
 			Assert.IsNotNull(message, "Null Message!");
 		}
 
+		[Obsolete]
 		public IDestination Destination
 		{
 			get
@@ -410,20 +460,11 @@
 				{
 					destination = CreateDestination();
 					Assert.IsNotNull(destination, "No destination available!");
-					WriteLine("Using destination: " + destination);
+					Console.WriteLine("Using destination: " + destination);
 				}
 				return destination;
 			}
 			set { destination = value; }
 		}
-
-		protected virtual void WriteLine(string text)
-		{
-			if(logging)
-			{
-				Console.WriteLine();
-				Console.WriteLine("#### : " + text);
-			}
-		}
 	}
-}
\ No newline at end of file
+}

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TemporaryQueueTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TemporaryQueueTest.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TemporaryQueueTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TemporaryQueueTest.cs Wed Aug  6 17:22:22 2008
@@ -50,11 +50,11 @@
 
             // Send message to queue which has a listener to reply to the temporary queue
             IMessageProducer producer = CreateProducer();
+			producer.Persistent = false;
             
             IMessage request = CreateMessage();
             request.NMSCorrelationID = "abc";
             request.NMSReplyTo = tempQ;
-            request.NMSPersistent = false;
             producer.Send(request);
 
             // now lets wait for the message to arrive on the temporary queue

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs Wed Aug  6 17:22:22 2008
@@ -14,7 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
+using Apache.NMS.Util;
 using NUnit.Framework;
 
 namespace Apache.NMS.Test
@@ -22,38 +24,58 @@
     [TestFixture]
     public abstract class TextMessage : NMSTestSupport
     {
-        private string expected = "Hello World!";
-
-        [SetUp]
-        public override void SetUp()
-        {
-            base.SetUp();
-        }
-
-        [TearDown]
-        public override void TearDown()
-        {
-            base.TearDown();
-        }
-
+		protected static string DESTINATION_NAME = "TextMessageDestination";
+		protected static string TEST_CLIENT_ID = "TextMessageClientId";
+		
         [Test]
-        public override void SendAndSyncReceive()
+        public void SendReceiveTextMessage()
         {
-            base.SendAndSyncReceive();
-        }
+			doSendReceiveTextMessage(false);
+		}
 
-        protected override IMessage CreateMessage()
-        {
-            IMessage request = Session.CreateTextMessage(expected);
-            return request;
+		[Test]
+		public void SendReceiveTextMessagePersistent()
+		{
+			doSendReceiveTextMessage(true);
+		}
+
+		protected void doSendReceiveTextMessage(bool persistent)
+		{
+			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			{
+				connection.Start();
+				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+				{
+					IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME);
+					using(IMessageConsumer consumer = session.CreateConsumer(destination, receiveTimeout))
+					using(IMessageProducer producer = session.CreateProducer(destination, receiveTimeout))
+					{
+						producer.Persistent = persistent;
+						producer.RequestTimeout = receiveTimeout;
+						IMessage request = session.CreateTextMessage("Hello World!");
+						producer.Send(request);
+
+						IMessage message = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(request, message, "Text message does not match.");
+						Assert.AreEqual(persistent, message.NMSPersistent, "NMSPersistent does not match");
+					}
+				}
+			}
         }
 
-        protected override void AssertValidMessage(IMessage message)
-        {
-            ITextMessage textMessage = (ITextMessage) message;
-            String text = textMessage.Text;
-            Console.WriteLine("Received message with text: " + text);
-            Assert.AreEqual(expected, text, "the message text");
-        }
-    }
+		/// <summary>
+		/// Assert that two messages are ITextMessages and their text bodies are equal.
+		/// </summary>
+		/// <param name="expected"></param>
+		/// <param name="actual"></param>
+		/// <param name="message"></param>
+		protected void AssertTextMessageEqual(IMessage expected, IMessage actual, String message)
+		{
+			ITextMessage expectedTextMsg = expected as ITextMessage;
+			Assert.IsNotNull(expectedTextMsg, "'expected' message not a text message");
+			ITextMessage actualTextMsg = actual as ITextMessage;
+			Assert.IsNotNull(actualTextMsg, "'actual' message not a text message");
+			Assert.AreEqual(expectedTextMsg.Text, actualTextMsg.Text, message);
+		}
+	}
 }
\ No newline at end of file

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs?rev=683452&r1=683451&r2=683452&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs Wed Aug  6 17:22:22 2008
@@ -14,240 +14,229 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-using NUnit.Framework;
+
 using System;
 using System.Collections;
-
+using Apache.NMS.Util;
+using NUnit.Framework;
 
 namespace Apache.NMS.Test
 {
 	[TestFixture]
-    abstract public class TransactionTest : NMSTestSupport
-    {
-        IMessageProducer producer;
-        IMessageConsumer consumer;
-        
-        [SetUp]
-		override public void SetUp()
-        {
-            base.SetUp();
-			acknowledgementMode = AcknowledgementMode.Transactional;
-            Drain();
-            consumer = Session.CreateConsumer(Destination);
-            producer = Session.CreateProducer(Destination);
-        }
-		
-        [TearDown]
-        override public void TearDown()
-        {
-			base.TearDown();
-        }
-		
-		
-        [Test]
-        public void TestSendRollback()
-        {
-            IMessage[] outbound = new IMessage[]{
-                Session.CreateTextMessage("First Message"),
-                Session.CreateTextMessage("Second Message")
-            };
-            
-            //sends a message
-            producer.Send(outbound[0]);
-            Session.Commit();
-            
-            //sends a message that gets rollbacked
-            producer.Send(Session.CreateTextMessage("I'm going to get rolled back."));
-            Session.Rollback();
-            
-            //sends a message
-            producer.Send(outbound[1]);
-            Session.Commit();
-            
-            //receives the first message
-            ArrayList messages = new ArrayList();
-            Console.WriteLine("About to consume message 1");
-            IMessage message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            messages.Add(message);
-            Console.WriteLine("Received: " + message);
-            
-            //receives the second message
-            Console.WriteLine("About to consume message 2");
-            message = consumer.Receive(TimeSpan.FromMilliseconds(4000));
-            messages.Add(message);
-            Console.WriteLine("Received: " + message);
-            
-            //validates that the rollbacked was not consumed
-            Session.Commit();
-            IMessage[] inbound = new IMessage[messages.Count];
-            messages.CopyTo(inbound);
-            AssertTextMessagesEqual("Rollback did not work.", outbound, inbound);
-        }
-        
-        [Test]
-        public void TestSendSessionClose()
-        {
-            IMessage[] outbound = new IMessage[]{
-                Session.CreateTextMessage("First Message"),
-                Session.CreateTextMessage("Second Message")
-            };
-            
-            //sends a message
-            producer.Send(outbound[0]);
-            Session.Commit();
-            
-            //sends a message that gets rollbacked
-            producer.Send(Session.CreateTextMessage("I'm going to get rolled back."));
-            consumer.Dispose();
-            Session.Dispose();
-            
-            Reconnect();
-            
-            //sends a message
-            producer.Send(outbound[1]);
-            Session.Commit();
-            
-            //receives the first message
-            ArrayList messages = new ArrayList();
-            Console.WriteLine("About to consume message 1");
-            IMessage message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            messages.Add(message);
-            Console.WriteLine("Received: " + message);
-            
-            //receives the second message
-            Console.WriteLine("About to consume message 2");
-            message = consumer.Receive(TimeSpan.FromMilliseconds(4000));
-            messages.Add(message);
-            Console.WriteLine("Received: " + message);
-            
-            //validates that the rollbacked was not consumed
-            Session.Commit();
-            IMessage[] inbound = new IMessage[messages.Count];
-            messages.CopyTo(inbound);
-            AssertTextMessagesEqual("Rollback did not work.", outbound, inbound);
-        }
-        
-        [Test]
-        public void TestReceiveRollback()
-        {
-            IMessage[] outbound = new IMessage[]{
-                Session.CreateTextMessage("First Message"),
-                Session.CreateTextMessage("Second Message")
-            };
-            
-            //sent both messages
-            producer.Send(outbound[0]);
-            producer.Send(outbound[1]);
-            Session.Commit();
-            
-            Console.WriteLine("Sent 0: " + outbound[0]);
-            Console.WriteLine("Sent 1: " + outbound[1]);
-            
-            ArrayList messages = new ArrayList();
-            IMessage message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            messages.Add(message);
-            Session.Commit();
-            
-            // rollback so we can get that last message again.
-            message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            Assert.IsNotNull(message);
-            Session.Rollback();
-            
-            // Consume again.. the previous message should
-            // get redelivered.
-            message = consumer.Receive(TimeSpan.FromMilliseconds(5000));
-            Assert.IsNotNull(message, "Should have re-received the message again!");
-            messages.Add(message);
-            Session.Commit();
-            
-            IMessage[] inbound = new IMessage[messages.Count];
-            messages.CopyTo(inbound);
-            AssertTextMessagesEqual("Rollback did not work", outbound, inbound);
-        }
-        
-        
-        [Test]
-        public void TestReceiveTwoThenRollback()
-        {
-            IMessage[] outbound = new IMessage[]{
-                Session.CreateTextMessage("First Message"),
-                Session.CreateTextMessage("Second Message")
-            };
-            
-            producer.Send(outbound[0]);
-            producer.Send(outbound[1]);
-            Session.Commit();
-            
-            Console.WriteLine("Sent 0: " + outbound[0]);
-            Console.WriteLine("Sent 1: " + outbound[1]);
-            
-            ArrayList messages = new ArrayList();
-            IMessage message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            AssertTextMessageEqual("first mesage received before rollback", outbound[0], message);
-            
-            message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            Assert.IsNotNull(message);
-            AssertTextMessageEqual("second message received before rollback", outbound[1], message);
-            Session.Rollback();
-            
-            // Consume again.. the previous message should
-            // get redelivered.
-            message = consumer.Receive(TimeSpan.FromMilliseconds(5000));
-            Assert.IsNotNull(message, "Should have re-received the first message again!");
-            messages.Add(message);
-            AssertTextMessageEqual("first message received after rollback", outbound[0], message);
-            
-            message = consumer.Receive(TimeSpan.FromMilliseconds(5000));
-            Assert.IsNotNull(message, "Should have re-received the second message again!");
-            messages.Add(message);
-            AssertTextMessageEqual("second message received after rollback", outbound[1], message);
-            
-            Assert.IsNull(consumer.ReceiveNoWait());
-            Session.Commit();
-            
-            IMessage[] inbound = new IMessage[messages.Count];
-            messages.CopyTo(inbound);
-            AssertTextMessagesEqual("Rollback did not work", outbound, inbound);
-        }
-        
-        protected override string CreateDestinationName()
-        {
-            // TODO - how can we get the test name?
-            return base.CreateDestinationName() + (++destinationCounter);
-        }
-        
-        protected void AssertTextMessagesEqual(String message, IMessage[] expected, IMessage[] actual)
-        {
-            Assert.AreEqual(expected.Length, actual.Length, "Incorrect number of messages received");
-            
-            for (int i = 0; i < expected.Length; i++)
-            {
-                AssertTextMessageEqual(message + ". Index: " + i, expected[i], actual[i]);
-            }
-        }
-        
-        protected void AssertTextMessageEqual(String message, IMessage expected, IMessage actual)
-        {
-            Assert.IsTrue(expected is ITextMessage, "expected object not a text message");
-            Assert.IsTrue(actual is ITextMessage, "actual object not a text message");
-            
-            String expectedText = ((ITextMessage) expected).Text;
-            String actualText = ((ITextMessage) actual).Text;
-            
-            Assert.AreEqual(expectedText, actualText, message);
-        }
-		
+	abstract public class TransactionTest : NMSTestSupport
+	{
+		protected static string DESTINATION_NAME = "TransactionTestDestination";
+		protected static string TEST_CLIENT_ID = "TransactionTestClientId";
+		protected static string TEST_CLIENT_ID2 = "TransactionTestClientId2";
+
+		[Test]
+		public void TestSendRollback()
+		{
+			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			{
+				connection.Start();
+				using(ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
+				{
+					IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME);
+					using(IMessageConsumer consumer = session.CreateConsumer(destination, receiveTimeout))
+					using(IMessageProducer producer = session.CreateProducer(destination, receiveTimeout))
+					{
+						producer.Persistent = false;
+						producer.RequestTimeout = receiveTimeout;
+						ITextMessage firstMsgSend = session.CreateTextMessage("First Message");
+						producer.Send(firstMsgSend);
+						session.Commit();
+
+						ITextMessage rollbackMsg = session.CreateTextMessage("I'm going to get rolled back.");
+						producer.Send(rollbackMsg);
+						session.Rollback();
+
+						ITextMessage secondMsgSend = session.CreateTextMessage("Second Message");
+						producer.Send(secondMsgSend);
+						session.Commit();
+
+						// Receive the messages
+
+						IMessage message = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
+
+						message = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(secondMsgSend, message, "Second message does not match.");
+
+						// validates that the rollback was not consumed
+						session.Commit();
+					}
+				}
+			}
+		}
+
+		[Test]
+		public void TestSendSessionClose()
+		{
+			ITextMessage firstMsgSend;
+			ITextMessage secondMsgSend;
+
+			using(IConnection connection1 = CreateConnection(TEST_CLIENT_ID))
+			{
+				connection1.Start();
+				using(ISession session1 = connection1.CreateSession(AcknowledgementMode.Transactional))
+				{
+					IDestination destination1 = SessionUtil.GetDestination(session1, DESTINATION_NAME);
+					using(IMessageConsumer consumer = session1.CreateConsumer(destination1, receiveTimeout))
+					{
+						// First connection session that sends one message, and the
+						// second message is implicitly rolled back as the session is
+						// disposed before Commit() can be called.
+						using(IConnection connection2 = CreateConnection(TEST_CLIENT_ID2))
+						{
+							connection2.Start();
+							using(ISession session2 = connection2.CreateSession(AcknowledgementMode.Transactional))
+							{
+								IDestination destination2 = SessionUtil.GetDestination(session2, DESTINATION_NAME);
+								using(IMessageProducer producer = session2.CreateProducer(destination2, receiveTimeout))
+								{
+									producer.Persistent = false;
+									producer.RequestTimeout = receiveTimeout;
+									firstMsgSend = session2.CreateTextMessage("First Message");
+									producer.Send(firstMsgSend);
+									session2.Commit();
+
+									ITextMessage rollbackMsg = session2.CreateTextMessage("I'm going to get rolled back.");
+									producer.Send(rollbackMsg);
+								}
+							}
+						}
+
+						// Second connection session that will send one message.
+						using(IConnection connection2 = CreateConnection(TEST_CLIENT_ID2))
+						{
+							connection2.Start();
+							using(ISession session2 = connection2.CreateSession(AcknowledgementMode.Transactional))
+							{
+								IDestination destination2 = SessionUtil.GetDestination(session2, DESTINATION_NAME);
+								using(IMessageProducer producer = session2.CreateProducer(destination2, receiveTimeout))
+								{
+									producer.Persistent = false;
+									producer.RequestTimeout = receiveTimeout;
+									secondMsgSend = session2.CreateTextMessage("Second Message");
+									producer.Send(secondMsgSend);
+									session2.Commit();
+								}
+							}
+						}
+
+						// Check the consumer to verify which messages were actually received.
+						IMessage message = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
+
+						message = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(secondMsgSend, message, "Second message does not match.");
+
+						// validates that the rollback was not consumed
+						session1.Commit();
+					}
+				}
+			}
+		}
+
+		[Test]
+		public void TestReceiveRollback()
+		{
+			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			{
+				connection.Start();
+				using(ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
+				{
+					IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME);
+					using(IMessageConsumer consumer = session.CreateConsumer(destination, receiveTimeout))
+					using(IMessageProducer producer = session.CreateProducer(destination, receiveTimeout))
+					{
+						producer.Persistent = false;
+						producer.RequestTimeout = receiveTimeout;
+						// Send both messages
+						ITextMessage firstMsgSend = session.CreateTextMessage("First Message");
+						producer.Send(firstMsgSend);
+						ITextMessage secondMsgSend = session.CreateTextMessage("Second Message");
+						producer.Send(secondMsgSend);
+						session.Commit();
+
+						// Receive the messages
+
+						IMessage message = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
+						session.Commit();
+
+						message = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(secondMsgSend, message, "Second message does not match.");
+
+						// Rollback so we can get that last message again.
+						session.Rollback();
+						IMessage rollbackMsg = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(secondMsgSend, rollbackMsg, "Rollback message does not match.");
+						session.Commit();
+					}
+				}
+			}
+		}
+
+
+		[Test]
+		public void TestReceiveTwoThenRollback()
+		{
+			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			{
+				connection.Start();
+				using(ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
+				{
+					IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME);
+					using(IMessageConsumer consumer = session.CreateConsumer(destination, receiveTimeout))
+					using(IMessageProducer producer = session.CreateProducer(destination, receiveTimeout))
+					{
+						producer.Persistent = false;
+						producer.RequestTimeout = receiveTimeout;
+						// Send both messages
+						ITextMessage firstMsgSend = session.CreateTextMessage("First Message");
+						producer.Send(firstMsgSend);
+						ITextMessage secondMsgSend = session.CreateTextMessage("Second Message");
+						producer.Send(secondMsgSend);
+						session.Commit();
+
+						// Receive the messages
+
+						IMessage message = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
+						message = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(secondMsgSend, message, "Second message does not match.");
+
+						// Rollback so we can get that last two messages again.
+						session.Rollback();
+						IMessage rollbackMsg = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(firstMsgSend, rollbackMsg, "First rollback message does not match.");
+						rollbackMsg = consumer.Receive(receiveTimeout);
+						AssertTextMessageEqual(secondMsgSend, rollbackMsg, "Second rollback message does not match.");
+			
+						Assert.IsNull(consumer.ReceiveNoWait());
+						session.Commit();
+					}
+				}
+			}
+		}
+
 		/// <summary>
-		/// Method Reconnect
+		/// Assert that two messages are ITextMessages and their text bodies are equal.
 		/// </summary>
-		protected override void Reconnect()
+		/// <param name="expected"></param>
+		/// <param name="actual"></param>
+		/// <param name="message"></param>
+		protected void AssertTextMessageEqual(IMessage expected, IMessage actual, String message)
 		{
-			base.Reconnect();
-            consumer = Session.CreateConsumer(Destination);
-            producer = Session.CreateProducer(Destination);
+			ITextMessage expectedTextMsg = expected as ITextMessage;
+			Assert.IsNotNull(expectedTextMsg, "'expected' message not a text message");
+			ITextMessage actualTextMsg = actual as ITextMessage;
+			Assert.IsNotNull(actualTextMsg, "'actual' message not a text message");
+			Assert.AreEqual(expectedTextMsg.Text, actualTextMsg.Text, message);
 		}
-		
-    }
+	}
 }
 
 



Mime
View raw message