[jboss-cvs] JBoss Messaging SVN: r1717 - in branches/Branch_Client_Failover_Experiment/tests: . bin etc src/org/jboss/test/messaging/jms src/org/jboss/test/messaging/jms/clustering src/org/jboss/test/messaging/tools src/org/jboss/test/messaging/tools/jmx src/org/jboss/test/messaging/tools/jmx/rmi src/org/jboss/test/messaging/tools/jndi

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 7 14:15:57 EST 2006


Author: ovidiu.feodorov at jboss.com
Date: 2006-12-07 14:15:49 -0500 (Thu, 07 Dec 2006)
New Revision: 1717

Modified:
   branches/Branch_Client_Failover_Experiment/tests/bin/.testrc.example
   branches/Branch_Client_Failover_Experiment/tests/bin/runtest
   branches/Branch_Client_Failover_Experiment/tests/bin/start-rmi-server
   branches/Branch_Client_Failover_Experiment/tests/bin/stop-rmi-server
   branches/Branch_Client_Failover_Experiment/tests/build.xml
   branches/Branch_Client_Failover_Experiment/tests/etc/container.xml
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/JMSTest.java
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringBase.java
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainerConfiguration.java
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
Log:
committing changes that were supposed to be in repository since yesterday: modified the test framwork for a higher flexibility in running clustered tests

Modified: branches/Branch_Client_Failover_Experiment/tests/bin/.testrc.example
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/bin/.testrc.example	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/bin/.testrc.example	2006-12-07 19:15:49 UTC (rev 1717)
@@ -20,6 +20,9 @@
 # be also permitting sharing over a LAN. "mysql" allows this, "hsqldb" doesn't. The test will
 # quickly fail in such a situation.
 #
+# It is also possible to configure a test to run in clustered mode by using the "-clustered"
+# switch.
+#
 CLUSTERED=true
 #
 #

Modified: branches/Branch_Client_Failover_Experiment/tests/bin/runtest
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/bin/runtest	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/bin/runtest	2006-12-07 19:15:49 UTC (rev 1717)
@@ -97,6 +97,9 @@
     if [ "$1" = "-remotedebug" ]; then
         REMOTE_DEBUG_FLAG="-debug"
     fi
+    if [ "$1" = "-clustered" ]; then
+        TEST_CLUSTERED=true
+    fi
     shift
 done
 
@@ -109,6 +112,13 @@
 if [ "$isRemote" = "true" ]; then
   export TEST_DATABASE TEST_SERIALIZATION TEST_CLUSTERED
   $reldir/start-rmi-server $REMOTE_DEBUG_FLAG -use-existent-test-classpath-file
+
+  if [ "$TEST_CLUSTERED" = "true" ]; then
+
+     # start the second remote server
+     $reldir/start-rmi-server $REMOTE_DEBUG_FLAG -use-existent-test-classpath-file -index 1
+  fi
+
 fi
 
 
@@ -116,6 +126,10 @@
 org.jboss.test.messaging.tools.junit.SelectiveTestRunner $TARGET_CLASS $TARGET_TEST
 
 if [ "$isRemote" = "true" ]; then
+  $reldir/stop-rmi-server -use-existent-test-classpath-file -index 1
+
+  # stop the second remote server
   $reldir/stop-rmi-server -use-existent-test-classpath-file
+
 fi
 

Modified: branches/Branch_Client_Failover_Experiment/tests/bin/start-rmi-server
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/bin/start-rmi-server	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/bin/start-rmi-server	2006-12-07 19:15:49 UTC (rev 1717)
@@ -27,6 +27,9 @@
         else
             JAVA_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=n,suspend=y,address=rmiserver"
         fi
+    elif [ "$1" = "-index" ]; then
+        shift
+        index=$1
     elif [ "$1" = "-use-existent-test-classpath-file" ]; then
         USE_EXISTENT_TEST_CLASSPATH_FILE=true;
     fi
@@ -49,6 +52,9 @@
    JAVA_OPTS="$JAVA_OPTS -Dtest.clustered=$TEST_CLUSTERED"
 fi
 
+if [ "$index" != "" ]; then
+   JAVA_OPTS="$JAVA_OPTS -Dtest.server.index=$index"
+fi
 
 if [ "$USE_EXISTENT_TEST_CLASSPATH_FILE" = "true" ]; then
    CLASSPATH_FILE="$reldir/.test.execution.classpath"
@@ -68,4 +74,4 @@
 JAVA_OPTS="$JAVA_OPTS -Xmx768M"
 
 java $JAVA_OPTS -cp $CLASSPATH -Dtest.bind.address=localhost \
-org.jboss.test.messaging.tools.jmx.rmi.RMITestServer &
+org.jboss.test.messaging.tools.jmx.rmi.RMITestServer $port &

Modified: branches/Branch_Client_Failover_Experiment/tests/bin/stop-rmi-server
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/bin/stop-rmi-server	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/bin/stop-rmi-server	2006-12-07 19:15:49 UTC (rev 1717)
@@ -27,10 +27,17 @@
         fi
     elif [ "$1" = "-use-existent-test-classpath-file" ]; then
         USE_EXISTENT_TEST_CLASSPATH_FILE=true;
+    elif [ "$1" = "-index" ]; then
+        shift
+        index=$1
     fi
     shift
 done
 
+if [ "$index" != "" ]; then
+   JAVA_OPTS="$JAVA_OPTS -Dtest.server.index=$index"
+fi
+
 if [ "$USE_EXISTENT_TEST_CLASSPATH_FILE" = "true" ]; then
    CLASSPATH_FILE="$reldir/.test.execution.classpath"
 else

Modified: branches/Branch_Client_Failover_Experiment/tests/build.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/build.xml	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/build.xml	2006-12-07 19:15:49 UTC (rev 1717)
@@ -281,7 +281,7 @@
            description="Starts the RMI server used by clustering tests">
 
       <java classname="org.jboss.test.messaging.tools.jmx.rmi.RMITestServer" fork="true" spawn="true">
-         <sysproperty key="test.registry.index" value="${test.registry.index}"/>
+         <sysproperty key="test.server.index" value="${test.server.index}"/>
          <sysproperty key="module.output" value="${tests.output}"/>
          <sysproperty key="remote.test.suffix" value="-remote"/>
          <sysproperty key="test.bind.address" value="${test.bind.address}"/>
@@ -319,7 +319,7 @@
            description="Stops the RMI server used by clustering tests">
       <java classname="org.jboss.test.messaging.tools.jmx.rmi.StopRMIServer"
             classpathref="test.execution.classpath">
-         <sysproperty key="test.registry.index" value="${test.registry.index}"/>
+         <sysproperty key="test.server.index" value="${test.server.index}"/>
       </java>
    </target>
 
@@ -633,26 +633,26 @@
       <!-- Stop the rmi servers in case a previous run aborted -->
 
       <antcall target="stop-rmi-server-clustering">
-         <param name="test.registry.index" value="0"/>
+         <param name="test.server.index" value="0"/>
       </antcall>
       <antcall target="stop-rmi-server-clustering">
-         <param name="test.registry.index" value="1"/>
+         <param name="test.server.index" value="1"/>
       </antcall>
       <antcall target="stop-rmi-server-clustering">
-         <param name="test.registry.index" value="2"/>
+         <param name="test.server.index" value="2"/>
       </antcall>
 
       <!-- Start 3 rmi servers -->
 
       <antcall target="start-rmi-server-clustering">
-         <param name="test.registry.index" value="0"/>
+         <param name="test.server.index" value="0"/>
       </antcall>
 
       <antcall target="start-rmi-server-clustering">
-         <param name="test.registry.index" value="1"/>
+         <param name="test.server.index" value="1"/>
       </antcall>
       <antcall target="start-rmi-server-clustering">
-         <param name="test.registry.index" value="2"/>
+         <param name="test.server.index" value="2"/>
       </antcall>
 
 
@@ -711,13 +711,13 @@
       </junit>
 
       <antcall target="stop-rmi-server-clustering">
-         <param name="test.registry.index" value="0"/>
+         <param name="test.server.index" value="0"/>
       </antcall>
       <antcall target="stop-rmi-server-clustering">
-         <param name="test.registry.index" value="1"/>
+         <param name="test.server.index" value="1"/>
       </antcall>
       <antcall target="stop-rmi-server-clustering">
-         <param name="test.registry.index" value="2"/>
+         <param name="test.server.index" value="2"/>
       </antcall>
 
    </target>

Modified: branches/Branch_Client_Failover_Experiment/tests/etc/container.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/etc/container.xml	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/etc/container.xml	2006-12-07 19:15:49 UTC (rev 1717)
@@ -68,6 +68,20 @@
 
    <serialization-type>jms</serialization-type>
 
+
+   <!--
+      Specifies whether to start a clustered messaging server or not. If "test.clustered" is set,
+      the value of the system property takes precedence. Supported values are "true" or "false".
+
+      Setting "clustered" to "true" doesn't guarantee that the test will be actually run in
+      clustered mode, the test database must be also permitting sharing over a LAN. "mysql" allows
+      this, "hsqldb" doesn't. The test will quickly fail in such a situation.
+   -->
+
+   <!--
+   <clustered>true</clustered>
+   -->
+
 </container>
 
 

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/JMSTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/JMSTest.java	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/JMSTest.java	2006-12-07 19:15:49 UTC (rev 1717)
@@ -87,6 +87,11 @@
       super.tearDown();
    }
 
+   public void testNoop() throws Exception
+   {
+      log.info("noop");
+   }
+
    public void test_NonPersistent_NonTransactional() throws Exception
    {
       ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringBase.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringBase.java	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringBase.java	2006-12-07 19:15:49 UTC (rev 1717)
@@ -92,27 +92,27 @@
       {
          startServer(0);
          startServer(1);
-         startServer(2);
-
+//         startServer(2);
+//
          ic1 = new InitialContext(ServerManagement.getJNDIEnvironment(0));
          ic2 = new InitialContext(ServerManagement.getJNDIEnvironment(1));
-         ic3 = new InitialContext(ServerManagement.getJNDIEnvironment(2));
-         
+//         ic3 = new InitialContext(ServerManagement.getJNDIEnvironment(2));
+//
          log.info("Deployed destinations ok");
-
+//
          cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
          cf2 = (ConnectionFactory)ic2.lookup("/ConnectionFactory");
-         cf3 = (ConnectionFactory)ic3.lookup("/ConnectionFactory");
-
+//         cf3 = (ConnectionFactory)ic3.lookup("/ConnectionFactory");
+//
          queue1 = (Queue)ic1.lookup("queue/testDistributedQueue");
          queue2 = (Queue)ic2.lookup("queue/testDistributedQueue");
-         queue3 = (Queue)ic3.lookup("queue/testDistributedQueue");
-
+//         queue3 = (Queue)ic3.lookup("queue/testDistributedQueue");
+//
          topic1 = (Topic)ic1.lookup("topic/testDistributedTopic");
          topic2 = (Topic)ic2.lookup("topic/testDistributedTopic");
-         topic3 = (Topic)ic3.lookup("topic/testDistributedTopic");
-
-         drainQueues();
+//         topic3 = (Topic)ic3.lookup("topic/testDistributedTopic");
+//
+//         drainQueues();
       }
       catch (Exception e)
       {
@@ -133,8 +133,6 @@
    {
       try
       {
-         super.tearDown();
-
          ServerManagement.log(ServerManagement.INFO,"Undeploying Server 0");
          ServerManagement.undeployQueue("testDistributedQueue", 0);
          ServerManagement.undeployTopic("testDistributedTopic", 0);
@@ -142,6 +140,9 @@
          ServerManagement.log(ServerManagement.INFO,"Undeploying Server 1");
          ServerManagement.undeployQueue("testDistributedQueue", 1);
          ServerManagement.undeployTopic("testDistributedTopic", 1);
+//
+//         ServerManagement.undeployQueue("testDistributedQueue", 2);
+//         ServerManagement.undeployTopic("testDistributedTopic", 2);
 
          ServerManagement.log(ServerManagement.INFO,"Undeploying Server 2");
          ServerManagement.undeployQueue("testDistributedQueue", 2);
@@ -149,7 +150,9 @@
 
          ic1.close();
          ic2.close();
-         ic3.close();
+//         ic3.close();
+
+         super.tearDown();
       }
       catch (Exception e)
       {

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java	2006-12-07 19:15:49 UTC (rev 1717)
@@ -37,85 +37,97 @@
  */
 public class ManualClusteringTest extends ClusteringBase
 {
+
+   // Constants -----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
    public ManualClusteringTest(String name)
    {
       super(name);
    }
-   
 
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-   }
+   // Public --------------------------------------------------------
 
-   protected void tearDown() throws Exception
-   {
-         super.tearDown();
-   }
-   
    public void testClusteredQueueLocalConsumerNonPersistent() throws Exception
    {
-      clusteredQueueLocalConsumer(false);
+      System.out.println("xxxxxxxxxxxx");
+//      clusteredQueueLocalConsumer(false);
    }
-   
+
    public void testClusteredQueueLocalConsumerPersistent() throws Exception
    {
       clusteredQueueLocalConsumer(true);
    }
-        
+
    public void testClusteredTopicNonDurableNonPersistent() throws Exception
    {
       clusteredTopicNonDurable(false);
    }
-   
+
    public void testClusteredTopicNonDurablePersistent() throws Exception
    {
       clusteredTopicNonDurable(true);
    }
-      
+
    public void testClusteredTopicNonDurableWithSelectorsNonPersistent() throws Exception
    {
       clusteredTopicNonDurableWithSelectors(false);
    }
-   
+
    public void testClusteredTopicNonDurableWithSelectorsPersistent() throws Exception
    {
       clusteredTopicNonDurableWithSelectors(true);
    }
-   
+
    public void testClusteredTopicDurableNonPersistent() throws Exception
    {
       clusteredTopicDurable(false);
    }
-   
+
    public void testClusteredTopicDurablePersistent() throws Exception
    {
       clusteredTopicDurable(true);
    }
-   
+
    public void testClusteredTopicSharedDurableLocalConsumerNonPersistent() throws Exception
    {
       clusteredTopicSharedDurableLocalConsumer(false);
    }
-   
+
    public void testClusteredTopicSharedDurableLocalConsumerPersistent() throws Exception
    {
       clusteredTopicSharedDurableLocalConsumer(true);
    }
-   
+
    public void testClusteredTopicSharedDurableNoLocalSubNonPersistent() throws Exception
    {
       clusteredTopicSharedDurableNoLocalSub(false);
    }
-   
+
    public void testClusteredTopicSharedDurableNoLocalSubPersistent() throws Exception
    {
       clusteredTopicSharedDurableNoLocalSub(true);
    }
-   
-   
-   
-   
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+   }
+
+   protected void tearDown() throws Exception
+   {
+         super.tearDown();
+   }
+
    /*
     * Create a consumer on each queue on each node.
     * Send messages in turn from all nodes.
@@ -124,307 +136,308 @@
    protected void clusteredQueueLocalConsumer(boolean persistent) throws Exception
    {
       Connection conn1 = null;
-      
+
       Connection conn2 = null;
-      
+
       Connection conn3 = null;
       try
       {
          conn1 = cf1.createConnection();
-         
+
          conn2 = cf2.createConnection();
-         
+
          conn3 = cf3.createConnection();
-           
+
          Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          MessageConsumer cons1 = sess1.createConsumer(queue1);
-         
+
          MessageConsumer cons2 = sess2.createConsumer(queue2);
-         
+
          MessageConsumer cons3 = sess3.createConsumer(queue3);
-         
+
          conn1.start();
-         
+
          conn2.start();
-         
+
          conn3.start();
-         
+
          //Send at node1
-         
+
          MessageProducer prod1 = sess1.createProducer(queue1);
-         
+
          prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-         
+
          final int NUM_MESSAGES = 100;
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = sess1.createTextMessage("message" + i);
-            
+
             prod1.send(tm);
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons1.receive(1000);
-            
+
             assertNotNull(tm);
-            
+
             assertEquals("message" + i, tm.getText());
          }
-         
+
          Message m = cons2.receive(2000);
-         
+
          assertNull(m);
-         
+
          m = cons3.receive(2000);
-         
+
          assertNull(m);
-         
+
          // Send at node2
-         
+
          MessageProducer prod2 = sess2.createProducer(queue2);
-         
+
          prod2.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = sess2.createTextMessage("message" + i);
-            
+
             prod2.send(tm);
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons2.receive(1000);
-            
+
             assertNotNull(tm);
-            
+
             assertEquals("message" + i, tm.getText());
          }
-         
+
          m = cons1.receive(2000);
-         
+
          assertNull(m);
-         
+
          m = cons3.receive(2000);
-         
+
          assertNull(m);
-         
+
          // Send at node3
-         
+
          MessageProducer prod3 = sess3.createProducer(queue3);
-         
+
          prod3.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = sess3.createTextMessage("message" + i);
-            
+
             prod3.send(tm);
          }
-            
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons3.receive(1000);
-            
+
             assertNotNull(tm);
-            
+
             assertEquals("message" + i, tm.getText());
          }
-         
+
          m = cons1.receive(2000);
-         
+
          assertNull(m);
-         
+
          m = cons2.receive(2000);
-         
-         assertNull(m);         
+
+         assertNull(m);
       }
       finally
-      {      
+      {
          if (conn1 != null) conn1.close();
-         
+
          if (conn2 != null) conn2.close();
-         
+
          if (conn3 != null) conn3.close();
       }
    }
-   
-   
+
+   // Private -------------------------------------------------------
+
    /*
     * Create non durable subscriptions on all nodes of the cluster.
     * Ensure all messages are receive as appropriate
     */
-   public void clusteredTopicNonDurable(boolean persistent) throws Exception
+   private void clusteredTopicNonDurable(boolean persistent) throws Exception
    {
       Connection conn1 = null;
-      
+
       Connection conn2 = null;
-      
+
       Connection conn3 = null;
       try
       {
          conn1 = cf1.createConnection();
-         
+
          conn2 = cf2.createConnection();
-         
+
          conn3 = cf3.createConnection();
-           
+
          Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          MessageConsumer cons1 = sess1.createConsumer(topic1);
-         
+
          MessageConsumer cons2 = sess2.createConsumer(topic2);
-         
+
          MessageConsumer cons3 = sess3.createConsumer(topic3);
-         
+
          MessageConsumer cons4 = sess1.createConsumer(topic1);
-         
+
          MessageConsumer cons5 = sess2.createConsumer(topic2);
-            
+
          conn1.start();
-         
+
          conn2.start();
-         
+
          conn3.start();
-         
+
          //Send at node1
-         
+
          MessageProducer prod1 = sess1.createProducer(topic1);
-         
+
          prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-         
+
          final int NUM_MESSAGES = 100;
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = sess1.createTextMessage("message" + i);
-            
+
             prod1.send(tm);
          }
-            
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons1.receive(1000);
-            
+
             assertNotNull(tm);
-                        
-            assertEquals("message" + i, tm.getText());                        
+
+            assertEquals("message" + i, tm.getText());
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons2.receive(1000);
-                      
+
             assertNotNull(tm);
-            
+
             assertEquals("message" + i, tm.getText());
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons3.receive(1000);
-                        
+
             assertNotNull(tm);
-             
+
             assertEquals("message" + i, tm.getText());
-         } 
-         
+         }
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons4.receive(1000);
-                        
+
             assertNotNull(tm);
-             
+
             assertEquals("message" + i, tm.getText());
-         } 
-         
+         }
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons5.receive(1000);
-                        
+
             assertNotNull(tm);
-             
+
             assertEquals("message" + i, tm.getText());
-         } 
+         }
       }
       finally
-      {      
+      {
          if (conn1 != null) conn1.close();
-         
+
          if (conn2 != null) conn2.close();
-         
+
          if (conn3 != null) conn3.close();
       }
    }
-   
-   
-   
-   
+
+
+
+
    /*
     * Create non durable subscriptions on all nodes of the cluster.
     * Include some with selectors
     * Ensure all messages are receive as appropriate
     */
-   public void clusteredTopicNonDurableWithSelectors(boolean persistent) throws Exception
+   private void clusteredTopicNonDurableWithSelectors(boolean persistent) throws Exception
    {
       Connection conn1 = null;
-      
+
       Connection conn2 = null;
-      
+
       Connection conn3 = null;
       try
       {
          conn1 = cf1.createConnection();
-         
+
          conn2 = cf2.createConnection();
-         
+
          conn3 = cf3.createConnection();
-                             
+
          Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          MessageConsumer cons1 = sess1.createConsumer(topic1);
-         
+
          MessageConsumer cons2 = sess2.createConsumer(topic2);
-         
+
          MessageConsumer cons3 = sess3.createConsumer(topic3);
-         
+
          MessageConsumer cons4 = sess1.createConsumer(topic1, "COLOUR='red'");
-         
+
          MessageConsumer cons5 = sess2.createConsumer(topic2, "COLOUR='blue'");
-            
+
          conn1.start();
-         
+
          conn2.start();
-         
+
          conn3.start();
-         
+
          //Send at node1
-         
+
          MessageProducer prod1 = sess1.createProducer(topic1);
-         
+
          prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-         
+
          final int NUM_MESSAGES = 100;
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = sess1.createTextMessage("message" + i);
-            
+
             int c = i % 3;
             if (c == 0)
             {
@@ -434,422 +447,422 @@
             {
                tm.setStringProperty("COLOUR", "blue");
             }
-            
+
             prod1.send(tm);
          }
-            
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons1.receive(1000);
-            
+
             assertNotNull(tm);
-                        
-            assertEquals("message" + i, tm.getText());                        
+
+            assertEquals("message" + i, tm.getText());
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons2.receive(1000);
-                      
+
             assertNotNull(tm);
-            
+
             assertEquals("message" + i, tm.getText());
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons3.receive(1000);
-                        
+
             assertNotNull(tm);
-             
+
             assertEquals("message" + i, tm.getText());
-         } 
-         
+         }
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             int c = i % 3;
-            
+
             if (c == 0)
             {
                TextMessage tm = (TextMessage)cons4.receive(1000);
-                           
+
                assertNotNull(tm);
-                
+
                assertEquals("message" + i, tm.getText());
             }
-         } 
-         
+         }
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             int c = i % 3;
-            
+
             if (c == 1)
             {
                TextMessage tm = (TextMessage)cons5.receive(1000);
-                           
+
                assertNotNull(tm);
-                
+
                assertEquals("message" + i, tm.getText());
             }
-         } 
+         }
       }
       finally
-      {      
+      {
          if (conn1 != null) conn1.close();
-         
+
          if (conn2 != null) conn2.close();
-         
+
          if (conn3 != null) conn3.close();
       }
    }
-   
-   
-   
+
+
+
    /*
     * Create durable subscriptions on all nodes of the cluster.
     * Include a couple with selectors
     * Ensure all messages are receive as appropriate
     * None of the durable subs are shared
     */
-   public void clusteredTopicDurable(boolean persistent) throws Exception
+   private void clusteredTopicDurable(boolean persistent) throws Exception
    {
       Connection conn1 = null;
-      
+
       Connection conn2 = null;
-      
+
       Connection conn3 = null;
       try
       {
          conn1 = cf1.createConnection();
-         
+
          conn2 = cf2.createConnection();
-         
+
          conn3 = cf3.createConnection();
-         
+
          conn1.setClientID("wib1");
-         
+
          conn2.setClientID("wib1");
-         
+
          conn3.setClientID("wib1");
-           
+
          Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-                  
-         try         
+
+         try
          {
             sess1.unsubscribe("sub1");
          }
          catch (Exception ignore) {}
-         try         
+         try
          {
             sess2.unsubscribe("sub2");
          }
          catch (Exception ignore) {}
-         try         
+         try
          {
             sess3.unsubscribe("sub3");
          }
          catch (Exception ignore) {}
-         try         
+         try
          {
             sess1.unsubscribe("sub4");
          }
          catch (Exception ignore) {}
-         try         
+         try
          {
             sess2.unsubscribe("sub5");
          }
          catch (Exception ignore) {}
-         
+
          MessageConsumer cons1 = sess1.createDurableSubscriber(topic1, "sub1");
-         
+
          MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub2");
-         
+
          MessageConsumer cons3 = sess3.createDurableSubscriber(topic3, "sub3");
-         
+
          MessageConsumer cons4 = sess1.createDurableSubscriber(topic1, "sub4");
-         
+
          MessageConsumer cons5 = sess2.createDurableSubscriber(topic2, "sub5");
-            
+
          conn1.start();
-         
+
          conn2.start();
-         
+
          conn3.start();
-         
+
          //Send at node1
-         
+
          MessageProducer prod1 = sess1.createProducer(topic1);
-         
+
          prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-         
+
          final int NUM_MESSAGES = 100;
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = sess1.createTextMessage("message" + i);
-            
+
             prod1.send(tm);
          }
-            
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons1.receive(1000);
-            
+
             assertNotNull(tm);
-                        
-            assertEquals("message" + i, tm.getText());                        
+
+            assertEquals("message" + i, tm.getText());
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons2.receive(1000);
-                      
+
             assertNotNull(tm);
-            
+
             assertEquals("message" + i, tm.getText());
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons3.receive(1000);
-                        
+
             assertNotNull(tm);
-             
+
             assertEquals("message" + i, tm.getText());
-         } 
-         
+         }
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons4.receive(1000);
-                        
+
             assertNotNull(tm);
-             
+
             assertEquals("message" + i, tm.getText());
-         } 
-         
+         }
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons5.receive(1000);
-                        
+
             assertNotNull(tm);
-             
+
             assertEquals("message" + i, tm.getText());
-         } 
-         
+         }
+
          cons1.close();
-         
+
          cons2.close();
-         
+
          cons3.close();
-         
+
          cons4.close();
-         
+
          cons5.close();
-         
+
          sess1.unsubscribe("sub1");
-         
+
          sess2.unsubscribe("sub2");
-         
+
          sess3.unsubscribe("sub3");
-         
+
          sess1.unsubscribe("sub4");
-         
+
          sess2.unsubscribe("sub5");
-         
+
       }
       finally
-      {      
+      {
          if (conn1 != null) conn1.close();
-         
+
          if (conn2 != null) conn2.close();
-         
+
          if (conn3 != null) conn3.close();
       }
    }
-   
-   
-   
-   
+
+
+
+
    /*
     * Create shared durable subs on multiple nodes, the local instance should always get the message
     */
    protected void clusteredTopicSharedDurableLocalConsumer(boolean persistent) throws Exception
    {
       Connection conn1 = null;
-      
+
       Connection conn2 = null;
-      
+
       Connection conn3 = null;
       try
       {
          conn1 = cf1.createConnection();
-         
+
          conn2 = cf2.createConnection();
-         
+
          conn3 = cf3.createConnection();
-         
+
          conn1.setClientID("wib1");
-         
+
          conn2.setClientID("wib1");
-         
+
          conn3.setClientID("wib1");
-           
+
          Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
-         try         
+
+         try
          {
             sess1.unsubscribe("sub1");
          }
          catch (Exception ignore) {}
-         try         
+         try
          {
             sess2.unsubscribe("sub1");
          }
          catch (Exception ignore) {}
-         try         
+         try
          {
             sess3.unsubscribe("sub1");
          }
          catch (Exception ignore) {}
-         
+
          MessageConsumer cons1 = sess1.createDurableSubscriber(topic1, "sub1");
-         
+
          MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub1");
-         
+
          MessageConsumer cons3 = sess3.createDurableSubscriber(topic3, "sub1");
-         
+
          conn1.start();
-         
+
          conn2.start();
-         
+
          conn3.start();
-         
+
          //Send at node1
-         
+
          MessageProducer prod1 = sess1.createProducer(topic1);
-         
+
          prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-         
+
          final int NUM_MESSAGES = 100;
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = sess1.createTextMessage("message" + i);
-            
+
             prod1.send(tm);
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons1.receive(1000);
-            
+
             assertNotNull(tm);
-            
+
             assertEquals("message" + i, tm.getText());
          }
-         
+
          Message m = cons2.receive(2000);
-         
+
          assertNull(m);
-         
+
          m = cons3.receive(2000);
-         
+
          assertNull(m);
-         
+
          // Send at node2
-         
+
          MessageProducer prod2 = sess2.createProducer(topic2);
-         
+
          prod2.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = sess2.createTextMessage("message" + i);
-            
+
             prod2.send(tm);
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons2.receive(1000);
-            
+
             assertNotNull(tm);
-               
+
             assertEquals("message" + i, tm.getText());
          }
-         
+
          m = cons1.receive(2000);
-         
+
          assertNull(m);
-         
+
          m = cons3.receive(2000);
-         
+
          assertNull(m);
-         
+
          // Send at node3
-         
+
          MessageProducer prod3 = sess3.createProducer(topic3);
-         
+
          prod3.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = sess3.createTextMessage("message" + i);
-            
+
             prod3.send(tm);
          }
-           
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = (TextMessage)cons3.receive(1000);
-            
+
             assertNotNull(tm);
-            
+
             assertEquals("message" + i, tm.getText());
          }
-         
+
          m = cons1.receive(2000);
-         
+
          assertNull(m);
-         
+
          m = cons2.receive(2000);
-         
-         assertNull(m);         
-         
+
+         assertNull(m);
+
          cons1.close();
-         
+
          cons2.close();
-         
+
          cons3.close();
-         
+
          //Need to unsubscribe on any node that the durable sub was created on
-         
+
          sess1.unsubscribe("sub1");
-         
+
          sess2.unsubscribe("sub1");
-         
+
          sess3.unsubscribe("sub1");
       }
       finally
-      {      
+      {
          if (conn1 != null) conn1.close();
-         
+
          if (conn2 != null) conn2.close();
-         
+
          if (conn3 != null) conn3.close();
       }
    }
-   
-   
-   
+
+
+
    /*
     * Create shared durable subs on multiple nodes, but without sub on local node
     * should round robin
@@ -858,97 +871,97 @@
    protected void clusteredTopicSharedDurableNoLocalSub(boolean persistent) throws Exception
    {
       Connection conn1 = null;
-      
+
       Connection conn2 = null;
-      
+
       Connection conn3 = null;
       try
       {
          conn1 = cf1.createConnection();
-         
+
          conn2 = cf2.createConnection();
-         
+
          conn3 = cf3.createConnection();
-         
+
          conn2.setClientID("wib1");
-         
+
          conn3.setClientID("wib1");
-           
+
          Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
+
          Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
-         try         
+
+         try
          {
             sess2.unsubscribe("sub1");
          }
          catch (Exception ignore) {}
-         try         
+         try
          {
             sess3.unsubscribe("sub1");
          }
          catch (Exception ignore) {}
-                  
+
          MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub1");
-         
+
          MessageConsumer cons3 = sess3.createDurableSubscriber(topic3, "sub1");
-         
+
          conn2.start();
-         
+
          conn3.start();
-         
+
          //Send at node1
-         
+
          //Should round robin between the other 2 since there is no active consumer on sub1 on node1
-         
+
          MessageProducer prod1 = sess1.createProducer(topic1);
-         
+
          prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-         
+
          final int NUM_MESSAGES = 100;
-         
+
          for (int i = 0; i < NUM_MESSAGES; i++)
          {
             TextMessage tm = sess1.createTextMessage("message" + i);
-            
+
             prod1.send(tm);
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES / 2; i++)
          {
             TextMessage tm = (TextMessage)cons2.receive(1000);
-            
+
             assertNotNull(tm);
-            
+
             assertEquals("message" + i * 2, tm.getText());
          }
-         
+
          for (int i = 0; i < NUM_MESSAGES / 2; i++)
          {
             TextMessage tm = (TextMessage)cons3.receive(1000);
-            
+
             assertNotNull(tm);
-            
+
             assertEquals("message" + (i * 2 + 1), tm.getText());
          }
-         
+
          cons2.close();
-         
+
          cons3.close();
-         
+
          sess2.unsubscribe("sub1");
-         
+
          sess3.unsubscribe("sub1");
-      
+
       }
       finally
-      {      
+      {
          if (conn1 != null) conn1.close();
-         
+
          if (conn2 != null) conn2.close();
-         
+
          if (conn3 != null) conn3.close();
       }
    }
@@ -956,7 +969,7 @@
    class MyListener implements MessageListener
    {
       private int i;
-      
+
       MyListener(int i)
       {
          this.i = i;
@@ -967,7 +980,7 @@
          try
          {
             int count = m.getIntProperty("count");
-            
+
             log.info("Listener " + i + " received message " + count);
          }
          catch (Exception e)
@@ -975,7 +988,12 @@
             e.printStackTrace();
          }
       }
-      
+
    }
+
+
+   // Inner classes -------------------------------------------------
+
    
+
 }

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/ServerManagement.java	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/ServerManagement.java	2006-12-07 19:15:49 UTC (rev 1717)
@@ -52,6 +52,8 @@
 {
    // Constants -----------------------------------------------------
 
+   public static final int MAX_SERVER_COUNT = 10;
+
    // logging levels used by the remote client to forward log output on a remote server
    public static int FATAL = 0;
    public static int ERROR = 1;
@@ -69,7 +71,7 @@
 
    private static final int RMI_SERVER_LOOKUP_RETRIES = 10;
 
-   private static Server[] servers = new Server[RMITestServer.RMI_REGISTRY_PORTS.length];
+   private static Server[] servers = new Server[MAX_SERVER_COUNT];
 
    public static boolean isLocal()
    {
@@ -541,12 +543,13 @@
     * Simulates a destination un-deployment (deleting the destination descriptor from the deploy
     * directory).
     */
-   private static void undeployDestination(boolean isQueue, String name, int serverIndex) throws Exception
+   private static void undeployDestination(boolean isQueue, String name, int serverIndex)
+      throws Exception
    {
       insureStarted(serverIndex);
       servers[serverIndex].undeployDestination(isQueue, name);
    }
-
+                                                                                                                
    public static void deployConnectionFactory(String objectName,
                                               String[] jndiBindings,
                                               int prefetchSize,
@@ -631,15 +634,19 @@
 
    private static Server acquireRemote(int initialRetries, int index)
    {
-      String name = "//localhost:" + RMITestServer.RMI_REGISTRY_PORTS[index] + "/" + RMITestServer.RMI_SERVER_NAME;
+      String name =
+         "//localhost:" + RMITestServer.DEFAULT_REGISTRY_PORT + "/" +
+         RMITestServer.RMI_SERVER_PREFIX + index;
+
       Server s = null;
       int retries = initialRetries;
+
       while(s == null && retries > 0)
       {
          int attempt = initialRetries - retries + 1;
          try
          {
-            log.info("trying to connect to the remote RMI server" +
+            log.info("trying to connect to the remote RMI server " + index + 
                      (attempt == 1 ? "" : ", attempt " + attempt));
             s = (Server)Naming.lookup(name);
             log.info("connected to the remote server");

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java	2006-12-07 19:15:49 UTC (rev 1717)
@@ -179,7 +179,6 @@
    private Server hsqldbServer;
 
    private boolean transaction;
-   private boolean cluster;
    private boolean database;
    private boolean jca;
    private boolean remotingSocket;
@@ -778,7 +777,7 @@
 
    public boolean isClustered()
    {
-      return cluster;
+      return config.isClustered();
    }
 
    public String toString()
@@ -1305,16 +1304,6 @@
             minus = true;
          }
 
-         if ("all-cluster".equals(tok))
-         {
-            cluster = true;
-            transaction = true;
-            database = true;
-            jca = true;
-            remotingSocket = true;
-            security = true;
-         }
-         else
          if ("all".equals(tok))
          {
             transaction = true;

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainerConfiguration.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainerConfiguration.java	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainerConfiguration.java	2006-12-07 19:15:49 UTC (rev 1717)
@@ -29,6 +29,8 @@
 {
    // Constants -----------------------------------------------------
 
+   public static final boolean DEFAULT_CLUSTERED_MODE = false;
+
    // Static --------------------------------------------------------
 
    public static String getHypersonicDatabase(String connectionURL)
@@ -74,6 +76,7 @@
    private String database;
    private Map dbConfigurations;
    private String serializationType;
+   private Boolean clusteredMode;
 
    // Constructors --------------------------------------------------
 
@@ -140,6 +143,14 @@
       return serializationType;
    }
 
+   /**
+    * @return the clustered mode in which the container should run an individual test.
+    */
+   public boolean isClustered()
+   {
+      return clusteredMode.booleanValue();
+   }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------
@@ -151,6 +162,7 @@
       Reader reader = new InputStreamReader(is);
       String currentDatabase = null;
       String currentSerializationType = null;
+      boolean currentClusteredMode = DEFAULT_CLUSTERED_MODE;
 
       try
       {
@@ -189,6 +201,10 @@
                {
                   currentSerializationType = XMLUtil.getTextContent(n);
                }
+               else if ("clustered".equals(name))
+               {
+                  currentClusteredMode = Boolean.getBoolean(XMLUtil.getTextContent(n));
+               }
                else
                {
                   throw new Exception("Unexpected child <" + name + "> of node " +
@@ -199,6 +215,7 @@
 
          setCurrentDatabase(currentDatabase);
          setCurrentSerializationType(currentSerializationType);
+         setCurrentClusteredMode(currentClusteredMode);
       }
       finally
       {
@@ -220,8 +237,8 @@
    }
 
    /**
-    * Always the value of "test.serialization" system property takes precedence over the c
-    * onfiguration file value.
+    * Always the value of "test.serialization" system property takes precedence over the
+    * configuration file value.
     */
    private void setCurrentSerializationType(String xmlConfigSerializationType)
    {
@@ -232,6 +249,24 @@
       }
    }
 
+   /**
+    * Always the value of "test.clustered" system property takes precedence over the configuration
+    * file value.
+    */
+   private void setCurrentClusteredMode(boolean xmlClusteredMode) throws Exception
+   {
+      String s = System.getProperty("test.clustered");
+      if (s != null)
+      {
+         clusteredMode = Boolean.valueOf(s);
+      }
+
+      if (clusteredMode == null)
+      {
+         clusteredMode = new Boolean(xmlClusteredMode);
+      }
+   }
+
    private void validate() throws Exception
    {
       // make sure that I have a corresponding "database-configuration"

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java	2006-12-07 19:15:49 UTC (rev 1717)
@@ -24,6 +24,7 @@
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
 import java.rmi.server.UnicastRemoteObject;
+import java.rmi.RemoteException;
 import java.util.Set;
 import javax.management.ObjectName;
 import javax.transaction.UserTransaction;
@@ -48,21 +49,21 @@
 {
    private static final long serialVersionUID = -368445344011004778L;
 
+   public static final int DEFAULT_REGISTRY_PORT = 22555;
+   public static final int DEFAULT_SERVER_INDEX = 0;
+   public static final String DEFAULT_SERVER_HOST = "localhost";
+
    private static final Logger log = Logger.getLogger(RMITestServer.class);
 
    protected RemoteTestServer server;
 
    private RMINamingDelegate namingDelegate;
+   private int index;
 
-   //public static final int RMI_REGISTRY_PORT = 25989;
-   
-   //We allow for up to 5 rmi test servers running simultaneously
-   public static final int[] RMI_REGISTRY_PORTS = 
-      new int[] {25989, 25990, 25991, 25992, 25993};
-   
-   public static final String RMI_SERVER_NAME = "messaging-rmi-server";
-   public static final String NAMING_SERVER_NAME = "naming-rmi-server";
 
+   public static final String RMI_SERVER_PREFIX = "messaging_rmi_server_";
+   public static final String NAMING_SERVER_PREFIX = "naming_rmi_server_";
+
    private static Registry registry;
    
    public static void main(String[] args) throws Exception
@@ -70,39 +71,50 @@
       log.debug("initializing RMI runtime");
 
       String host = System.getProperty("test.bind.address");
+
       if (host == null)
       {
-         host = "localhost";
+         host = DEFAULT_SERVER_HOST;
       }
 
-      log.info("bind address: " + host);
-      
-      int index;
-      String registryIndex = System.getProperty("test.registry.index");
-      if (registryIndex == null)
+      int serverIndex = DEFAULT_SERVER_INDEX;
+
+      String s = System.getProperty("test.server.index");
+
+      if (s != null)
       {
-         //Use the 0th port
-         index = 0;
+         serverIndex = Integer.parseInt(s);
       }
-      else
-      {
-         index = Integer.parseInt(registryIndex);         
-      }
-      int port = RMI_REGISTRY_PORTS[index];
 
+      log.info("RMI server " + serverIndex + ", bind address " + host);
+
+      RMITestServer testServer = new RMITestServer(serverIndex);
+      log.debug("RMI server " + serverIndex + " created");
+
       // let RMI know the bind address
       System.setProperty("java.rmi.server.hostname", host);
 
-      registry = LocateRegistry.createRegistry(port);
-      log.debug("registry created at port: " + port);
 
-      RMITestServer testServer = new RMITestServer(index);
-      log.debug("RMI server created");
+      // try to bind first
+      try
+      {
+         registry = LocateRegistry.getRegistry(DEFAULT_REGISTRY_PORT);
+         registry.bind(RMI_SERVER_PREFIX + serverIndex, testServer);
+         registry.bind(NAMING_SERVER_PREFIX + serverIndex, testServer.getNamingDelegate());
 
-      registry.bind(RMI_SERVER_NAME, testServer);
-      registry.bind(NAMING_SERVER_NAME, testServer.getNamingDelegate());
+      }
+      catch(Exception e)
+      {
+         log.info("Failure using an existing registry, trying creating it");
 
-      log.info("RMI server bound");
+         // try to create it
+         registry = LocateRegistry.createRegistry(DEFAULT_REGISTRY_PORT);
+
+         registry.bind(RMI_SERVER_PREFIX + serverIndex, testServer);
+         registry.bind(NAMING_SERVER_PREFIX + serverIndex, testServer.getNamingDelegate());
+      }
+
+      log.info("RMI server " + serverIndex + " bound");
    }
 
    public class VMKiller implements Runnable
@@ -126,8 +138,8 @@
 
    public RMITestServer(int index) throws Exception
    {
+      this.index = index;
       namingDelegate = new RMINamingDelegate();
-
       server = new RemoteTestServer(index);
    }
 
@@ -213,10 +225,10 @@
    {
       server.destroy();
 
-      registry.unbind(RMI_SERVER_NAME);
-      registry.unbind(NAMING_SERVER_NAME);
+      registry.unbind(RMI_SERVER_PREFIX + index);
+      registry.unbind(NAMING_SERVER_PREFIX + index);
       
-      //Now shutdown the process
+      // Now shutdown the process. The registry will be taken out with the last RMI server standing
       
       //TODO - we should shutdown cleanly - let main() exit - not kill the process
       

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java	2006-12-07 19:15:49 UTC (rev 1717)
@@ -51,20 +51,20 @@
       }
       
       int index;
-      String registryIndex = System.getProperty("test.registry.index");
-      if (registryIndex == null)
+
+      String serverIndex = System.getProperty("test.server.index");
+      if (serverIndex == null)
       {
-         //Use the 0th port
-         index = 0;
+         index = RMITestServer.DEFAULT_SERVER_INDEX;
       }
       else
       {
-         index = Integer.parseInt(registryIndex);         
+         index = Integer.parseInt(serverIndex);
       }
-      int port = RMITestServer.RMI_REGISTRY_PORTS[index];
 
       String name =
-         "//" + host + ":" + port + "/" + RMITestServer.RMI_SERVER_NAME;
+         "//" + host + ":" + RMITestServer.DEFAULT_REGISTRY_PORT + "/" +
+         RMITestServer.RMI_SERVER_PREFIX + index;
 
       log.info("Stopping " + name);
 
@@ -79,9 +79,12 @@
          return;
       }
 
-      //We should shut down cleanly - not kill the process like we are currently doing
+      // We should shut down cleanly - not kill the process like we are currently doing
       
       server.destroy();
+
+      // The last RMI server will take with it the registry too
+
       log.info("RMI server stopped");
 
    }

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java	2006-12-07 19:15:49 UTC (rev 1717)
@@ -53,7 +53,8 @@
    public RemoteContext(int remoteServerIndex) throws Exception
    {
       String n =
-         "//localhost:" + RMITestServer.RMI_REGISTRY_PORTS[remoteServerIndex] + "/" + RMITestServer.NAMING_SERVER_NAME;
+         "//localhost:" + RMITestServer.DEFAULT_REGISTRY_PORT + "/" +
+          RMITestServer.NAMING_SERVER_PREFIX + remoteServerIndex;
       
       log.info("Using this url for rmi server lookup " + n);
       

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java	2006-12-07 11:13:12 UTC (rev 1716)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java	2006-12-07 19:15:49 UTC (rev 1717)
@@ -42,9 +42,6 @@
 
    // Static --------------------------------------------------------
 
-   private static RemoteContext[] initialContexts =
-      new RemoteContext[RMITestServer.RMI_REGISTRY_PORTS.length];
-   
    /**
     * @return the JNDI environment to use to get this InitialContextFactory.
     */
@@ -71,29 +68,26 @@
    {
       String s = (String)environment.get(Constants.SERVER_INDEX_PROPERTY_NAME);
       
-      log.info("Created initial context for " + s);
-      
       if (s == null)
       {
          throw new IllegalArgumentException("Initial context environment must contain " +
                                             "entry for " + Constants.SERVER_INDEX_PROPERTY_NAME);
       }
-      
+
+      log.info("Created initial context for " + s);
+
       int remoteServerIndex = Integer.parseInt(s);
-      
-      if (initialContexts[remoteServerIndex] == null)
+
+      try
       {
-         try
-         {
-            initialContexts[remoteServerIndex] = new RemoteContext(remoteServerIndex);
-         }
-         catch(Exception e)
-         {
-            log.error("Cannot get the remote context", e);
-            throw new NamingException("Cannot get the remote context");
-         }
+         return new RemoteContext(remoteServerIndex);
       }
-      return initialContexts[remoteServerIndex];
+      catch(Exception e)
+      {
+         log.error("Cannot get the remote context", e);
+         throw new NamingException("Cannot get the remote context");
+      }
+
    }
 
    // Package protected ---------------------------------------------




More information about the jboss-cvs-commits mailing list