[jboss-cvs] JBoss Messaging SVN: r1472 - in branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging: core core/ha jms
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 12 11:47:07 EDT 2006
Author: clebert.suconic at jboss.com
Date: 2006-10-12 11:47:04 -0400 (Thu, 12 Oct 2006)
New Revision: 1472
Added:
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/HATestBase.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/ReconnectTest.java
Removed:
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/HATestBase.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/ReconnectTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-519 - moving package under core.ha
Copied: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha (from rev 1465, branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha)
Deleted: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/HATestBase.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/HATestBase.java 2006-10-10 22:14:54 UTC (rev 1465)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/HATestBase.java 2006-10-12 15:47:04 UTC (rev 1472)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.messaging.jms.ha;
-
-import junit.framework.TestCase;
-
-import javax.jms.ConnectionFactory;
-import javax.naming.InitialContext;
-import javax.naming.Context;
-import java.util.Properties;
-
-/**
- * Define HOST1 and HOST2 as System variable (java -DHOST1=YourHost -DHOST2=YourHost2) pointing to a JBoss instance
- * with JBossMessaging installed.
- * This can usually be done using util scripts to deploy a JBoss instance.
- *
- * @author Clebert Suconic
- */
-public abstract class HATestBase extends TestCase
-{
- protected ConnectionFactory factoryServer1;
- protected ConnectionFactory factoryServer2;
-
-
- protected String host1=System.getProperty("HOST1","localhost");
- protected String host2=System.getProperty("HOST2","localhost");
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- Context ctx1 = getContext(host1);
- Context ctx2 = getContext(host2);
-
- factoryServer1 = (ConnectionFactory)ctx1.lookup("/ConnectionFactory");
- factoryServer2 = (ConnectionFactory)ctx2.lookup("/ConnectionFactory");
- }
-
- protected Context getContext(String host) throws Exception
- {
- // don't worry about this yet, we will put this in more generic way.
- // This is for test purposes only.
- String jndiProviderClass = "org.jnp.interfaces.NamingContextFactory";
- Properties contextProperties = new Properties();
- contextProperties.put(Context.INITIAL_CONTEXT_FACTORY,
- jndiProviderClass);
- contextProperties.put(Context.PROVIDER_URL,
- "jnp://"+ host + ":1099");
- return new InitialContext(contextProperties);
-
- }
-
-
- protected ConnectionFactory getFactoryServer1() {
- return factoryServer1;
- }
-
- protected ConnectionFactory getFactoryServer2() {
- return factoryServer2;
- }
-
- protected String getHost1() {
- return host1;
- }
-
- protected String getHost2() {
- return host2;
- }
-
-
-}
Copied: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/HATestBase.java (from rev 1471, 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:48:10 UTC (rev 1471)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/HATestBase.java 2006-10-12 15:47:04 UTC (rev 1472)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.messaging.core.ha;
+
+import junit.framework.TestCase;
+
+import javax.jms.ConnectionFactory;
+import javax.naming.InitialContext;
+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.
+ * This can usually be done using util scripts to deploy a JBoss instance.
+ *
+ * @author Clebert Suconic
+ */
+public abstract class HATestBase extends TestCase
+{
+
+ protected Logger log = Logger.getLogger(getClass());
+
+ protected ConnectionFactory factoryServer1;
+ protected ConnectionFactory factoryServer2;
+
+ protected Context ctx1;
+ protected Context ctx2;
+
+
+ protected String NODE1 =System.getProperty("NODE1","localhost");
+ protected String NODE2 =System.getProperty("NODE2","localhost");
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ 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");
+ }
+
+ protected Context getContext(String host) throws Exception
+ {
+ // don't worry about this yet, we will put this in more generic way.
+ // This is for test purposes only.
+ String jndiProviderClass = "org.jnp.interfaces.NamingContextFactory";
+ Properties contextProperties = new Properties();
+ contextProperties.put(Context.INITIAL_CONTEXT_FACTORY,
+ jndiProviderClass);
+ contextProperties.put(Context.PROVIDER_URL,
+ "jnp://"+ host + ":1099");
+ return new InitialContext(contextProperties);
+
+ }
+
+
+ protected ConnectionFactory getFactoryServer1() {
+ return factoryServer1;
+ }
+
+ protected ConnectionFactory getFactoryServer2() {
+ return factoryServer2;
+ }
+
+ protected String getNODE1() {
+ return NODE1;
+ }
+
+ protected String getNODE2() {
+ return NODE2;
+ }
+
+ public Context getCtx1() {
+ return ctx1;
+ }
+
+ public Context getCtx2() {
+ return ctx2;
+ }
+
+}
Deleted: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/ReconnectTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/ReconnectTest.java 2006-10-10 22:14:54 UTC (rev 1465)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/ReconnectTest.java 2006-10-12 15:47:04 UTC (rev 1472)
@@ -1,35 +0,0 @@
-package org.jboss.test.messaging.jms.ha;
-
-import org.jboss.jms.client.JBossConnection;
-import org.jboss.jms.client.state.ConnectionState;
-import org.jboss.jms.client.delegate.ClientConnectionDelegate;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.Session;
-
-public class ReconnectTest extends HATestBase
-{
-
- public void testSimpleReconnect() throws Exception
- {
- JBossConnection conn = (JBossConnection)this.factoryServer1.createConnection();
- ClientConnectionDelegate delegate = (ClientConnectionDelegate)conn.getDelegate();
- ConnectionState state = (ConnectionState)delegate.getState();
-
- JBossConnection conn2 = (JBossConnection)this.factoryServer1.createConnection();
- conn.getDelegate().failOver(conn2.getDelegate());
- }
-
- public void testSimpleWithSession() throws Exception
- {
- JBossConnection conn = (JBossConnection)this.factoryServer1.createConnection();
- Session session = conn.createSession(true,Session.AUTO_ACKNOWLEDGE);
-
- ClientConnectionDelegate delegate = (ClientConnectionDelegate)conn.getDelegate();
- ConnectionState state = (ConnectionState)delegate.getState();
-
- JBossConnection conn2 = (JBossConnection)this.factoryServer1.createConnection();
- conn.getDelegate().failOver(conn2.getDelegate());
- }
-}
Copied: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/ReconnectTest.java (from rev 1471, 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:48:10 UTC (rev 1471)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/ha/ReconnectTest.java 2006-10-12 15:47:04 UTC (rev 1472)
@@ -0,0 +1,138 @@
+package org.jboss.test.messaging.core.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.*;
+
+public class ReconnectTest extends HATestBase
+{
+
+ public void testSimpleReconnect() throws Exception
+ {
+ JBossConnection conn = (JBossConnection)this.factoryServer1.createConnection();
+ 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();
+ Session session = conn.createSession(true,Session.AUTO_ACKNOWLEDGE);
+
+ ClientConnectionDelegate delegate = (ClientConnectionDelegate)conn.getDelegate();
+ ConnectionState state = (ConnectionState)delegate.getState();
+
+ JBossConnection conn2 = (JBossConnection)this.factoryServer1.createConnection();
+ conn.getDelegate().failOver(conn2.getDelegate());
+ }
+
+ public void testSimpleWithOneProducer() throws Exception
+ {
+ JBossConnection conn = (JBossConnection)this.factoryServer1.createConnection();
+ 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 Before");
+ producer.send(message);
+
+ ClientConnectionDelegate delegate = (ClientConnectionDelegate)conn.getDelegate();
+ ConnectionState state = (ConnectionState)delegate.getState();
+
+ JBossConnection conn2 = (JBossConnection)this.factoryServer2.createConnection();
+ conn.getDelegate().failOver(conn2.getDelegate());
+
+ 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