[jboss-cvs] JBoss Messaging SVN: r1469 - in branches/Branch_Client_Failover_Experiment/tests: bin src/org/jboss/test/messaging/jms/ha

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Oct 11 15:48:26 EDT 2006


Author: clebert.suconic at jboss.com
Date: 2006-10-11 15:48:23 -0400 (Wed, 11 Oct 2006)
New Revision: 1469

Modified:
   branches/Branch_Client_Failover_Experiment/tests/bin/runtest
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/HATestBase.java
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/ReconnectTest.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-519 - working with Producers and ConnectionState for connection recreation

Modified: branches/Branch_Client_Failover_Experiment/tests/bin/runtest
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/bin/runtest	2006-10-11 19:46:37 UTC (rev 1468)
+++ branches/Branch_Client_Failover_Experiment/tests/bin/runtest	2006-10-11 19:48:23 UTC (rev 1469)
@@ -43,7 +43,7 @@
 # it from there.
 #
 
-ant -Dtest.execution.classpath.file=bin/.test.execution.classpath -f $reldir/../build.xml get-test-execution-classpath
+ant -Dtest.execution.classpath.file=bin/.test.execution.classpath -f $reldir/../build.xml compile get-test-execution-classpath
 CLASSPATH=`cat $reldir/.test.execution.classpath`
 
 outputdir="$reldir/../output"
@@ -94,7 +94,7 @@
     shift
 done
 
-JAVA_OPTS="-Xmx1024M $JAVA_OPTS -Dmodule.output=$reldir/../output $REMOTE_TEST -Dtest.database=$TEST_DATABASE -Dtest.serialization=$TEST_SERIALIZATION -Dbuild.lib=../../output/lib"
+JAVA_OPTS="-Xmx1024M $JAVA_OPTS -Dmodule.output=$reldir/../output $REMOTE_TEST -Dtest.database=$TEST_DATABASE -Dtest.serialization=$TEST_SERIALIZATION -Dbuild.lib=../../output/lib -DNODE1=10.1.5.1 -DNODE2=10.1.5.2"
 
 if [ "$TARGET_TEST" != "" ]; then
    TARGET_TEST="-t $TARGET_TEST"

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/HATestBase.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/HATestBase.java	2006-10-11 19:46:37 UTC (rev 1468)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/HATestBase.java	2006-10-11 19:48:23 UTC (rev 1469)
@@ -45,16 +45,19 @@
     protected Context ctx2;
 
 
-    protected String host1=System.getProperty("HOST1","localhost");
-    protected String host2=System.getProperty("HOST2","localhost");
+    protected String NODE1 =System.getProperty("NODE1","localhost");
+    protected String NODE2 =System.getProperty("NODE2","localhost");
 
     public void setUp() throws Exception
     {
         super.setUp();
 
-        ctx1 = getContext(host1);
-        ctx2 = getContext(host2);
+        System.out.println("Server1=" + NODE1);
+        System.out.println("Server2=" + NODE2);
 
+        ctx1 = getContext(NODE1);
+        ctx2 = getContext(NODE2);
+
         factoryServer1 = (ConnectionFactory)ctx1.lookup("/ConnectionFactory");
         factoryServer2 = (ConnectionFactory)ctx2.lookup("/ConnectionFactory");
     }
@@ -82,12 +85,12 @@
         return factoryServer2;
     }
 
-    protected String getHost1() {
-        return host1;
+    protected String getNODE1() {
+        return NODE1;
     }
 
-    protected String getHost2() {
-        return host2;
+    protected String getNODE2() {
+        return NODE2;
     }
 
     public Context getCtx1() {

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/ReconnectTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/ReconnectTest.java	2006-10-11 19:46:37 UTC (rev 1468)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/ReconnectTest.java	2006-10-11 19:48:23 UTC (rev 1469)
@@ -15,10 +15,41 @@
         ClientConnectionDelegate delegate = (ClientConnectionDelegate)conn.getDelegate();
         ConnectionState state = (ConnectionState)delegate.getState();
 
+        assertFalse(state.isStarted());
+        conn.start();
+        assertTrue(state.isStarted());
+
         JBossConnection conn2 = (JBossConnection)this.factoryServer1.createConnection();
         conn.getDelegate().failOver(conn2.getDelegate());
+
+        conn.stop();
+        assertFalse(state.isStarted());
+
     }
 
+    public void testSimpleReconnectWithClientID() throws Exception
+    {
+        JBossConnection  conn = (JBossConnection)this.factoryServer1.createConnection();
+        conn.setClientID("someClient");
+        ClientConnectionDelegate delegate = (ClientConnectionDelegate)conn.getDelegate();
+        ConnectionState state = (ConnectionState)delegate.getState();
+
+        assertFalse(state.isStarted());
+        conn.start();
+        assertTrue(state.isStarted());
+
+        JBossConnection conn2 = (JBossConnection)this.factoryServer1.createConnection();
+        conn.getDelegate().failOver(conn2.getDelegate());
+
+        // force recovering the clientID from server
+        state.setClientID(null);
+        assertEquals ("someClient",conn.getClientID());
+
+        conn.stop();
+        assertFalse(state.isStarted());
+
+    }
+
     public void testWithSession() throws Exception
     {
         JBossConnection  conn = (JBossConnection)this.factoryServer1.createConnection();
@@ -34,20 +65,20 @@
     public void testSimpleWithOneProducer() throws Exception
     {
         JBossConnection  conn = (JBossConnection)this.factoryServer1.createConnection();
-        Session session = conn.createSession(true,Session.AUTO_ACKNOWLEDGE);
-        Destination destination = (Destination)getCtx1().lookup("topic/testTopic");
+        Session session = conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
+        Destination destination = (Destination)getCtx1().lookup("queue/testQueue");
         MessageProducer producer = session.createProducer(destination);
 
-        Message message = session.createTextMessage("Hello");
+        Message message = session.createTextMessage("Hello Before");
         producer.send(message);
 
         ClientConnectionDelegate delegate = (ClientConnectionDelegate)conn.getDelegate();
         ConnectionState state = (ConnectionState)delegate.getState();
 
-        JBossConnection conn2 = (JBossConnection)this.factoryServer1.createConnection();
+        JBossConnection conn2 = (JBossConnection)this.factoryServer2.createConnection();
         conn.getDelegate().failOver(conn2.getDelegate());
 
-        message = session.createTextMessage("Hello");
+        message = session.createTextMessage("Hello After");
         producer.send(message);
     }
 }




More information about the jboss-cvs-commits mailing list