[jboss-cvs] JBoss Messaging SVN: r1465 - in 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
Tue Oct 10 18:14:56 EDT 2006
Author: clebert.suconic at jboss.com
Date: 2006-10-10 18:14:54 -0400 (Tue, 10 Oct 2006)
New Revision: 1465
Added:
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/
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 - experiments
Added: 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-10 22:10:13 UTC (rev 1464)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/HATestBase.java 2006-10-10 22:14:54 UTC (rev 1465)
@@ -0,0 +1,91 @@
+/*
+ * 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;
+ }
+
+
+}
Added: 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-10 22:10:13 UTC (rev 1464)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ha/ReconnectTest.java 2006-10-10 22:14:54 UTC (rev 1465)
@@ -0,0 +1,35 @@
+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());
+ }
+}
More information about the jboss-cvs-commits
mailing list