activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r986104 - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/src/test/csharp/IndividualAckTest.cs Apache.NMS/trunk/src/test/csharp/TempDestinationTest.cs
Date Mon, 16 Aug 2010 19:25:50 GMT
Author: jgomes
Date: Mon Aug 16 19:25:50 2010
New Revision: 986104

URL: http://svn.apache.org/viewvc?rev=986104&view=rev
Log:
Fix message comparison in the test.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/IndividualAckTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TempDestinationTest.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/IndividualAckTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/IndividualAckTest.cs?rev=986104&r1=986103&r2=986104&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/IndividualAckTest.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/IndividualAckTest.cs
Mon Aug 16 19:25:50 2010
@@ -21,16 +21,16 @@ using NUnit.Framework;
 
 namespace Apache.NMS.ActiveMQ.Test
 {
-    [TestFixture]    
+    [TestFixture]
     public class IndividualAckTest : NMSTestSupport
     {
         private IConnection connection;
-        
+
         [SetUp]
         public override void SetUp()
         {
             base.SetUp();
-    
+
             connection = CreateConnection();
             connection.Start();
         }
@@ -43,120 +43,123 @@ namespace Apache.NMS.ActiveMQ.Test
         }
 
         [Test]
-        public void TestAckedMessageAreConsumed() 
+        public void TestAckedMessageAreConsumed()
         {
             ISession session = connection.CreateSession(AcknowledgementMode.IndividualAcknowledge);
             ITemporaryQueue queue = session.CreateTemporaryQueue();
             IMessageProducer producer = session.CreateProducer(queue);
             producer.Send(session.CreateTextMessage("Hello"));
-    
+
             // Consume the message...
             IMessageConsumer consumer = session.CreateConsumer(queue);
             IMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
             Assert.IsNotNull(msg);
             msg.Acknowledge();
-    
+
             // Reset the session.
             session.Close();
             session = connection.CreateSession(AcknowledgementMode.IndividualAcknowledge);
-    
+
             // Attempt to Consume the message...
             consumer = session.CreateConsumer(queue);
             msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
             Assert.IsNull(msg);
-    
+
             session.Close();
         }
 
         [Test]
-        public void TestLastMessageAcked() 
+        public void TestLastMessageAcked()
         {
             ISession session = connection.CreateSession(AcknowledgementMode.IndividualAcknowledge);
             ITemporaryQueue queue = session.CreateTemporaryQueue();
             IMessageProducer producer = session.CreateProducer(queue);
-            ITextMessage msg1 = session.CreateTextMessage("msg1");
-            ITextMessage msg2 = session.CreateTextMessage("msg2");
-            ITextMessage msg3 = session.CreateTextMessage("msg3");
+            ITextMessage msg1 = session.CreateTextMessage("msg1" + Guid.NewGuid().ToString());
+            ITextMessage msg2 = session.CreateTextMessage("msg2" + Guid.NewGuid().ToString());
+            ITextMessage msg3 = session.CreateTextMessage("msg3" + Guid.NewGuid().ToString());
             producer.Send(msg1);
             producer.Send(msg2);
             producer.Send(msg3);
-    
+
             // Consume the message...
             IMessageConsumer consumer = session.CreateConsumer(queue);
-            IMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            Assert.IsNotNull(msg);
-            msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            Assert.IsNotNull(msg);        
-            msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            Assert.IsNotNull(msg);
-            msg.Acknowledge();
-    
+            ITextMessage ackmsg = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;
+            Assert.IsNotNull(ackmsg);
+            Assert.AreEqual(msg1.Text,ackmsg.Text);
+            ackmsg = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;
+            Assert.IsNotNull(ackmsg);
+            Assert.AreEqual(msg2.Text,ackmsg.Text);
+            ackmsg = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;
+            Assert.IsNotNull(ackmsg);
+            Assert.AreEqual(msg3.Text,ackmsg.Text);
+            ackmsg.Acknowledge();
+
             // Reset the session.
             session.Close();
             session = connection.CreateSession(AcknowledgementMode.IndividualAcknowledge);
-    
+
             // Attempt to Consume the message...
             consumer = session.CreateConsumer(queue);
-            msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            Assert.IsNotNull(msg);
-            Assert.AreEqual(msg1,msg);
-            msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            Assert.IsNotNull(msg);
-            Assert.AreEqual(msg2,msg);
-            msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
+            ackmsg = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;
+            Assert.IsNotNull(ackmsg);
+            Assert.AreEqual(msg1.Text,ackmsg.Text);
+            ackmsg = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;
+            Assert.IsNotNull(ackmsg);
+            Assert.AreEqual(msg2.Text,ackmsg.Text);
+            IMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
             Assert.IsNull(msg);
             session.Close();
         }
 
         [Test]
-        public void TestUnAckedMessageAreNotConsumedOnSessionClose() 
+        public void TestUnAckedMessageAreNotConsumedOnSessionClose()
         {
             ISession session = connection.CreateSession(AcknowledgementMode.IndividualAcknowledge);
             ITemporaryQueue queue = session.CreateTemporaryQueue();
             IMessageProducer producer = session.CreateProducer(queue);
             producer.Send(session.CreateTextMessage("Hello"));
-    
+
             // Consume the message...
             IMessageConsumer consumer = session.CreateConsumer(queue);
             IMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
-            Assert.IsNotNull(msg);        
+            Assert.IsNotNull(msg);
             // Don't ack the message.
-            
+
             // Reset the session.  This should cause the unacknowledged message to be re-delivered.
             session.Close();
             session = connection.CreateSession(AcknowledgementMode.IndividualAcknowledge);
-                    
+
             // Attempt to Consume the message...
             consumer = session.CreateConsumer(queue);
             msg = consumer.Receive(TimeSpan.FromMilliseconds(2000));
-            Assert.IsNotNull(msg);        
+            Assert.IsNotNull(msg);
             msg.Acknowledge();
-            
+
             session.Close();
         }
-        
+
         [Test]
 	    public void TestIndividualAcknowledgeMultiMessages_AcknowledgeFirstTest()
 		{
             ISession session = connection.CreateSession(AcknowledgementMode.IndividualAcknowledge);
-	
+
             // Push 2 messages to queue
             ITemporaryQueue queue = session.CreateTemporaryQueue();
             IMessageProducer producer = session.CreateProducer(queue);
 
             ITextMessage msg = session.CreateTextMessage("test 1");
-            producer.Send(msg, MsgDeliveryMode.Persistent, MsgPriority.Normal, TimeSpan.MinValue);
           
-			msg = session.CreateTextMessage("test 2");		
+            producer.Send(msg, MsgDeliveryMode.Persistent, MsgPriority.Normal, TimeSpan.MinValue);
+			msg = session.CreateTextMessage("test 2");
             producer.Send(msg, MsgDeliveryMode.Persistent, MsgPriority.Normal, TimeSpan.MinValue);
             producer.Close();
 
             IMessageConsumer consumer = session.CreateConsumer(queue);
-			
+
             // Read the first message
             ITextMessage fetchedMessage1 = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(2000));
             Assert.IsNotNull(fetchedMessage1);
             Assert.AreEqual("test 1", fetchedMessage1.Text);
-            
+
 			// Read the second message
 			ITextMessage fetchedMessage2 = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(2000));
             Assert.IsNotNull(fetchedMessage2);
@@ -215,7 +218,7 @@ namespace Apache.NMS.ActiveMQ.Test
             Assert.IsNull(msg);
             session.Close();
         }
-		
+
         [Test]
         public void TestManyMessageAckedAfterAllConsumption()
         {

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TempDestinationTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TempDestinationTest.cs?rev=986104&r1=986103&r2=986104&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TempDestinationTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TempDestinationTest.cs Mon Aug
16 19:25:50 2010
@@ -23,7 +23,7 @@ namespace Apache.NMS.Test
 {
     [TestFixture]
     public class TempDestinationTest : NMSTestSupport
-    {        
+    {
         private IConnection connection;
         private IList connections = ArrayList.Synchronized(new ArrayList());
 
@@ -35,13 +35,13 @@ namespace Apache.NMS.Test
             this.connection = CreateConnection();
             this.connections.Add(connection);
         }
-    
+
         [TearDown]
         public override void TearDown()
         {
             foreach(IConnection conn in this.connections)
-            {                
-                try 
+            {
+                try
                 {
                     conn.Close();
                 }
@@ -56,17 +56,17 @@ namespace Apache.NMS.Test
         }
 
         [Test]
-        public void TestTempDestOnlyConsumedByLocalConn() 
+        public void TestTempDestOnlyConsumedByLocalConn()
         {
             connection.Start();
-    
+
             ISession tempSession = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             ITemporaryQueue queue = tempSession.CreateTemporaryQueue();
             IMessageProducer producer = tempSession.CreateProducer(queue);
             producer.DeliveryMode = (MsgDeliveryMode.NonPersistent);
             ITextMessage message = tempSession.CreateTextMessage("First");
             producer.Send(message);
-    
+
             // temp destination should not be consume when using another connection
             IConnection otherConnection = CreateConnection();
             connections.Add(otherConnection);
@@ -83,18 +83,18 @@ namespace Apache.NMS.Test
         }
 
         [Test]
-        public void TestTempQueueHoldsMessagesWithConsumers() 
+        public void TestTempQueueHoldsMessagesWithConsumers()
         {
             ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             ITemporaryQueue queue = session.CreateTemporaryQueue();
             IMessageConsumer consumer = session.CreateConsumer(queue);
             connection.Start();
-    
+
             IMessageProducer producer = session.CreateProducer(queue);
             producer.DeliveryMode = (MsgDeliveryMode.NonPersistent);
             ITextMessage message = session.CreateTextMessage("Hello");
             producer.Send(message);
-    
+
             IMessage message2 = consumer.Receive(TimeSpan.FromMilliseconds(1000));
             Assert.IsNotNull(message2);
             Assert.IsTrue(message2 is ITextMessage, "Expected message to be a ITextMessage");
@@ -102,7 +102,7 @@ namespace Apache.NMS.Test
         }
 
         [Test]
-        public void TestTempQueueHoldsMessagesWithoutConsumers() 
+        public void TestTempQueueHoldsMessagesWithoutConsumers()
         {
             ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             ITemporaryQueue queue = session.CreateTemporaryQueue();
@@ -110,7 +110,7 @@ namespace Apache.NMS.Test
             producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
             ITextMessage message = session.CreateTextMessage("Hello");
             producer.Send(message);
-    
+
             connection.Start();
             IMessageConsumer consumer = session.CreateConsumer(queue);
             IMessage message2 = consumer.Receive(TimeSpan.FromMilliseconds(3000));
@@ -118,37 +118,52 @@ namespace Apache.NMS.Test
             Assert.IsTrue(message2 is ITextMessage, "Expected message to be a ITextMessage");
             Assert.IsTrue(((ITextMessage)message2).Text == message.Text, "Expected message
to be a '" + message.Text + "'");
         }
-    
+
         [Test]
-        public void TestTmpQueueWorksUnderLoad() 
+        public void TestTmpQueueWorksUnderLoad()
         {
             int count = 500;
             int dataSize = 1024;
-    
+
             ArrayList list = new ArrayList(count);
             ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             ITemporaryQueue queue = session.CreateTemporaryQueue();
+            IBytesMessage message;
+            IBytesMessage message2;
             IMessageProducer producer = session.CreateProducer(queue);
             producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
-    
-            byte[] data = new byte[dataSize];
-            for(int i = 0; i < count; i++) 
+
+            byte[] srcdata = new byte[dataSize];
+            srcdata[0] = (byte) 'B';
+            srcdata[1] = (byte) 'A';
+            srcdata[2] = (byte) 'D';
+            srcdata[3] = (byte) 'W';
+            srcdata[4] = (byte) 'O';
+            srcdata[5] = (byte) 'L';
+            srcdata[6] = (byte) 'F';
+            for(int i = 0; i < count; i++)
             {
-                IBytesMessage message = session.CreateBytesMessage();
-                message.WriteBytes(data);
+                message = session.CreateBytesMessage();
+                message.WriteBytes(srcdata);
                 message.Properties.SetInt("c", i);
                 producer.Send(message);
                 list.Add(message);
             }
-    
+
             connection.Start();
+            byte[] data = new byte[dataSize];
+            byte[] data2 = new byte[dataSize];
             IMessageConsumer consumer = session.CreateConsumer(queue);
             for(int i = 0; i < count; i++)
             {
-                IMessage message2 = consumer.Receive(TimeSpan.FromMilliseconds(2000));
-                Assert.IsTrue(message2 != null);
+                message2 = consumer.Receive(TimeSpan.FromMilliseconds(2000)) as IBytesMessage;
+                Assert.IsNotNull(message2);
                 Assert.AreEqual(i, message2.Properties.GetInt("c"));
-                Assert.IsTrue(message2.Equals(list[i]));
+                message = list[i] as IBytesMessage;
+                Assert.IsNotNull(message);
+                message.ReadBytes(data);
+                message2.ReadBytes(data2);
+                Assert.AreEqual(data, data2);
             }
         }
     }



Mime
View raw message