You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jg...@apache.org on 2012/08/01 22:59:36 UTC

svn commit: r1368247 - in /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk: src/test/csharp/AMQNET383Test.cs vs2008-stomp-test.csproj

Author: jgomes
Date: Wed Aug  1 20:59:35 2012
New Revision: 1368247

URL: http://svn.apache.org/viewvc?rev=1368247&view=rev
Log:
Conditionally compile the test since .NET CF does not support the threading model used in the test.
Refactor the multiple tests down to a single test that takes variable parameters.
Add the test to the Visual Studio project file.

Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/AMQNET383Test.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/AMQNET383Test.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/AMQNET383Test.cs?rev=1368247&r1=1368246&r2=1368247&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/AMQNET383Test.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/AMQNET383Test.cs Wed Aug  1 20:59:35 2012
@@ -18,22 +18,19 @@
 /*
  * The main goal of this test list is to make sure that a producer and a consumer with
  * separate connections can communicate properly and consitently despite a waiting time
- * between messages TestStability500WithSleep would be the important test, as a delay of
+ * between messages TestStability with 500 sleep would be the important test, as a delay of
  * 30s is executed at each 100 (100, 200, 300, ...).
  */
 
+using System;
 using System.Threading;
-using Apache.NMS;
-using Apache.NMS.Util;
 using Apache.NMS.Test;
-using Apache.NMS.Stomp;
 using NUnit.Framework;
-using System;
 
 namespace Apache.NMS.Stomp.Test
 {
     [TestFixture]
-    public class NMSTester : NMSTestSupport
+    public class NMSTestStability : NMSTestSupport
     {
         // TODO set proper configuration parameters
         private const string destination = "test";
@@ -114,41 +111,35 @@ namespace Apache.NMS.Stomp.Test
             producerThread = null;
         }
 
-        [Test]
-        public void TestStability5Continuous()
-        {
-            numberOfMessages = 5;
-
-            consumerThread = new Thread(new ThreadStart(NMSTester.ConsumerThread));
-            consumerThread.Start();
-
-            producerThread = new Thread(new ThreadStart(NMSTester.ProducerThreadContinuous));
-            producerThread.Start();
-
-            Thread.Sleep(100);
-
-            Assert.IsTrue(consumerThread.IsAlive && producerThread.IsAlive);
-
-            while (consumerThread.IsAlive && producerThread.IsAlive)
-            {
-                Thread.Sleep(100);
-            }
-
-            Assert.AreEqual("", possibleConsumerException);
-            Assert.AreEqual("", possibleProducerException);
-            Assert.AreEqual(numberOfMessages, producerMessageCounter);
-            Assert.AreEqual(numberOfMessages, consumerMessageCounter);
-        }
+#if !NETCF
+		public enum ProducerTestType
+		{
+			CONTINUOUS,
+			WITHSLEEP
+		}
 
         [Test]
-        public void TestStability50Continuous()
+        public void TestStability(
+            [Values(5, 50, 500)]
+            int testMessages,
+			[Values(ProducerTestType.CONTINUOUS, ProducerTestType.WITHSLEEP)]
+            ProducerTestType producerType)
         {
-            numberOfMessages = 50;
+            //At 100,200,300, ... a delay of 30 seconds is executed in the producer to cause an unexpected disconnect, due to a malformed ACK?
+            numberOfMessages = testMessages;
 
-            consumerThread = new Thread(new ThreadStart(NMSTester.ConsumerThread));
+            consumerThread = new Thread(NMSTestStability.ConsumerThread);
             consumerThread.Start();
 
-            producerThread = new Thread(new ThreadStart(NMSTester.ProducerThreadContinuous));
+			if(ProducerTestType.CONTINUOUS == producerType)
+			{
+				producerThread = new Thread(NMSTestStability.ProducerThreadContinuous);
+			}
+			else
+			{
+				producerThread = new Thread(NMSTestStability.ProducerThreadWithSleep);
+			}
+			
             producerThread.Start();
 
             Thread.Sleep(100);
@@ -160,68 +151,12 @@ namespace Apache.NMS.Stomp.Test
                 Thread.Sleep(100);
             }
 
-            Assert.AreEqual("", possibleConsumerException);
-            Assert.AreEqual("", possibleProducerException);
+            Assert.IsEmpty(possibleConsumerException);
+            Assert.IsEmpty(possibleProducerException);
             Assert.AreEqual(numberOfMessages, producerMessageCounter);
             Assert.AreEqual(numberOfMessages, consumerMessageCounter);
         }
-
-        [Test]
-        public void TestStability500Continuous()
-        {
-            numberOfMessages = 500; //At 100,200,300, ... a delay of 30 seconds is executed in the producer to cause an unexpected disconnect, due to a malformed ACK?
-
-            consumerThread = new Thread(new ThreadStart(NMSTester.ConsumerThread));
-            consumerThread.Start();
-
-            producerThread = new Thread(new ThreadStart(NMSTester.ProducerThreadContinuous));
-            producerThread.Start();
-
-            Thread.Sleep(100);
-
-            Assert.IsTrue(consumerThread.IsAlive && producerThread.IsAlive);
-
-            while (consumerThread.IsAlive && producerThread.IsAlive)
-            {
-                Thread.Sleep(100);
-            }
-
-            Assert.AreEqual("", possibleConsumerException);
-            Assert.AreEqual("", possibleProducerException);
-            Assert.AreEqual(numberOfMessages, producerMessageCounter);
-            Assert.AreEqual(numberOfMessages, consumerMessageCounter);
-        }
-
-        [Test]
-        public void TestStability500WithSleep()
-        {
-            numberOfMessages = 500; //At 100,200,300, ... a delay of 30 seconds is executed in the producer to cause an unexpected disconnect, due to a malformed ACK?
-
-            consumerThread = new Thread(new ThreadStart(NMSTester.ConsumerThread));
-            consumerThread.Start();
-
-            producerThread = new Thread(new ThreadStart(NMSTester.ProducerThreadWithSleep));
-            producerThread.Start();
-
-            Thread.Sleep(100);
-
-            Assert.IsTrue(consumerThread.IsAlive && producerThread.IsAlive);
-
-            while (consumerThread.IsAlive && producerThread.IsAlive)
-            {
-                Thread.Sleep(100);
-            }
-
-            Assert.AreEqual("", possibleConsumerException);
-            Assert.AreEqual("", possibleProducerException);
-            Assert.AreEqual(numberOfMessages, producerMessageCounter);
-            Assert.AreEqual(numberOfMessages, consumerMessageCounter);
-        }
-
-        public static void Main(string[] args)
-        {
-
-        }
+#endif
 
         #region Consumer
         private static void ConsumerThread()

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj?rev=1368247&r1=1368246&r2=1368247&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj Wed Aug  1 20:59:35 2012
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -99,6 +99,7 @@
     <VisualStudio />
   </ProjectExtensions>
   <ItemGroup>
+    <Compile Include="src\test\csharp\AMQNET383Test.cs" />
     <Compile Include="src\test\csharp\StompHelperTest.cs" />
     <Compile Include="src\test\csharp\StompRedeliveryPolicyTest.cs" />
     <Compile Include="src\test\csharp\Threads\CompositeTaskRunnerTest.cs" />