[jboss-cvs] JBoss Messaging SVN: r5763 - trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 29 16:20:13 EST 2009


Author: clebert.suconic at jboss.com
Date: 2009-01-29 16:20:13 -0500 (Thu, 29 Jan 2009)
New Revision: 5763

Modified:
   trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/JustReplicationTest.java
Log:
JBMESSAGING-1488: Just a quick change to the test, as I had it this way (multi-thread) somewhere on my workspace

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/JustReplicationTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/JustReplicationTest.java	2009-01-29 20:11:12 UTC (rev 5762)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/JustReplicationTest.java	2009-01-29 21:20:13 UTC (rev 5763)
@@ -23,6 +23,7 @@
 package org.jboss.messaging.tests.integration.cluster.failover;
 
 import java.nio.ByteBuffer;
+import java.util.concurrent.CountDownLatch;
 
 import org.jboss.messaging.core.client.ClientConsumer;
 import org.jboss.messaging.core.client.ClientMessage;
@@ -59,25 +60,76 @@
 
    public void testFactory() throws Exception
    {
+      final ClientSessionFactory factory = createFailoverFactory(); // Just a regular factory with Backup configured
+      
+      final int NUMBER_OF_THREADS = 5;
+      final int NUMBER_OF_ITERATIONS = 5;
+      final int NUMBER_OF_SESSIONS = 5;
+      
+      final CountDownLatch flagAlign = new CountDownLatch(NUMBER_OF_THREADS);
+      final CountDownLatch flagStart = new CountDownLatch(1);
 
-     final ClientSessionFactory factory = createFailoverFactory(); // Just a regular factory with Backup configured
+      class LocalThread extends Thread
+      {
 
-     for (int i = 0; i < 2; i++)
-     {
-        ClientSession sessions[] = new ClientSession[10];
-        for (int j = 0; j < 10; j++)
-        {
-           sessions[j] = factory.createSession(false, true, true);
-           sessions[j].start();
-        }
+         Throwable e;
 
-        for (ClientSession session: sessions)
-        {
-           session.close();
-        }
+         @Override
+         public void run()
+         {
+            try
+            {
+               flagAlign.countDown();
+               flagStart.await();
 
-     }
+               
+               for (int i = 0; i < NUMBER_OF_ITERATIONS; i++)
+               {
+                  ClientSession sessions[] = new ClientSession[NUMBER_OF_SESSIONS];
+                  for (int j = 0; j < NUMBER_OF_SESSIONS; j++)
+                  {
+                     sessions[j] = factory.createSession(false, true, true);
+                     sessions[j].start();
+                  }
 
+                  for (ClientSession session : sessions)
+                  {
+                     session.close();
+                  }
+
+               }
+            }
+            catch (Throwable e)
+            {
+               this.e = e;
+            }
+         }
+      }
+
+      LocalThread t[] = new LocalThread[NUMBER_OF_THREADS];
+
+      for (int i = 0; i < t.length; i++)
+      {
+         t[i] = new LocalThread();
+         t[i].start();
+      }
+      
+      flagAlign.await();
+      flagStart.countDown();
+
+      for (LocalThread localT : t)
+      {
+         localT.join();
+      }
+
+      for (LocalThread localT : t)
+      {
+         if (localT.e != null)
+         {
+            throw new Exception(localT.e.getMessage(), localT.e);
+         }
+      }
+
    }
 
    public void testJustReplication() throws Exception
@@ -86,7 +138,7 @@
       factory.setBlockOnAcknowledge(true);
       factory.setBlockOnNonPersistentSend(true);
       factory.setBlockOnPersistentSend(true);
-      
+
       factory.setMinLargeMessageSize(10 * 1024);
 
       ClientSession session = factory.createSession(null, null, false, true, true, false, 0);
@@ -94,7 +146,7 @@
       final int numberOfMessages = 500;
 
       final int numberOfBytes = 15000;
-      
+
       try
       {
          session.createQueue(ADDRESS, ADDRESS, null, true, false);
@@ -163,9 +215,10 @@
    @Override
    protected void setUp() throws Exception
    {
-      setUpFileBased(100*1024*1024);
+      setUpFileBased(100 * 1024 * 1024);
    }
 
+   @Override
    protected void tearDown() throws Exception
    {
       super.tearDown();




More information about the jboss-cvs-commits mailing list