[jboss-cvs] JBoss Messaging SVN: r1520 - in trunk/tests: . src/org/jboss/test/messaging/jms src/org/jboss/test/messaging/jms/clustering src/org/jboss/test/messaging/jms/crash src/org/jboss/test/messaging/jms/manual src/org/jboss/test/messaging/jms/server 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
Fri Oct 27 13:23:15 EDT 2006
Author: timfox
Date: 2006-10-27 13:23:03 -0400 (Fri, 27 Oct 2006)
New Revision: 1520
Added:
trunk/tests/src/org/jboss/test/messaging/jms/clustering/
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java
Removed:
trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java
Modified:
trunk/tests/build.xml
trunk/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashLargeLeaseTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashNegativeLeaseTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTwoConnectionsTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashZeroLeaseTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java
trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RemoteTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
Log:
http://jira.jboss.com/jira/browse/JBMESSAGING-581
Modified: trunk/tests/build.xml
===================================================================
--- trunk/tests/build.xml 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/build.xml 2006-10-27 17:23:03 UTC (rev 1520)
@@ -67,6 +67,9 @@
<property name="stress.tests.database" value="mysql"/>
<property name="stress.tests.serialization" value="jms"/>
+ <!-- Clustering tests -->
+ <property name="clustering.tests.database" value="mysql"/>
+
<!--
Project paths.
-->
@@ -134,7 +137,7 @@
JDBC Drivers.
-->
<path id="any.jdbc.driver.classpath">
- <fileset dir="${tests.root}/lib/jdbc-drivers" includes="*.jar"/>
+ <fileset dir="${tests.root}/lib/jdbc-drivers" includes="*.jar"/>
</path>
@@ -274,6 +277,23 @@
</java>
</target>
+ <target name="start-rmi-server-clustering" depends="init"
+ 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="module.output" value="${tests.output}"/>
+ <sysproperty key="remote.test.suffix" value="-remote"/>
+ <sysproperty key="test.bind.address" value="${test.bind.address}"/>
+ <sysproperty key="test.database" value="${clustering.tests.database}"/>
+ <sysproperty key="test.serialization" value="${functional.tests.serialization}"/>
+ <!--
+ <jvmarg line="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=rmiserver"/>
+ -->
+ <classpath refid="test.execution.classpath"/>
+ </java>
+ </target>
+
<target name="start-rmi-server-stress" depends="init"
description="Starts the RMI server used by remote stress tests">
@@ -295,6 +315,14 @@
classpathref="test.execution.classpath"/>
</target>
+ <target name="stop-rmi-server-clustering" depends="init"
+ 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}"/>
+ </java>
+ </target>
+
<!-- ======================================================================================== -->
<!-- Test Execution Tasks -->
<!-- ======================================================================================== -->
@@ -349,6 +377,7 @@
<exclude name="**/jms/crash/*Test.class"/>
<exclude name="**/jms/MemLeakTest.class"/>
<exclude name="**/jms/manual/**/*Test.class"/>
+ <exclude name="**/jms/clustering/*Test.class"/>
</fileset>
</batchtest>
</junit>
@@ -421,11 +450,11 @@
haltonerror="${junit.batchtest.haltonerror}">
<formatter type="plain" usefile="${junit.formatter.usefile}"/>
<fileset dir="${build.tests.classes}">
- <!-- <include name="org/jboss/test/messaging/jms/JMSTest.class"/> -->
<include name="**/messaging/jms/ReferenceableTest.class"/>
<exclude name="**/jms/stress/**"/>
<exclude name="**/jms/crash/*Test.class"/>
<exclude name="**/jms/MemLeakTest.class"/>
+ <exclude name="**/jms/clustering/*Test.class"/>
</fileset>
</batchtest>
</junit>
@@ -461,7 +490,6 @@
haltonerror="${junit.batchtest.haltonerror}">
<formatter type="plain" usefile="${junit.formatter.usefile}"/>
<fileset dir="${build.tests.classes}">
- <!-- <include name="**/jms/stress/**/*Test.class"/> -->
<include name="**/jms/stress/StressTest.class"/>
</fileset>
</batchtest>
@@ -523,20 +551,18 @@
haltonerror="${junit.batchtest.haltonerror}">
<formatter type="plain" usefile="${junit.formatter.usefile}"/>
<fileset dir="${build.tests.classes}">
- <!--
- <include name="org/jboss/test/messaging/jms/JMSTest.class"/>
- -->
- <include name="org/jboss/test/messaging/jms/**/*Test.class"/>
- <exclude name="org/jboss/test/messaging/jms/stress/**"/>
- <exclude name="org/jboss/test/messaging/jms/server/**"/>
- <exclude name="org/jboss/test/messaging/jms/persistence/**"/>
- <exclude name="org/jboss/test/messaging/jms/ReferencingTest.class"/>
- <exclude name="org/jboss/test/messaging/jms/PersistenceTest.class"/>
- <exclude name="org/jboss/test/messaging/jms/crash/*Test.class"/>
- <exclude name="org/jboss/test/messaging/jms/MemLeakTest.class"/>
- <exclude name="org/jboss/test/messaging/jms/ManifestTest.class"/>
- <exclude name="org/jboss/test/messaging/jms/JCAWrapperTest.class"/>
+ <include name="**/jms/**/*Test.class"/>
+ <exclude name="**/jms/stress/**"/>
+ <exclude name="**/jms/server/**"/>
+ <exclude name="**/jms/persistence/**"/>
+ <exclude name="**/jms/ReferencingTest.class"/>
+ <exclude name="**/jms/PersistenceTest.class"/>
+ <exclude name="**/jms/crash/*Test.class"/>
+ <exclude name="**/jms/MemLeakTest.class"/>
+ <exclude name="**/jms/ManifestTest.class"/>
+ <exclude name="**/jms/JCAWrapperTest.class"/>
<exclude name="**/jms/manual/**/*Test.class"/>
+ <exclude name="**/jms/clustering/*Test.class"/>
</fileset>
</batchtest>
</junit>
@@ -601,6 +627,100 @@
</target>
+ <target name="clustering-tests" depends="tests-jar, prepare-testdirs, clear-test-logs"
+ description="Runs the clustering tests">
+
+ <!-- Stop the rmi servers in case a previous run aborted -->
+
+ <antcall target="stop-rmi-server-clustering">
+ <param name="test.registry.index" value="0"/>
+ </antcall>
+ <antcall target="stop-rmi-server-clustering">
+ <param name="test.registry.index" value="1"/>
+ </antcall>
+ <antcall target="stop-rmi-server-clustering">
+ <param name="test.registry.index" value="2"/>
+ </antcall>
+
+ <!-- Start 3 rmi servers -->
+
+ <antcall target="start-rmi-server-clustering">
+ <param name="test.registry.index" value="0"/>
+ </antcall>
+ <antcall target="start-rmi-server-clustering">
+ <param name="test.registry.index" value="1"/>
+ </antcall>
+ <antcall target="start-rmi-server-clustering">
+ <param name="test.registry.index" value="2"/>
+ </antcall>
+
+ <mkdir dir="${build.tests.reports}"/>
+
+ <echo message=""/>
+ <echo message="Running clustering tests, fork=${junit.fork}, junit.batchtest.fork=${junit.batchtest.fork}"/>
+ <echo message=""/>
+
+ <junit printsummary="${junit.printsummary}"
+ fork="${junit.fork}"
+ includeantruntime="yes"
+ haltonerror="${junit.haltonerror}"
+ haltonfailure="${junit.haltonfailure}"
+ showoutput="${junit.showoutput}"
+ timeout="${junit.timeout}">
+
+ <sysproperty key="remote" value="true"/>
+ <sysproperty key="module.output" value="${tests.output}"/>
+ <sysproperty key="test.bind.address" value="${test.bind.address}"/>
+ <sysproperty key="test.database" value="${clustering.tests.database}"/>
+ <sysproperty key="test.serialization" value="${functional.tests.serialization}"/>
+ <jvmarg value="-Xmx512M"/>
+ <!--
+ <jvmarg line="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=antjunit"/>
+ -->
+ <classpath>
+ <path refid="test.execution.classpath"/>
+
+ <!-- Add this when http://jira.jboss.org/jira/browse/JBAS-2554 is done -->
+ <!--
+ <path refid="jboss.test.classpath"/>
+ -->
+ </classpath>
+
+ <!-- Use this when http://jira.jboss.org/jira/browse/JBAS-2554 is done -->
+ <!--
+ <sysproperty key="jboss-junit-configuration" value="Remote"/>
+ <formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
+ usefile="${junit.formatter.usefile}" extension="-Remote.xml"/>
+ -->
+
+ <sysproperty key="messaging-test-configuration" value="Clustering"/>
+ <formatter classname="org.jboss.test.messaging.tools.ant.XMLJUnitMultipleResultFormatter"
+ usefile="${junit.formatter.usefile}" extension="-Clustering.xml"/>
+
+ <batchtest fork="${junit.batchtest.fork}"
+ todir="${junit.batchtest.todir}"
+ haltonfailure="${junit.batchtest.haltonfailure}"
+ haltonerror="${junit.batchtest.haltonerror}">
+ <formatter type="plain" usefile="${junit.formatter.usefile}"/>
+ <fileset dir="${build.tests.classes}">
+ <include name="**/jms/clustering/*Test.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+
+ <antcall target="stop-rmi-server-clustering">
+ <param name="test.registry.index" value="0"/>
+ </antcall>
+ <antcall target="stop-rmi-server-clustering">
+ <param name="test.registry.index" value="1"/>
+ </antcall>
+ <antcall target="stop-rmi-server-clustering">
+ <param name="test.registry.index" value="2"/>
+ </antcall>
+
+ </target>
+
+
<target name="crash-tests" depends="tests-jar, prepare-testdirs, clear-test-logs"
description="Runs crash tests">
@@ -724,6 +844,7 @@
<include name="**/messaging/jms/**/*Test.class"/>
<exclude name="**/jms/stress/**"/>
<exclude name="org/jboss/test/messaging/jms/ManifestTest.class"/>
+ <exclude name="**/jms/clustering/*Test.class"/>
</fileset>
</batchtest>
</junit>
Copied: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java (from rev 1519, trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -0,0 +1,1158 @@
+/*
+ * 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.clustering;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+
+/**
+ *
+ * A ManualClusteringTest
+ *
+ * Nodes must be started up in order node1, node2, node3
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ManualClusteringTest extends MessagingTestCase
+{
+ protected Context ic1;
+
+ protected Context ic2;
+
+ protected Context ic3;
+
+ protected Queue queue1;
+
+ protected Topic topic1;
+
+ protected Queue queue2;
+
+ protected Topic topic2;
+
+ protected Queue queue3;
+
+ protected Topic topic3;
+
+ protected ConnectionFactory cf1;
+
+ protected ConnectionFactory cf2;
+
+ protected ConnectionFactory cf3;
+
+ public ManualClusteringTest(String name)
+ {
+ super(name);
+ }
+
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ try
+ {
+
+ ServerManagement.start("all", 0, true);
+
+ ServerManagement.start("all", 1, true);
+
+ ServerManagement.start("all", 2, true);
+
+ ServerManagement.deployClusteredQueue("testDistributedQueue", 0);
+ ServerManagement.deployClusteredTopic("testDistributedTopic", 0);
+
+ ServerManagement.deployClusteredQueue("testDistributedQueue", 1);
+ ServerManagement.deployClusteredTopic("testDistributedTopic", 1);
+
+ ServerManagement.deployClusteredQueue("testDistributedQueue", 2);
+ ServerManagement.deployClusteredTopic("testDistributedTopic", 2);
+
+ ic1 = new InitialContext(ServerManagement.getJNDIEnvironment(0));
+
+ ic2 = new InitialContext(ServerManagement.getJNDIEnvironment(1));
+
+ ic3 = new InitialContext(ServerManagement.getJNDIEnvironment(2));
+
+ queue1 = (Queue)ic1.lookup("queue/testDistributedQueue");
+
+ queue2 = (Queue)ic2.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");
+
+ cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
+
+ cf2 = (ConnectionFactory)ic2.lookup("/ConnectionFactory");
+
+ cf3 = (ConnectionFactory)ic3.lookup("/ConnectionFactory");
+
+ drainQueues();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ try
+ {
+ super.tearDown();
+
+ ServerManagement.undeployQueue("testDistributedQueue", 0);
+ ServerManagement.undeployTopic("testDistributedTopic", 0);
+
+ ServerManagement.undeployQueue("testDistributedQueue", 1);
+ ServerManagement.undeployTopic("testDistributedTopic", 1);
+
+ ServerManagement.undeployQueue("testDistributedQueue", 2);
+ ServerManagement.undeployTopic("testDistributedTopic", 2);
+
+ ic1.close();
+
+ ic2.close();
+
+ ic3.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected void drainQueues() 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();
+
+ Message msg = null;
+
+ do
+ {
+ msg = cons1.receive(1000);
+ }
+ while (msg != null);
+
+ do
+ {
+ msg = cons2.receive(1000);
+ }
+ while (msg != null);
+
+ do
+ {
+ msg = cons3.receive(1000);
+ }
+ while (msg != null);
+ }
+ finally
+ {
+ if (conn1 != null) conn1.close();
+
+ if (conn2 != null) conn2.close();
+
+ if (conn3 != null) conn3.close();
+ }
+ }
+
+
+ public void testClusteredQueueLocalConsumerNonPersistent() throws Exception
+ {
+ 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);
+ }
+
+
+
+
+ /*
+ * Create a consumer on each queue on each node.
+ * Send messages in turn from all nodes.
+ * Ensure that the local consumer gets the message
+ */
+ 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);
+ }
+ 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.
+ * Ensure all messages are receive as appropriate
+ */
+ public 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());
+ }
+
+ 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
+ {
+ 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)
+ {
+ tm.setStringProperty("COLOUR", "red");
+ }
+ else if (c == 1)
+ {
+ 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());
+ }
+
+ 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
+ {
+ 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
+ {
+ sess1.unsubscribe("sub1");
+ }
+ catch (Exception ignore) {}
+ try
+ {
+ sess2.unsubscribe("sub2");
+ }
+ catch (Exception ignore) {}
+ try
+ {
+ sess3.unsubscribe("sub3");
+ }
+ catch (Exception ignore) {}
+ try
+ {
+ sess1.unsubscribe("sub4");
+ }
+ catch (Exception ignore) {}
+ 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());
+ }
+
+ 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
+ {
+ sess1.unsubscribe("sub1");
+ }
+ catch (Exception ignore) {}
+ try
+ {
+ sess2.unsubscribe("sub1");
+ }
+ catch (Exception ignore) {}
+ 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);
+
+ 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
+ * note that this test assumes round robin
+ */
+ 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
+ {
+ sess2.unsubscribe("sub1");
+ }
+ catch (Exception ignore) {}
+ 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();
+ }
+ }
+
+ class MyListener implements MessageListener
+ {
+ private int i;
+
+ MyListener(int i)
+ {
+ this.i = i;
+ }
+
+ public void onMessage(Message m)
+ {
+ try
+ {
+ int count = m.getIntProperty("count");
+
+ log.info("Listener " + i + " received message " + count);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -78,9 +78,9 @@
localServer = new LocalTestServer();
//Start all the services locally
- localServer.start("all");
+ localServer.start("all", false);
- localServer.deployQueue("Queue", null);
+ localServer.deployQueue("Queue", null, false);
//Connect to the remote server, but don't start a servicecontainer on it
//We are only using the remote server to open a client connection to the local server
@@ -121,7 +121,7 @@
String remotingSessionId = (String)remoteServer.executeCommand(command);
- remoteServer.exit();
+ remoteServer.destroy();
//we have removed the exception listener so the server side resouces shouldn't be cleared up
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashLargeLeaseTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashLargeLeaseTest.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashLargeLeaseTest.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -74,11 +74,11 @@
localServer = new LocalTestServer();
// Start all the services locally
- localServer.start("all");
+ localServer.start("all", false);
localServer.setAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "LeasePeriod", "30000");
- localServer.deployQueue("Queue", null);
+ localServer.deployQueue("Queue", null, false);
// Connect to the remote server, but don't start a servicecontainer on it. We are only using
// the remote server to open a client connection to the local server.
@@ -116,7 +116,7 @@
// Now we should have a client connection from the remote server to the local server
- remoteServer.exit();
+ remoteServer.destroy();
log.trace("killed remote server");
// Wait for connection resources to be cleared up
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashNegativeLeaseTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashNegativeLeaseTest.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashNegativeLeaseTest.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -74,14 +74,13 @@
localServer = new LocalTestServer();
// Start all the services locally
- localServer.start("all");
+ localServer.start("all", false);
-
//Set lease period to -1 --> this should disable leasing so the state won't be cleared up
localServer.setAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "LeasePeriod", "-1");
- localServer.deployQueue("Queue", null);
+ localServer.deployQueue("Queue", null, false);
// Connect to the remote server, but don't start a servicecontainer on it. We are only using
// the remote server to open a client connection to the local server.
@@ -119,7 +118,7 @@
// Now we should have a client connection from the remote server to the local server
- remoteServer.exit();
+ remoteServer.destroy();
log.trace("killed remote server");
// Wait for connection resources to be cleared up
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTest.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTest.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -74,16 +74,15 @@
localServer = new LocalTestServer();
// Start all the services locally
- localServer.start("all");
+ localServer.start("all", false);
-
// This crash test is relying on a precise value of LeaseInterval, so we don't rely on
// the default, whatever that is ...
localServer.setAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "LeasePeriod", "3000");
- localServer.deployQueue("Queue", null);
- localServer.deployTopic("Topic", null);
+ localServer.deployQueue("Queue", null, false);
+ localServer.deployTopic("Topic", null, false);
// Connect to the remote server, but don't start a servicecontainer on it. We are only using
// the remote server to open a client connection to the local server.
@@ -121,7 +120,7 @@
// Now we should have a client connection from the remote server to the local server
- remoteServer.exit();
+ remoteServer.destroy();
log.trace("killed remote server");
// Wait for connection resources to be cleared up
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTwoConnectionsTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTwoConnectionsTest.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTwoConnectionsTest.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -76,16 +76,15 @@
localServer = new LocalTestServer();
// Start all the services locally
- localServer.start("all");
+ localServer.start("all", false);
-
// This crash test is relying on a precise value of LeaseInterval, so we don't rely on
// the default, whatever that is ...
localServer.setAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "LeasePeriod", "3000");
- localServer.deployQueue("Queue", null);
- localServer.deployTopic("Topic", null);
+ localServer.deployQueue("Queue", null, false);
+ localServer.deployTopic("Topic", null, false);
// Connect to the remote server, but don't start a servicecontainer on it. We are only using
// the remote server to open a client connection to the local server.
@@ -123,7 +122,7 @@
log.info("we have = " + ((SimpleConnectionManager)cm).getClients().size() + " clients registered on SimpleconnectionManager");
// Now we should have a client connection from the remote server to the local server
- remoteServer.exit();
+ remoteServer.destroy();
log.info("killed remote server");
// Wait for connection resources to be cleared up
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashZeroLeaseTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashZeroLeaseTest.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashZeroLeaseTest.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -74,14 +74,13 @@
localServer = new LocalTestServer();
// Start all the services locally
- localServer.start("all");
+ localServer.start("all", false);
-
//Set lease period to 0 --> this should disable leasing so the state won't be cleared up
localServer.setAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "LeasePeriod", "0");
- localServer.deployQueue("Queue", null);
+ localServer.deployQueue("Queue", null, false);
// Connect to the remote server, but don't start a servicecontainer on it. We are only using
// the remote server to open a client connection to the local server.
@@ -119,7 +118,7 @@
// Now we should have a client connection from the remote server to the local server
- remoteServer.exit();
+ remoteServer.destroy();
log.trace("killed remote server");
// Wait for connection resources to be cleared up
Deleted: trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -1,1297 +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.manual;
-
-import java.util.Properties;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.jboss.test.messaging.MessagingTestCase;
-
-/**
- *
- * A ManualClusteringTest
- *
- * Nodes must be started up in order node1, node2, node3
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class ManualClusteringTest extends MessagingTestCase
-{
- protected Context ic1;
-
- protected Context ic2;
-
- protected Context ic3;
-
- protected Queue queue1;
-
- protected Topic topic1;
-
- protected Queue queue2;
-
- protected Topic topic2;
-
- protected Queue queue3;
-
- protected Topic topic3;
-
- protected ConnectionFactory cf1;
-
- protected ConnectionFactory cf2;
-
- protected ConnectionFactory cf3;
-
- public ManualClusteringTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- Properties props1 = new Properties();
-
- props1.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- props1.put(Context.PROVIDER_URL, "jnp://localhost:1199");
- props1.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
-
- ic1 = new InitialContext(props1);
-
- Properties props2 = new Properties();
-
- props2.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- props2.put(Context.PROVIDER_URL, "jnp://localhost:1299");
- props2.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
-
- ic2 = new InitialContext(props2);
-
- Properties props3 = new Properties();
-
- props3.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- props3.put(Context.PROVIDER_URL, "jnp://localhost:1399");
- props3.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
-
- ic3 = new InitialContext(props3);
-
- queue1 = (Queue)ic1.lookup("queue/testDistributedQueue");
-
- queue2 = (Queue)ic2.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");
-
- cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
-
- cf2 = (ConnectionFactory)ic2.lookup("/ConnectionFactory");
-
- cf3 = (ConnectionFactory)ic3.lookup("/ConnectionFactory");
-
- drainStuff();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- ic1.close();
-
- ic2.close();
- }
-
- protected void drainStuff() 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(queue2);
-
- conn1.start();
-
- conn2.start();
-
- conn3.start();
-
- Message msg = null;
-
- do
- {
- msg = cons1.receive(1000);
- }
- while (msg != null);
-
- do
- {
- msg = cons2.receive(1000);
- }
- while (msg != null);
-
- do
- {
- msg = cons3.receive(1000);
- }
- while (msg != null);
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
- public void testClusteredQueueLocalConsumerNonPersistent() throws Exception
- {
- clusteredQueueLocalConsumer(false);
- }
-
- public void testClusteredQueueLocalConsumerPersistent() throws Exception
- {
- clusteredQueueLocalConsumer(true);
- }
-
- public void testClusteredQueueNoLocalConsumerNonPersistent() throws Exception
- {
- clusteredQueueNoLocalConsumer(false);
- }
-
- public void testClusteredQueueNoLocalConsumerPersistent() throws Exception
- {
- clusteredQueueNoLocalConsumer(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 testClusteredTopicSharedDurableNoLocalConsumerNonPersistent() throws Exception
- {
- clusteredTopicSharedDurableNoLocalConsumer(false);
- }
-
- public void testClusteredTopicSharedDurableNoLocalConsumerPersistent() throws Exception
- {
- clusteredTopicSharedDurableNoLocalConsumer(true);
- }
-
- public void testClusteredTopicSharedDurableNoLocalSubNonPersistent() throws Exception
- {
- clusteredTopicSharedDurableNoLocalSub(false);
- }
-
- public void testClusteredTopicSharedDurableNoLocalSubPersistent() throws Exception
- {
- clusteredTopicSharedDurableNoLocalSub(true);
- }
-
-
-
-
- /*
- * Create a consumer on each queue on each node.
- * Send messages in turn from all nodes.
- * Ensure that the local consumer gets the message
- */
- 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);
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
-
-
-
- /*
- * Create a consumer on two nodes out of three
- * Send messages from the third node
- * Ensure that the messages are received from the other two nodes in
- * round robin order.
- * (Note that this test depends on us using the default router which has
- * this round robin behaviour)
- */
- protected void clusteredQueueNoLocalConsumer(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 cons2 = sess2.createConsumer(queue2);
-
- MessageConsumer cons3 = sess3.createConsumer(queue3);
-
- 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 / 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());
- }
-
- }
- 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.
- * Ensure all messages are receive as appropriate
- */
- public 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());
- }
-
- 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
- {
- 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)
- {
- tm.setStringProperty("COLOUR", "red");
- }
- else if (c == 1)
- {
- 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());
- }
-
- 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
- {
- 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);
-
- 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());
- }
-
- 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);
-
- 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);
-
- 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 consumer on local node
- * even thought there is durable sub
- * should round robin
- * note that this test assumes round robin
- */
- protected void clusteredTopicSharedDurableNoLocalConsumer(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);
-
- MessageConsumer cons1 = sess1.createDurableSubscriber(topic1, "sub1");
-
- //Now close it on node 1
- conn1.close();
-
- conn1 = cf1.createConnection();
-
- conn1.setClientID("wib1");
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- //This means the durable sub is inactive on node1
-
- 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();
-
- 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
- * note that this test assumes round robin
- */
- 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);
-
- 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();
- }
- }
-
- class MyListener implements MessageListener
- {
- private int i;
-
- MyListener(int i)
- {
- this.i = i;
- }
-
- public void onMessage(Message m)
- {
- try
- {
- int count = m.getIntProperty("count");
-
- log.info("Listener " + i + " received message " + count);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- }
-
-}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -83,7 +83,7 @@
try
{
- ServerManagement.startServerPeer("0", "/some-new-context", null);
+ ServerManagement.startServerPeer(0, "/some-new-context", null);
fail("should throw exception");
}
catch(MessagingJMSException e)
@@ -96,7 +96,7 @@
{
ServerManagement.stopServerPeer();
- ServerManagement.startServerPeer("0", "/here-go-queues", "/and-here-topics/etc/etc");
+ ServerManagement.startServerPeer(0, "/here-go-queues", "/and-here-topics/etc/etc");
try
{
Modified: trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -21,10 +21,6 @@
*/
package org.jboss.test.messaging.tools;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
import java.rmi.Naming;
import java.util.Hashtable;
import java.util.Set;
@@ -49,6 +45,7 @@
* is also use to start/stop a remote server.
*
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision$</tt>
*
* $Id$
@@ -74,9 +71,7 @@
private static final int RMI_SERVER_LOOKUP_RETRIES = 10;
- private static Server server;
- private static volatile Process process;
- private static Thread vmStarter;
+ private static Server[] servers = new Server[RMITestServer.RMI_REGISTRY_PORTS.length];
public static boolean isLocal()
{
@@ -90,25 +85,42 @@
public static Server getServer()
{
- return server;
+ return getServer(0);
}
-
+
+ public static Server getServer(int i)
+ {
+ Server s = servers[i];
+
+ if (s == null)
+ {
+ throw new IllegalStateException("Server " + i + " is not started!");
+ }
+
+ return s;
+ }
+
public static synchronized void create() throws Exception
{
- if (server != null)
+ create(0);
+ }
+
+ public static synchronized void create(int index) throws Exception
+ {
+ if (servers[index] != null)
{
return;
}
if (isLocal())
{
- server = new LocalTestServer();
+ servers[index] = new LocalTestServer();
return;
}
- server = acquireRemote(RMI_SERVER_LOOKUP_RETRIES);
+ servers[index] = acquireRemote(RMI_SERVER_LOOKUP_RETRIES, index);
- if (server != null)
+ if (servers[index] != null)
{
// RMI server started
return;
@@ -121,15 +133,20 @@
// but when running such a test from a forking ant, ant blocks forever waiting for *this* VM
// to exit. That's why I require the remote server to be started in advance.
- throw new IllegalStateException("The RMI server doesn't seem to be started. " +
+ throw new IllegalStateException("The RMI server " + index + " doesn't seem to be started. " +
"Start it and re-run the test.");
}
-
+
public static synchronized void start(String config) throws Exception
{
- create();
+ start(config, 0, false);
+ }
+ public static synchronized void start(String config, int index, boolean clustered) throws Exception
+ {
+ create(index);
+
if (isLocal())
{
log.info("IN-VM TEST");
@@ -141,106 +158,99 @@
MessageIdGeneratorFactory.instance.clear();
- server.start(config);
+ //Now start the server
+ servers[index].start(config, clustered);
log.debug("server started");
}
public static synchronized void stop() throws Exception
{
- if (server != null)
- {
- server.stop();
- }
+ insureStarted();
+
+ servers[0].stop();
}
public static synchronized void destroy() throws Exception
{
stop();
- server.destroy();
+ servers[0].destroy();
- if (isRemote())
- {
- log.debug("destroying the remote server VM");
- process.destroy();
- log.debug("remote server VM destroyed");
- }
- server = null;
+ servers[0] = null;
}
public static void disconnect() throws Exception
{
if (isRemote())
{
- server = null;
- process = null;
- if (vmStarter != null)
- {
- vmStarter.interrupt();
- vmStarter = null;
- }
+ servers[0] = null;
}
}
public static ObjectName deploy(String mbeanConfiguration) throws Exception
{
insureStarted();
- return server.deploy(mbeanConfiguration);
+ return servers[0].deploy(mbeanConfiguration);
}
public static void undeploy(ObjectName on) throws Exception
{
insureStarted();
- server.undeploy(on);
+ servers[0].undeploy(on);
}
public static Object getAttribute(ObjectName on, String attribute) throws Exception
{
insureStarted();
- return server.getAttribute(on, attribute);
+ return servers[0].getAttribute(on, attribute);
}
public static void setAttribute(ObjectName on, String name, String valueAsString)
throws Exception
{
insureStarted();
- server.setAttribute(on, name, valueAsString);
+ servers[0].setAttribute(on, name, valueAsString);
}
public static Object invoke(ObjectName on, String operationName,
Object[] params, String[] signature) throws Exception
{
insureStarted();
- return server.invoke(on, operationName, params, signature);
+ return servers[0].invoke(on, operationName, params, signature);
}
public static Set query(ObjectName pattern) throws Exception
{
insureStarted();
- return server.query(pattern);
+ return servers[0].query(pattern);
}
public static UserTransaction getUserTransaction() throws Exception
{
insureStarted();
- return server.getUserTransaction();
+ return servers[0].getUserTransaction();
}
-
+
public static void log(int level, String text)
{
+ log(level, text, 0);
+ }
+
+ public static void log(int level, String text, int index)
+ {
if (isRemote())
{
- if (server == null)
+ if (servers[index] == null)
{
- log.debug("The remote server has not been created yet " +
+ log.debug("The remote server " + index + " has not been created yet " +
"so this log won't make it to the server!");
return;
}
try
{
- server.log(level, text);
+ servers[index].log(level, text);
}
catch(Exception e)
{
@@ -251,7 +261,7 @@
public static void startServerPeer() throws Exception
{
- startServerPeer(null, null, null);
+ startServerPeer(0, null, null);
}
/**
@@ -259,30 +269,30 @@
* @param defaultQueueJNDIContext - if null, the jboss-service.xml value will be used.
* @param defaultTopicJNDIContext - if null, the jboss-service.xml value will be used.
*/
- public static void startServerPeer(String serverPeerID,
+ public static void startServerPeer(int serverPeerID,
String defaultQueueJNDIContext,
String defaultTopicJNDIContext) throws Exception
{
insureStarted();
- server.startServerPeer(serverPeerID, defaultQueueJNDIContext, defaultTopicJNDIContext);
+ servers[0].startServerPeer(serverPeerID, defaultQueueJNDIContext, defaultTopicJNDIContext, false);
}
public static void stopServerPeer() throws Exception
{
insureStarted();
- server.stopServerPeer();
+ servers[0].stopServerPeer();
}
public static boolean isServerPeerStarted() throws Exception
{
insureStarted();
- return server.isServerPeerStarted();
+ return servers[0].isServerPeerStarted();
}
public static ObjectName getServerPeerObjectName() throws Exception
{
insureStarted();
- return server.getServerPeerObjectName();
+ return servers[0].getServerPeerObjectName();
}
/**
@@ -292,7 +302,7 @@
public static Set getConnectorSubsystems() throws Exception
{
insureStarted();
- return server.getConnectorSubsystems();
+ return servers[0].getConnectorSubsystems();
}
/**
@@ -303,7 +313,7 @@
ServerInvocationHandler handler) throws Exception
{
insureStarted();
- server.addServerInvocationHandler(subsystem, handler);
+ servers[0].addServerInvocationHandler(subsystem, handler);
}
/**
@@ -314,47 +324,56 @@
throws Exception
{
insureStarted();
- server.removeServerInvocationHandler(subsystem);
+ servers[0].removeServerInvocationHandler(subsystem);
}
public static MessageStore getMessageStore() throws Exception
{
insureStarted();
- return server.getMessageStore();
+ return servers[0].getMessageStore();
}
public static DestinationManager getDestinationManager()
throws Exception
{
insureStarted();
- return server.getDestinationManager();
+ return servers[0].getDestinationManager();
}
public static PersistenceManager getPersistenceManager()
throws Exception
{
insureStarted();
- return server.getPersistenceManager();
+ return servers[0].getPersistenceManager();
}
public static void configureSecurityForDestination(String destName, String config)
throws Exception
{
insureStarted();
- server.configureSecurityForDestination(destName, config);
+ servers[0].configureSecurityForDestination(destName, config);
}
public static void setDefaultSecurityConfig(String config) throws Exception
{
insureStarted();
- server.setDefaultSecurityConfig(config);
+ servers[0].setDefaultSecurityConfig(config);
}
public static String getDefaultSecurityConfig() throws Exception
{
insureStarted();
- return server.getDefaultSecurityConfig();
+ return servers[0].getDefaultSecurityConfig();
}
+
+ /**
+ * Simulates a topic deployment (copying the topic descriptor in the deploy directory).
+ */
+ public static void deployClusteredTopic(String name, int serverIndex) throws Exception
+ {
+ insureStarted(serverIndex);
+ servers[serverIndex].deployTopic(name, null, true);
+ }
/**
* Simulates a topic deployment (copying the topic descriptor in the deploy directory).
@@ -370,7 +389,7 @@
public static void deployTopic(String name, String jndiName) throws Exception
{
insureStarted();
- server.deployTopic(name, jndiName);
+ servers[0].deployTopic(name, jndiName, false);
}
/**
@@ -389,7 +408,7 @@
int downCacheSize) throws Exception
{
insureStarted();
- server.deployTopic(name, jndiName, fullSize, pageSize, downCacheSize);
+ servers[0].deployTopic(name, jndiName, fullSize, pageSize, downCacheSize, false);
}
/**
@@ -399,6 +418,14 @@
{
undeployDestination(false, name);
}
+
+ /**
+ * Simulates a topic un-deployment (deleting the topic descriptor from the deploy directory).
+ */
+ public static void undeployTopic(String name, int serverIndex) throws Exception
+ {
+ undeployDestination(false, name, serverIndex);
+ }
/**
* Creates a topic programatically.
@@ -406,7 +433,7 @@
public static void createTopic(String name, String jndiName) throws Exception
{
insureStarted();
- server.createTopic(name, jndiName);
+ servers[0].createTopic(name, jndiName);
}
/**
@@ -414,8 +441,17 @@
*/
public static boolean destroyTopic(String name) throws Exception
{
- return server.destroyDestination(false, name);
+ return servers[0].destroyDestination(false, name);
}
+
+ /**
+ * Simulates a queue deployment (copying the queue descriptor in the deploy directory).
+ */
+ public static void deployClusteredQueue(String name, int serverIndex) throws Exception
+ {
+ insureStarted(serverIndex);
+ servers[serverIndex].deployQueue(name, null, true);
+ }
/**
* Simulates a queue deployment (copying the queue descriptor in the deploy directory).
@@ -431,7 +467,7 @@
public static void deployQueue(String name, String jndiName) throws Exception
{
insureStarted();
- server.deployQueue(name, jndiName);
+ servers[0].deployQueue(name, jndiName, false);
}
/**
@@ -450,7 +486,7 @@
int downCacheSize) throws Exception
{
insureStarted();
- server.deployQueue(name, jndiName, fullSize, pageSize, downCacheSize);
+ servers[0].deployQueue(name, jndiName, fullSize, pageSize, downCacheSize, false);
}
/**
@@ -460,6 +496,14 @@
{
undeployDestination(true, name);
}
+
+ /**
+ * Simulates a queue un-deployment (deleting the queue descriptor from the deploy directory).
+ */
+ public static void undeployQueue(String name, int serverIndex) throws Exception
+ {
+ undeployDestination(true, name, serverIndex);
+ }
/**
* Creates a queue programatically.
@@ -467,7 +511,7 @@
public static void createQueue(String name, String jndiName) throws Exception
{
insureStarted();
- server.createQueue(name, jndiName);
+ servers[0].createQueue(name, jndiName);
}
/**
@@ -475,7 +519,7 @@
*/
public static boolean destroyQueue(String name) throws Exception
{
- return server.destroyDestination(true, name);
+ return servers[0].destroyDestination(true, name);
}
/**
@@ -485,8 +529,18 @@
private static void undeployDestination(boolean isQueue, String name) throws Exception
{
insureStarted();
- server.undeployDestination(isQueue, name);
+ servers[0].undeployDestination(isQueue, name);
}
+
+ /**
+ * 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
+ {
+ insureStarted(serverIndex);
+ servers[serverIndex].undeployDestination(isQueue, name);
+ }
public static void deployConnectionFactory(String objectName,
String[] jndiBindings,
@@ -496,7 +550,7 @@
int defaultTempQueueDownCacheSize)
throws Exception
{
- server.deployConnectionFactory(objectName,
+ servers[0].deployConnectionFactory(objectName,
jndiBindings,
prefetchSize,
defaultTempQueueFullSize,
@@ -509,19 +563,19 @@
int prefetchSize)
throws Exception
{
- server.deployConnectionFactory(objectName, jndiBindings, prefetchSize);
+ servers[0].deployConnectionFactory(objectName, jndiBindings, prefetchSize);
}
public static void deployConnectionFactory(String objectName,
String[] jndiBindings)
throws Exception
{
- server.deployConnectionFactory(objectName, jndiBindings);
+ servers[0].deployConnectionFactory(objectName, jndiBindings);
}
public static void undeployConnectionFactory(ObjectName objectName) throws Exception
{
- server.undeployConnectionFactory(objectName);
+ servers[0].undeployConnectionFactory(objectName);
}
public static Hashtable getJNDIEnvironment()
@@ -532,9 +586,14 @@
}
else
{
- return RemoteInitialContextFactory.getJNDIEnvironment();
+ return getJNDIEnvironment(0);
}
}
+
+ public static Hashtable getJNDIEnvironment(int index)
+ {
+ return RemoteInitialContextFactory.getJNDIEnvironment(index);
+ }
// Attributes ----------------------------------------------------
@@ -550,19 +609,24 @@
private static void insureStarted() throws Exception
{
- if (server == null)
+ insureStarted(0);
+ }
+
+ private static void insureStarted(int index) throws Exception
+ {
+ if (servers[index] == null)
{
- throw new Exception("The server has not been created!");
+ throw new Exception("The server " + index + " has not been created!");
}
- if (!server.isStarted())
+ if (!servers[index].isStarted())
{
- throw new Exception("The server has not been started!");
+ throw new Exception("The server " + index + " has not been started!");
}
}
- private static Server acquireRemote(int initialRetries)
+ private static Server acquireRemote(int initialRetries, int index)
{
- String name = "//localhost:" + RMITestServer.RMI_REGISTRY_PORT + "/" + RMITestServer.RMI_SERVER_NAME;
+ String name = "//localhost:" + RMITestServer.RMI_REGISTRY_PORTS[index] + "/" + RMITestServer.RMI_SERVER_NAME;
Server s = null;
int retries = initialRetries;
while(s == null && retries > 0)
@@ -598,138 +662,138 @@
// Inner classes -------------------------------------------------
- static class VMStarter implements Runnable
- {
- public void run()
- {
- // start a remote java process that runs a TestServer
-
- String userDir = System.getProperty("user.dir");
- String javaClassPath = System.getProperty("java.class.path");
- String fileSeparator = System.getProperty("file.separator");
- String javaHome = System.getProperty("java.home");
- String moduleOutput = System.getProperty("module.output");
-
- String osName = System.getProperty("os.name").toLowerCase();
- boolean isWindows = osName.indexOf("windows") != -1;
-
- String javaExecutable =
- javaHome + fileSeparator + "bin" + fileSeparator + "java" + (isWindows ? ".exe" : "");
-
- String[] cmdarray = new String[]
- {
- javaExecutable,
- "-cp",
- javaClassPath,
- "-Dmodule.output=" + moduleOutput,
- "-Dremote.test.suffix=-remote",
- "org.jboss.test.messaging.tools.jmx.rmi.TestServer",
- };
-
- String[] environment;
- if (isWindows)
- {
- environment = new String[]
- {
- "SYSTEMROOT=C:\\WINDOWS" // TODO get this from environment, as it may be diffrent on different machines
- };
- }
- else
- {
- environment = new String[0];
- }
-
- Runtime runtime = Runtime.getRuntime();
-
- try
- {
- log.debug("creating external process");
-
- Thread stdoutLogger = new Thread(new RemoteProcessLogger(RemoteProcessLogger.STDOUT),
- "Remote VM STDOUT Logging Thread");
- Thread stderrLogger = new Thread(new RemoteProcessLogger(RemoteProcessLogger.STDERR),
- "Remote VM STDERR Logging Thread");
-
- stdoutLogger.setDaemon(true);
- stdoutLogger.setDaemon(true);
- stdoutLogger.start();
- stderrLogger.start();
-
- process = runtime.exec(cmdarray, environment, new File(userDir));
- }
- catch(Exception e)
- {
- log.error("Error spawning remote server", e);
- }
- }
- }
-
- /**
- * This logger is used to get and display the output generated at stdout or stderr by the
- * RMI server VM.
- */
- static class RemoteProcessLogger implements Runnable
- {
- public static final int STDOUT = 0;
- public static final int STDERR = 1;
-
- private int type;
- private BufferedReader br;
- private PrintStream out;
-
- public RemoteProcessLogger(int type)
- {
- this.type = type;
-
- if (type == STDOUT)
- {
- out = System.out;
- }
- else if (type == STDERR)
- {
- out = System.err;
- }
- else
- {
- throw new IllegalArgumentException("Unknown type " + type);
- }
- }
-
- public void run()
- {
- while(process == null)
- {
- try
- {
- Thread.sleep(50);
- }
- catch(InterruptedException e)
- {
- // OK
- }
- }
-
- if (type == STDOUT)
- {
- br = new BufferedReader(new InputStreamReader(process.getInputStream()));
- }
- else if (type == STDERR)
- {
- br = new BufferedReader(new InputStreamReader(process.getErrorStream()));
- }
-
- String line;
- try
- {
- while((line = br.readLine()) != null)
- {
- out.println(line);
- }
- }
- catch(Exception e)
- {
- log.error("failed to read from process " + process, e);
- }
- }
- }
+// static class VMStarter implements Runnable
+// {
+// public void run()
+// {
+// // start a remote java process that runs a TestServer
+//
+// String userDir = System.getProperty("user.dir");
+// String javaClassPath = System.getProperty("java.class.path");
+// String fileSeparator = System.getProperty("file.separator");
+// String javaHome = System.getProperty("java.home");
+// String moduleOutput = System.getProperty("module.output");
+//
+// String osName = System.getProperty("os.name").toLowerCase();
+// boolean isWindows = osName.indexOf("windows") != -1;
+//
+// String javaExecutable =
+// javaHome + fileSeparator + "bin" + fileSeparator + "java" + (isWindows ? ".exe" : "");
+//
+// String[] cmdarray = new String[]
+// {
+// javaExecutable,
+// "-cp",
+// javaClassPath,
+// "-Dmodule.output=" + moduleOutput,
+// "-Dremote.test.suffix=-remote",
+// "org.jboss.test.messaging.tools.jmx.rmi.TestServer",
+// };
+//
+// String[] environment;
+// if (isWindows)
+// {
+// environment = new String[]
+// {
+// "SYSTEMROOT=C:\\WINDOWS" // TODO get this from environment, as it may be diffrent on different machines
+// };
+// }
+// else
+// {
+// environment = new String[0];
+// }
+//
+// Runtime runtime = Runtime.getRuntime();
+//
+// try
+// {
+// log.debug("creating external process");
+//
+// Thread stdoutLogger = new Thread(new RemoteProcessLogger(RemoteProcessLogger.STDOUT),
+// "Remote VM STDOUT Logging Thread");
+// Thread stderrLogger = new Thread(new RemoteProcessLogger(RemoteProcessLogger.STDERR),
+// "Remote VM STDERR Logging Thread");
+//
+// stdoutLogger.setDaemon(true);
+// stdoutLogger.setDaemon(true);
+// stdoutLogger.start();
+// stderrLogger.start();
+//
+// process = runtime.exec(cmdarray, environment, new File(userDir));
+// }
+// catch(Exception e)
+// {
+// log.error("Error spawning remote server", e);
+// }
+// }
+// }
+//
+// /**
+// * This logger is used to get and display the output generated at stdout or stderr by the
+// * RMI server VM.
+// */
+// static class RemoteProcessLogger implements Runnable
+// {
+// public static final int STDOUT = 0;
+// public static final int STDERR = 1;
+//
+// private int type;
+// private BufferedReader br;
+// private PrintStream out;
+//
+// public RemoteProcessLogger(int type)
+// {
+// this.type = type;
+//
+// if (type == STDOUT)
+// {
+// out = System.out;
+// }
+// else if (type == STDERR)
+// {
+// out = System.err;
+// }
+// else
+// {
+// throw new IllegalArgumentException("Unknown type " + type);
+// }
+// }
+//
+// public void run()
+// {
+// while(process == null)
+// {
+// try
+// {
+// Thread.sleep(50);
+// }
+// catch(InterruptedException e)
+// {
+// // OK
+// }
+// }
+//
+// if (type == STDOUT)
+// {
+// br = new BufferedReader(new InputStreamReader(process.getInputStream()));
+// }
+// else if (type == STDERR)
+// {
+// br = new BufferedReader(new InputStreamReader(process.getErrorStream()));
+// }
+//
+// String line;
+// try
+// {
+// while((line = br.readLine()) != null)
+// {
+// out.println(line);
+// }
+// }
+// catch(Exception e)
+// {
+// log.error("failed to read from process " + process, e);
+// }
+// }
+// }
}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -188,6 +188,10 @@
private List toUnbindAtExit;
private String ipAddressOrHostName;
+
+ //There may be many service containers on the same machine, so we need to distinguish them
+ //so we don't start up multiple servers with services running on the same port
+ private int serverIndex;
// Static --------------------------------------------------------
@@ -247,10 +251,15 @@
// Constructors --------------------------------------------------
- public ServiceContainer(String sevicesToStart) throws Exception
+ public ServiceContainer(String servicesToStart) throws Exception
{
- this(sevicesToStart, null);
+ this(servicesToStart, null);
}
+
+ public ServiceContainer(String sevicesToStart, int serverIndex) throws Exception
+ {
+ this(sevicesToStart, null, serverIndex);
+ }
/**
* @param sevicesToStart - A comma separated list of services to be started. Available services:
@@ -265,7 +274,16 @@
this.tm = tm;
parseConfig(sevicesToStart);
toUnbindAtExit = new ArrayList();
+ this.serverIndex = 0;
}
+
+ public ServiceContainer(String sevicesToStart, TransactionManager tm, int serverIndex) throws Exception
+ {
+ this.tm = tm;
+ parseConfig(sevicesToStart);
+ toUnbindAtExit = new ArrayList();
+ this.serverIndex = serverIndex;
+ }
// Public --------------------------------------------------------
@@ -1117,14 +1135,16 @@
"socket.check_connection=false&" +
"leasePeriod=20000";
+ int portNumber = 9111 + serverIndex;
+
String locatorURI;
if (multiplex)
{
- locatorURI = "multiplex://" + ipAddressOrHostName + ":9111" + params;
+ locatorURI = "multiplex://" + ipAddressOrHostName + ":" + portNumber + params;
}
else
{
- locatorURI = "socket://" + ipAddressOrHostName + ":9111" + params;
+ locatorURI = "socket://" + ipAddressOrHostName + ":" + portNumber + params;
}
log.debug("Using the following locator uri:" + locatorURI);
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -79,6 +79,8 @@
// List<ObjectName>
private List connFactoryObjectNames;
+
+ private int serverIndex;
// Constructors --------------------------------------------------
@@ -88,27 +90,41 @@
connFactoryObjectNames = new ArrayList();
}
+
+ public LocalTestServer(int serverIndex)
+ {
+ this();
+
+ this.serverIndex = serverIndex;
+ }
// Server implementation -----------------------------------------
- public synchronized void start(String containerConfig) throws Exception
+ public synchronized void start(String containerConfig, boolean clustered) throws Exception
{
if (isStarted())
{
return;
}
-
+
log.debug("starting service container");
- sc = new ServiceContainer(containerConfig, null);
+ sc = new ServiceContainer(containerConfig, null, serverIndex);
sc.start();
+
+ log.info("********* STARTING SERVER DATABASE TYPE IS " + sc.getDatabaseType());
+
+ if (this.getDatabaseType().equals("hsqldb") && clustered)
+ {
+ throw new IllegalStateException("The test server cannot be started in clustered mode with hsqldb as a database - must use a shared database");
+ }
if ("none".equals(containerConfig))
{
return;
}
- startServerPeer(null, null, null);
+ startServerPeer(serverIndex, null, null, clustered);
log.info("server started");
}
@@ -211,12 +227,15 @@
return sc != null;
}
- public void startServerPeer(String serverPeerID,
+ public void startServerPeer(int serverPeerID,
String defaultQueueJNDIContext,
- String defaultTopicJNDIContext) throws Exception
+ String defaultTopicJNDIContext,
+ boolean clustered) throws Exception
{
try
- {
+ {
+ log.info("******* STARTING SERVER PEER WITH ID " + serverPeerID);
+
log.debug("creating ServerPeer instance");
// we are using the "default" service deployment descriptors available in
@@ -230,9 +249,21 @@
}
String databaseType = sc.getDatabaseType();
- String persistenceConfigFile =
- "server/default/deploy/" + databaseType + "-persistence-service.xml";
+ String persistenceConfigFile;
+ if (clustered && !databaseType.equals("hsqldb"))
+ {
+ //HSQL can't be used for clustered server peer - since it's not a shared database
+
+ persistenceConfigFile =
+ "server/default/deploy/clustered-" + databaseType + "-persistence-service.xml";
+ }
+ else
+ {
+ persistenceConfigFile =
+ "server/default/deploy/" + databaseType + "-persistence-service.xml";
+ }
+
log.info("********* LOADING CONFIG FILE: " + persistenceConfigFile);
URL persistenceConfigFileURL = getClass().getClassLoader().getResource(persistenceConfigFile);
@@ -269,10 +300,8 @@
(MBeanConfigurationElement)mdd.query("service", "ServerPeer").iterator().next();
// overwrite the file configuration, if needed
- if (serverPeerID != null)
- {
- serverPeerConfig.setConstructorArgumentValue(0, 0, serverPeerID);
- }
+ serverPeerConfig.setConstructorArgumentValue(0, 0, String.valueOf(serverPeerID));
+
if (defaultQueueJNDIContext != null)
{
serverPeerConfig.setConstructorArgumentValue(0, 1, defaultQueueJNDIContext);
@@ -292,9 +321,7 @@
sc.invoke(serverPeerObjectName, "create", new Object[0], new String[0]);
sc.invoke(serverPeerObjectName, "start", new Object[0], new String[0]);
-
- log.info("deploying post offices");
-
+
MBeanConfigurationElement queuePostOfficeConfig =
(MBeanConfigurationElement)pdd.query("service", "QueuePostOffice").iterator().next();
queuePostOfficeObjectName = sc.registerAndConfigureService(queuePostOfficeConfig);
@@ -307,8 +334,6 @@
sc.invoke(topicPostOfficeObjectName, "create", new Object[0], new String[0]);
sc.invoke(topicPostOfficeObjectName, "start", new Object[0], new String[0]);
- log.info("Deployed postoffices");
-
log.debug("deploying connection factories");
List connFactoryElements = cfdd.query("service", "ConnectionFactory");
@@ -560,15 +585,15 @@
getAttribute(serverPeerObjectName, "Instance");
}
- public void deployTopic(String name, String jndiName) throws Exception
+ public void deployTopic(String name, String jndiName, boolean clustered) throws Exception
{
- deployDestination(false, name, jndiName);
+ deployDestination(false, name, jndiName, clustered);
}
public void deployTopic(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize) throws Exception
+ int downCacheSize, boolean clustered) throws Exception
{
- deployDestination(false, name, jndiName, fullSize, pageSize, downCacheSize);
+ deployDestination(false, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
}
public void createTopic(String name, String jndiName) throws Exception
@@ -578,15 +603,15 @@
new String[] { "java.lang.String", "java.lang.String"} );
}
- public void deployQueue(String name, String jndiName) throws Exception
+ public void deployQueue(String name, String jndiName, boolean clustered) throws Exception
{
- deployDestination(true, name, jndiName);
+ deployDestination(true, name, jndiName, clustered);
}
public void deployQueue(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize) throws Exception
+ int downCacheSize, boolean clustered) throws Exception
{
- deployDestination(true, name, jndiName, fullSize, pageSize, downCacheSize);
+ deployDestination(true, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
}
public void createQueue(String name, String jndiName) throws Exception
@@ -596,7 +621,7 @@
new String[] { "java.lang.String", "java.lang.String"} );
}
- public void deployDestination(boolean isQueue, String name, String jndiName) throws Exception
+ public void deployDestination(boolean isQueue, String name, String jndiName, boolean clustered) throws Exception
{
String config =
"<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") + "\"" +
@@ -604,6 +629,7 @@
" xmbean-dd=\"xmdesc/" + (isQueue ? "Queue" : "Topic" ) + "-xmbean.xml\">" +
(jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
" <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <attribute name=\"Clustered\">" + String.valueOf(clustered) + "</attribute>" +
"</mbean>";
MBeanConfigurationElement mbean =
@@ -618,7 +644,8 @@
String jndiName,
int fullSize,
int pageSize,
- int downCacheSize) throws Exception
+ int downCacheSize,
+ boolean clustered) throws Exception
{
log.info("deploying queue, fullsize:" + fullSize + ", ps:" + pageSize + " dc size:" + downCacheSize);
@@ -631,6 +658,7 @@
" <attribute name=\"FullSize\">" + fullSize + "</attribute>" +
" <attribute name=\"PageSize\">" + pageSize + "</attribute>" +
" <attribute name=\"DownCacheSize\">" + downCacheSize + "</attribute>" +
+ " <attribute name=\"Clustered\">" + String.valueOf(clustered) + "</attribute>" +
"</mbean>";
MBeanConfigurationElement mbean =
@@ -774,11 +802,6 @@
return XMLUtil.elementToString(element);
}
- public void exit() throws Exception
- {
- destroy();
- }
-
public Object executeCommand(Command command) throws Exception
{
return command.execute();
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -56,12 +56,17 @@
private RMINamingDelegate namingDelegate;
- public static final int RMI_REGISTRY_PORT = 25989;
+ //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";
private static Registry registry;
-
+
public static void main(String[] args) throws Exception
{
log.debug("initializing RMI runtime");
@@ -73,14 +78,27 @@
}
log.info("bind address: " + host);
+
+ int index;
+ String registryIndex = System.getProperty("test.registry.index");
+ if (registryIndex == null)
+ {
+ //Use the 0th port
+ index = 0;
+ }
+ else
+ {
+ index = Integer.parseInt(registryIndex);
+ }
+ int port = RMI_REGISTRY_PORTS[index];
// let RMI know the bind address
System.setProperty("java.rmi.server.hostname", host);
- registry = LocateRegistry.createRegistry(RMI_REGISTRY_PORT);
- log.debug("registry created");
+ registry = LocateRegistry.createRegistry(port);
+ log.debug("registry created at port: " + port);
- RMITestServer testServer = new RMITestServer();
+ RMITestServer testServer = new RMITestServer(index);
log.debug("RMI server created");
registry.bind(RMI_SERVER_NAME, testServer);
@@ -108,11 +126,11 @@
}
}
- public RMITestServer() throws Exception
+ public RMITestServer(int index) throws Exception
{
namingDelegate = new RMINamingDelegate();
- server = new RemoteTestServer();
+ server = new RemoteTestServer(index);
}
public void configureSecurityForDestination(String destName, String config) throws Exception
@@ -125,23 +143,24 @@
return server.deploy(mbeanConfiguration);
}
- public void deployQueue(String name, String jndiName) throws Exception
+ public void deployQueue(String name, String jndiName, boolean clustered) throws Exception
{
- server.deployQueue(name, jndiName);
+ server.deployQueue(name, jndiName, clustered);
}
- public void deployTopic(String name, String jndiName) throws Exception
+ public void deployTopic(String name, String jndiName, boolean clustered) throws Exception
{
- server.deployTopic(name, jndiName);
+ server.deployTopic(name, jndiName, clustered);
}
public void deployQueue(String name,
String jndiName,
int fullSize,
int pageSize,
- int downCacheSize) throws Exception
+ int downCacheSize,
+ boolean clustered) throws Exception
{
- server.deployQueue(name, jndiName, fullSize, pageSize, downCacheSize);
+ server.deployQueue(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
}
public void createQueue(String name, String jndiName) throws Exception
@@ -153,9 +172,10 @@
String jndiName,
int fullSize,
int pageSize,
- int downCacheSize) throws Exception
+ int downCacheSize,
+ boolean clustered) throws Exception
{
- server.deployTopic(name, jndiName, fullSize, pageSize, downCacheSize);
+ server.deployTopic(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
}
public void createTopic(String name, String jndiName) throws Exception
@@ -197,12 +217,11 @@
registry.unbind(RMI_SERVER_NAME);
registry.unbind(NAMING_SERVER_NAME);
- }
-
- public void exit() throws Exception
- {
- server.exit();
-
+
+ //Now shutdown the process
+
+ //TODO - we should shutdown cleanly - let main() exit - not kill the process
+
new Thread(new VMKiller(), "VM Killer").start();
}
@@ -302,14 +321,15 @@
server.setDefaultSecurityConfig(config);
}
- public void start(String containerConfig) throws Exception
+ public void start(String containerConfig, boolean clustered) throws Exception
{
- server.start(containerConfig);
+ server.start(containerConfig, clustered);
}
- public void startServerPeer(String serverPeerID, String defaultQueueJNDIContext, String defaultTopicJNDIContext) throws Exception
+ public void startServerPeer(int serverPeerID, String defaultQueueJNDIContext,
+ String defaultTopicJNDIContext, boolean clustered) throws Exception
{
- server.startServerPeer(serverPeerID, defaultQueueJNDIContext, defaultTopicJNDIContext);
+ server.startServerPeer(serverPeerID, defaultQueueJNDIContext, defaultTopicJNDIContext, clustered);
}
public void stop() throws Exception
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RemoteTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RemoteTestServer.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RemoteTestServer.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -44,6 +44,11 @@
// Attributes ----------------------------------------------------
// Constructors --------------------------------------------------
+
+ public RemoteTestServer(int serverIndex)
+ {
+ super(serverIndex);
+ }
// Server implementation -----------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -44,7 +44,7 @@
*/
public interface Server extends Remote
{
- void start(String containerConfig) throws Exception;
+ void start(String containerConfig, boolean clustered) throws Exception;
void stop() throws Exception;
void destroy() throws Exception;
@@ -77,9 +77,10 @@
* @param defaultQueueJNDIContext - if null, the jboss-service.xml value will be used.
* @param defaultTopicJNDIContext - if null, the jboss-service.xml value will be used.
*/
- void startServerPeer(String serverPeerID,
+ void startServerPeer(int serverPeerID,
String defaultQueueJNDIContext,
- String defaultTopicJNDIContext) throws Exception;
+ String defaultTopicJNDIContext,
+ boolean clustered) throws Exception;
void stopServerPeer() throws Exception;
boolean isServerPeerStarted() throws Exception;
@@ -133,13 +134,13 @@
/**
* Simulates a topic deployment (copying the topic descriptor in the deploy directory).
*/
- void deployTopic(String name, String jndiName) throws Exception;
+ void deployTopic(String name, String jndiName, boolean clustered) throws Exception;
/**
* Simulates a topic deployment (copying the topic descriptor in the deploy directory).
*/
void deployTopic(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize) throws Exception;
+ int downCacheSize, boolean clustered) throws Exception;
/**
* Creates a topic programatically.
@@ -149,13 +150,13 @@
/**
* Simulates a queue deployment (copying the queue descriptor in the deploy directory).
*/
- void deployQueue(String name, String jndiName) throws Exception;
+ void deployQueue(String name, String jndiName, boolean clustered) throws Exception;
/**
* Simulates a queue deployment (copying the queue descriptor in the deploy directory).
*/
void deployQueue(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize) throws Exception;
+ int downCacheSize, boolean clustered) throws Exception;
/**
* Creates a queue programatically.
@@ -207,8 +208,6 @@
*/
String getDefaultSecurityConfig() throws Exception;
- void exit() throws Exception;
-
/**
* Executes a command on the server
*
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -50,9 +50,22 @@
{
host = "localhost";
}
+
+ int index;
+ String registryIndex = System.getProperty("test.registry.index");
+ if (registryIndex == null)
+ {
+ //Use the 0th port
+ index = 0;
+ }
+ else
+ {
+ index = Integer.parseInt(registryIndex);
+ }
+ int port = RMITestServer.RMI_REGISTRY_PORTS[index];
String name =
- "//" + host + ":" + RMITestServer.RMI_REGISTRY_PORT + "/" + RMITestServer.RMI_SERVER_NAME;
+ "//" + host + ":" + port + "/" + RMITestServer.RMI_SERVER_NAME;
log.info("Stopping " + name);
@@ -67,11 +80,11 @@
return;
}
- server.stop();
+ //We should shut down cleanly - not kill the process like we are currently doing
+
+ server.destroy();
log.info("RMI server stopped");
- server.exit();
- log.info("RMI server shut down");
}
// Attributes ----------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -53,13 +53,13 @@
// Attributes ----------------------------------------------------
private NamingDelegate namingDelegate;
-
+
// Constructors --------------------------------------------------
- public RemoteContext() throws Exception
+ public RemoteContext(int remoteServerIndex) throws Exception
{
String n =
- "//localhost:" + RMITestServer.RMI_REGISTRY_PORT + "/" + RMITestServer.NAMING_SERVER_NAME;
+ "//localhost:" + RMITestServer.RMI_REGISTRY_PORTS[remoteServerIndex] + "/" + RMITestServer.NAMING_SERVER_NAME;
namingDelegate = (NamingDelegate)Naming.lookup(n);
}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java 2006-10-26 19:28:04 UTC (rev 1519)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java 2006-10-27 17:23:03 UTC (rev 1520)
@@ -22,6 +22,7 @@
package org.jboss.test.messaging.tools.jndi;
import org.jboss.logging.Logger;
+import org.jboss.test.messaging.tools.jmx.rmi.RMITestServer;
import java.util.Hashtable;
@@ -43,19 +44,21 @@
// Static --------------------------------------------------------
- private static RemoteContext initialContext;
+ private static RemoteContext[] initialContexts = new RemoteContext[RMITestServer.RMI_REGISTRY_PORTS.length];
+
+ private static final String REMOTE_SERVER_INDEX_KEY_NAME = "jboss.messaging.test.remoteserverindex";
-
/**
* @return the JNDI environment to use to get this InitialContextFactory.
*/
- public static Hashtable getJNDIEnvironment()
+ public static Hashtable getJNDIEnvironment(int index)
{
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial",
"org.jboss.test.messaging.tools.jndi.RemoteInitialContextFactory");
env.put("java.naming.provider.url", "");
env.put("java.naming.factory.url.pkgs", "");
+ env.put(REMOTE_SERVER_INDEX_KEY_NAME, String.valueOf(index));
return env;
}
@@ -67,11 +70,20 @@
public Context getInitialContext(Hashtable environment) throws NamingException
{
- if (initialContext == null)
+ String s = (String)environment.get(REMOTE_SERVER_INDEX_KEY_NAME);
+
+ if (s == null)
{
+ throw new IllegalArgumentException("Initial context environment must contain entry for " + REMOTE_SERVER_INDEX_KEY_NAME);
+ }
+
+ int remoteServerIndex = Integer.parseInt(s);
+
+ if (initialContexts[remoteServerIndex] == null)
+ {
try
{
- initialContext = new RemoteContext();
+ initialContexts[remoteServerIndex] = new RemoteContext(remoteServerIndex);
}
catch(Exception e)
{
@@ -79,7 +91,7 @@
throw new NamingException("Cannot get the remote context");
}
}
- return initialContext;
+ return initialContexts[remoteServerIndex];
}
// Package protected ---------------------------------------------
More information about the jboss-cvs-commits
mailing list