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

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


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

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/ReconnectTest.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-519 - working with stateTransfer between new and old connection

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 23:47:02 UTC (rev 1470)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/HATestBase.java	2006-10-11 23:48:10 UTC (rev 1471)
@@ -29,6 +29,8 @@
 import javax.naming.Context;
 import java.util.Properties;
 
+import org.jboss.logging.Logger;
+
 /**
  * Define HOST1 and HOST2 as System variable (java -DHOST1=YourHost -DHOST2=YourHost2) pointing to a JBoss instance
  * with JBossMessaging installed.
@@ -38,6 +40,9 @@
  */
 public abstract class HATestBase extends TestCase
 {
+
+    protected Logger log = Logger.getLogger(getClass());
+
     protected ConnectionFactory factoryServer1;
     protected ConnectionFactory factoryServer2;
 

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 23:47:02 UTC (rev 1470)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/ReconnectTest.java	2006-10-11 23:48:10 UTC (rev 1471)
@@ -1,8 +1,12 @@
 package org.jboss.test.messaging.jms.ha;
 
 import org.jboss.jms.client.JBossConnection;
+import org.jboss.jms.client.JBossSession;
+import org.jboss.jms.client.remoting.JMSRemotingConnection;
 import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.jms.client.state.SessionState;
 import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+import org.jboss.jms.client.delegate.ClientSessionDelegate;
 
 import javax.jms.*;
 
@@ -81,4 +85,54 @@
         message = session.createTextMessage("Hello After");
         producer.send(message);
     }
+
+    public void testSimpleWithOneProducerTransacted() throws Exception
+    {
+        log.info("++testSimpleWithOneProducerTransacted");
+        JBossConnection  conn = (JBossConnection)this.factoryServer1.createConnection();
+
+        log.info("ConnectionCreated=" + conn);
+
+        log.info(">>Creating Sessions");
+
+        JBossSession session = (JBossSession)conn.createSession(true,Session.AUTO_ACKNOWLEDGE);
+        ClientSessionDelegate clientSessionDelegate = (ClientSessionDelegate)session.getDelegate();
+        SessionState sessionState = (SessionState)clientSessionDelegate.getState();
+        Object txID = sessionState.getCurrentTxId();
+        log.info(">>Lookup Queue");
+        Destination destination = (Destination)getCtx1().lookup("queue/testQueue");
+        log.info(">>Creating Producer");
+        MessageProducer producer = session.createProducer(destination);
+        log.info(">>creating Message");
+        Message message = session.createTextMessage("Hello Before");
+        log.info(">>Sending Message");
+        producer.send(message);
+
+        ClientConnectionDelegate delegate = (ClientConnectionDelegate)conn.getDelegate();
+
+        JMSRemotingConnection originalRemoting = delegate.getRemotingConnection();
+
+        ConnectionState state = (ConnectionState)delegate.getState();
+
+        log.info(">>Creating alternate connection");
+
+        JBossConnection conn2 = (JBossConnection)this.factoryServer2.createConnection();
+        log.info("NewConnectionCreated=" + conn2);
+
+        log.info(">>Failling over");
+        assertSame(originalRemoting,delegate.getRemotingConnection());
+        conn.getDelegate().failOver(conn2.getDelegate());
+        assertNotSame(originalRemoting,delegate.getRemotingConnection());
+
+        //System.out.println("Kill server1"); Thread.sleep(10000);
+
+        message = session.createTextMessage("Hello After");
+        log.info(">>Sending new message");
+        producer.send(message);
+
+        assertEquals(txID,sessionState.getCurrentTxId());
+        System.out.println("TransactionID on client = " + txID);
+        log.info(">>Final commit");
+        session.commit();
+    }
 }




More information about the jboss-cvs-commits mailing list