[jboss-cvs] JBoss Messaging SVN: r2926 - in trunk/tests: etc and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 25 15:13:28 EDT 2007
Author: timfox
Date: 2007-07-25 15:13:28 -0400 (Wed, 25 Jul 2007)
New Revision: 2926
Modified:
trunk/tests/build.xml
trunk/tests/etc/jbossjta-properties.xml
trunk/tests/src/org/jboss/test/messaging/MessagingTestCase.java
trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java
trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java
trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java
trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java
trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectWithRecoveryTest.java
Log:
Speeded up bridge tests
Modified: trunk/tests/build.xml
===================================================================
--- trunk/tests/build.xml 2007-07-25 10:43:58 UTC (rev 2925)
+++ trunk/tests/build.xml 2007-07-25 19:13:28 UTC (rev 2926)
@@ -444,7 +444,7 @@
<mkdir dir="${build.tests.reports}"/>
<echo message=""/>
- <echo message="Running remote tests, fork=${junit.fork}, junit.batchtest.fork=${junit.batchtest.fork}, remoting=${test.remoting}"/>
+ <echo message="Running remote tests, junit.batchtest.fork=${junit.batchtest.fork}, remoting=${test.remoting}"/>
<echo message=""/>
<junit printsummary="${junit.printsummary}"
@@ -802,7 +802,8 @@
<echo message=""/>
<junit printsummary="${junit.printsummary}"
- fork="${junit.fork}"
+ fork="on"
+ forkMode="once"
includeantruntime="yes"
haltonerror="${junit.haltonerror}"
haltonfailure="${junit.haltonfailure}"
@@ -829,8 +830,7 @@
<formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
usefile="${junit.formatter.usefile}" extension="-Remote-${test.remoting}.xml"/>
- <batchtest fork="${junit.batchtest.fork}"
- todir="${junit.batchtest.todir}"
+ <batchtest todir="${junit.batchtest.todir}"
haltonfailure="${junit.batchtest.haltonfailure}"
haltonerror="${junit.batchtest.haltonerror}">
<formatter type="plain" usefile="${junit.formatter.usefile}"/>
@@ -842,7 +842,7 @@
<formatter classname="org.jboss.test.messaging.tools.ant.JUnitTestSuiteListener"/>
<fileset dir="${build.tests.classes}">
- <include name="**/jms/bridge/**/*Test.class"/>
+ <include name="**/jms/bridge/**/*Test.class"/>
</fileset>
</batchtest>
</junit>
Modified: trunk/tests/etc/jbossjta-properties.xml
===================================================================
--- trunk/tests/etc/jbossjta-properties.xml 2007-07-25 10:43:58 UTC (rev 2925)
+++ trunk/tests/etc/jbossjta-properties.xml 2007-07-25 19:13:28 UTC (rev 2926)
@@ -175,13 +175,13 @@
Default is 120 seconds.
-->
<property
- name="com.arjuna.ats.arjuna.recovery.periodicRecoveryPeriod" value="5"/>
+ name="com.arjuna.ats.arjuna.recovery.periodicRecoveryPeriod" value="20"/>
<!--
Interval in seconds between first and second pass of periodic recovery.
Default is 10 seconds.
-->
<property
- name="com.arjuna.ats.arjuna.recovery.recoveryBackoffPeriod" value="2"/>
+ name="com.arjuna.ats.arjuna.recovery.recoveryBackoffPeriod" value="10"/>
<!--
Periodic recovery modules to use. Invoked in sort-order of names.
-->
Modified: trunk/tests/src/org/jboss/test/messaging/MessagingTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/MessagingTestCase.java 2007-07-25 10:43:58 UTC (rev 2925)
+++ trunk/tests/src/org/jboss/test/messaging/MessagingTestCase.java 2007-07-25 19:13:28 UTC (rev 2926)
@@ -146,6 +146,15 @@
assertEquals(0, messageCount.intValue());
}
+ protected void checkEmpty(Queue queue, int server) throws Exception
+ {
+ ObjectName destObjectName = new ObjectName("jboss.messaging.destination:service=Queue,name=" + queue.getQueueName());
+
+ Integer messageCount = (Integer)ServerManagement.getServer(server).getAttribute(destObjectName, "MessageCount");
+
+ assertEquals(0, messageCount.intValue());
+ }
+
protected void checkEmpty(Topic topic) throws Exception
{
ObjectName destObjectName = new ObjectName("jboss.messaging.destination:service=Topic,name=" + topic.getTopicName());
@@ -185,6 +194,14 @@
return expected == messageCount.intValue();
}
+ protected int getMessageCount(String queueName) throws Exception
+ {
+ ObjectName destObjectName =
+ new ObjectName("jboss.messaging.destination:service=Queue,name=" + queueName);
+ Integer messageCount = (Integer)ServerManagement.getAttribute(destObjectName, "MessageCount");
+ return messageCount.intValue();
+ }
+
protected void drainDestination(ConnectionFactory cf, Destination dest) throws Exception
{
Connection conn = null;
Modified: trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2007-07-25 10:43:58 UTC (rev 2925)
+++ trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2007-07-25 19:13:28 UTC (rev 2926)
@@ -7,7 +7,6 @@
import org.jboss.jms.client.JBossConnectionFactory;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java 2007-07-25 10:43:58 UTC (rev 2925)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java 2007-07-25 19:13:28 UTC (rev 2926)
@@ -27,7 +27,6 @@
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
-import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
@@ -58,24 +57,38 @@
super(name);
}
- protected void setUp() throws Exception
+ private static ObjectName sourceProviderLoader;
+
+ private static ObjectName targetProviderLoader;
+
+ public void setUp() throws Exception
{
- if (!ServerManagement.isRemote())
- {
- fail("Test should only be run in a remote configuration");
- }
-
- nodeCount = 3;
-
- super.setUp();
+ boolean first = firstTime;
+
+ super.setUp();
+
+ if (first)
+ {
+ Properties props1 = new Properties();
+ props1.putAll(ServerManagement.getJNDIEnvironment(0));
+
+ Properties props2 = new Properties();
+ props2.putAll(ServerManagement.getJNDIEnvironment(1));
+
+ installJMSProviderLoader(0, props1, "/XAConnectionFactory", "adaptor1");
+
+ installJMSProviderLoader(0, props2, "/XAConnectionFactory", "adaptor2");
+
+ sourceProviderLoader = new ObjectName("jboss.messaging:service=JMSProviderLoader,name=adaptor1");
+ targetProviderLoader = new ObjectName("jboss.messaging:service=JMSProviderLoader,name=adaptor2");
+ }
}
- protected void tearDown() throws Exception
+ public void tearDown() throws Exception
{
- super.tearDown();
+ super.tearDown();
}
-
public void testStopStartPauseResume() throws Exception
{
Connection connSource = null;
@@ -86,27 +99,8 @@
try
{
- ServerManagement.deployQueue("sourceQueue", 1);
- ServerManagement.deployQueue("targetQueue", 2);
-
- Properties props1 = new Properties();
- props1.putAll(ServerManagement.getJNDIEnvironment(1));
-
- Properties props2 = new Properties();
- props2.putAll(ServerManagement.getJNDIEnvironment(2));
-
- installJMSProviderLoader(0, props1, "/XAConnectionFactory", "adaptor1");
-
- installJMSProviderLoader(0, props2, "/XAConnectionFactory", "adaptor2");
-
- log.info("Deploying bridge");
-
- ObjectName sourceProviderLoader = new ObjectName("jboss.messaging:service=JMSProviderLoader,name=adaptor1");
- ObjectName targetProviderLoader = new ObjectName("jboss.messaging:service=JMSProviderLoader,name=adaptor2");
-
-
on = deployBridge(0, "Bridge1", sourceProviderLoader, targetProviderLoader,
- "/queue/sourceQueue", "/queue/targetQueue",
+ "/queue/sourceQueue", "/queue/destQueue",
null, null, null, null,
Bridge.QOS_AT_MOST_ONCE, null, 1,
-1, null, null, 5000, -1, false);
@@ -115,18 +109,7 @@
ServerManagement.getServer(0).invoke(on, "create", new Object[0], new String[0]);
log.info("Created bridge");
-
- InitialContext icSource = new InitialContext(props1);
- InitialContext icTarget = new InitialContext(props2);
-
- ConnectionFactory cf0 = (ConnectionFactory)icSource.lookup("/XAConnectionFactory");
-
- ConnectionFactory cf1 = (ConnectionFactory)icTarget.lookup("/XAConnectionFactory");
-
- Destination destSource = (Destination)icSource.lookup("/queue/sourceQueue");
-
- Destination destTarget = (Destination)icTarget.lookup("/queue/targetQueue");
-
+
connSource = cf0.createConnection();
connTarget = cf1.createConnection();
@@ -139,11 +122,11 @@
Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessSource.createProducer(destSource);
+ MessageProducer prod = sessSource.createProducer(sourceQueue);
Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessTarget.createConsumer(destTarget);
+ MessageConsumer cons = sessTarget.createConsumer(destQueue);
for (int i = 0; i < NUM_MESSAGES; i++)
{
@@ -154,10 +137,8 @@
//It's stopped so no messages should be received
- Message m = cons.receive(2000);
+ checkEmpty(destQueue, 1);
- assertNull(m);
-
//Start it
log.info("Starting bridge");
@@ -175,11 +156,8 @@
assertEquals("message" + i, tm.getText());
}
- m = cons.receive(2000);
-
- assertNull(m);
-
-
+ checkEmpty(destQueue, 1);
+
//Send some more
for (int i = NUM_MESSAGES; i < 2 * NUM_MESSAGES; i++)
@@ -200,10 +178,8 @@
assertEquals("message" + i, tm.getText());
}
- m = cons.receive(2000);
+ checkEmpty(destQueue, 1);
- assertNull(m);
-
//Pause it
ServerManagement.getServer(0).invoke(on, "pause", new Object[0], new String[0]);
@@ -223,10 +199,8 @@
//These shouldn't be received
- m = cons.receive(2000);
+ checkEmpty(destQueue, 1);
- assertNull(m);
-
// Resume
ServerManagement.getServer(0).invoke(on, "resume", new Object[0], new String[0]);
@@ -242,10 +216,8 @@
assertEquals("message" + i, tm.getText());
}
- m = cons.receive(2000);
+ checkEmpty(destQueue, 1);
- assertNull(m);
-
isPaused = ((Boolean)ServerManagement.getAttribute(on, "Paused")).booleanValue();
assertFalse(isPaused);
@@ -256,14 +228,7 @@
boolean isStarted = ((Boolean)ServerManagement.getAttribute(on, "Started")).booleanValue();
- assertFalse(isStarted);
-
- MessageConsumer cons2 = sessSource.createConsumer(destSource);
-
- m = cons2.receive(2000);
-
- assertNull(m);
-
+ assertFalse(isStarted);
}
finally
{
@@ -289,28 +254,6 @@
{
//Ignore
}
-
- try
- {
- ServerManagement.undeployQueue("sourceQueue", 1);
- }
- catch (Exception e)
- {
- //Ignore
- }
-
- try
- {
- ServerManagement.undeployQueue("targetQueue", 2);
- }
- catch (Exception e)
- {
- //Ignore
- }
-
- uninstallJMSProviderLoader(0, "adaptor1");
-
- uninstallJMSProviderLoader(0, "adaptor2");
}
}
@@ -319,27 +262,9 @@
ObjectName on = null;
try
- {
- ServerManagement.deployQueue("sourceQueue", 1);
- ServerManagement.deployQueue("targetQueue", 2);
-
- Thread.sleep(5000);
-
- Properties props1 = new Properties();
- props1.putAll(ServerManagement.getJNDIEnvironment(1));
-
- Properties props2 = new Properties();
- props2.putAll(ServerManagement.getJNDIEnvironment(2));
-
- installJMSProviderLoader(0, props1, "/XAConnectionFactory", "adaptor1");
-
- installJMSProviderLoader(0, props2, "/XAConnectionFactory", "adaptor2");
-
- ObjectName sourceProviderLoader = new ObjectName("jboss.messaging:service=JMSProviderLoader,name=adaptor1");
- ObjectName targetProviderLoader = new ObjectName("jboss.messaging:service=JMSProviderLoader,name=adaptor2");
-
+ {
on = deployBridge(0, "Bridge2", sourceProviderLoader, targetProviderLoader,
- "/queue/sourceQueue", "/queue/targetQueue",
+ "/queue/sourceQueue", "/queue/destQueue",
null, null, null, null,
Bridge.QOS_ONCE_AND_ONLY_ONCE, null, 1,
-1, null, null, 5000, -1, false);
@@ -380,11 +305,11 @@
{
String destLookup = (String)ServerManagement.getAttribute(on, "TargetDestinationLookup");
- assertEquals("/queue/targetQueue", destLookup);
+ assertEquals("/queue/destQueue", destLookup);
ServerManagement.setAttribute(on, "TargetDestinationLookup", "/queue/WibbleQueue");
destLookup = (String)ServerManagement.getAttribute(on, "TargetDestinationLookup");
assertEquals("/queue/WibbleQueue", destLookup);
- ServerManagement.setAttribute(on, "TargetDestinationLookup", "/queue/targetQueue");
+ ServerManagement.setAttribute(on, "TargetDestinationLookup", "/queue/destQueue");
}
{
@@ -526,10 +451,10 @@
{
String destLookup = (String)ServerManagement.getAttribute(on, "TargetDestinationLookup");
- assertEquals("/queue/targetQueue", destLookup);
+ assertEquals("/queue/destQueue", destLookup);
ServerManagement.setAttribute(on, "TargetDestinationLookup", "/queue/WibbleQueue");
destLookup = (String)ServerManagement.getAttribute(on, "TargetDestinationLookup");
- assertEquals("/queue/targetQueue", destLookup);
+ assertEquals("/queue/destQueue", destLookup);
}
{
@@ -628,13 +553,17 @@
assertEquals(-1, maxRetries.intValue());
}
+ Properties props1 = new Properties();
+ props1.putAll(ServerManagement.getJNDIEnvironment(0));
+ Properties props2 = new Properties();
+ props2.putAll(ServerManagement.getJNDIEnvironment(1));
InitialContext icSource = new InitialContext(props1);
InitialContext icTarget = new InitialContext(props2);
log.trace("Checking bridged bridge");
checkBridged(icSource, icTarget, "/ConnectionFactory", "/ConnectionFactory",
- "/queue/sourceQueue", "/queue/targetQueue");
+ "/queue/sourceQueue", "/queue/destQueue");
log.trace("Checked bridge");
@@ -653,28 +582,6 @@
{
//Ignore
}
-
- try
- {
- ServerManagement.undeployQueue("sourceQueue", 1);
- }
- catch (Exception e)
- {
- //Ignore
- }
-
- try
- {
- ServerManagement.undeployQueue("targetQueue", 2);
- }
- catch (Exception e)
- {
- //Ignore
- }
-
- uninstallJMSProviderLoader(0, "adaptor1");
-
- uninstallJMSProviderLoader(0, "adaptor2");
}
}
@@ -790,17 +697,6 @@
assertEquals("message" + i, tm.getText());
}
-
- Message m = cons.receive(1000);
-
- assertNull(m);
-
- MessageConsumer cons2 = sessSource.createConsumer(destSource);
-
- m = cons2.receive(1000);
-
- assertNull(m);
-
}
finally
{
@@ -838,13 +734,4 @@
ServerManagement.getServer(0).deploy(config);
}
- private void uninstallJMSProviderLoader(int server, String name) throws Exception
- {
- ObjectName on = new ObjectName("jboss.messaging:service=JMSProviderLoader,name=" + name);
-
- log.info("Uninstalling bridge:" + name);
-
- ServerManagement.getServer(0).undeploy(on);
- }
-
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java 2007-07-25 10:43:58 UTC (rev 2925)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java 2007-07-25 19:13:28 UTC (rev 2926)
@@ -38,7 +38,6 @@
import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.server.bridge.Bridge;
import org.jboss.logging.Logger;
-import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.tm.TransactionManagerLocator;
/**
@@ -58,22 +57,7 @@
{
super(name);
}
-
- protected void setUp() throws Exception
- {
- if (!ServerManagement.isRemote())
- {
- fail("Test should only be run in a remote configuration");
- }
-
- super.setUp();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
+
// MaxBatchSize but no MaxBatchTime
public void testNoMaxBatchTime_AtMostOnce_P() throws Exception
@@ -343,8 +327,6 @@
try
{
- setUpAdministeredObjects(true);
-
int qosMode = Bridge.QOS_AT_MOST_ONCE;
int batchSize = 10;
@@ -518,8 +500,6 @@
try
{
- setUpAdministeredObjects(true);
-
final int NUM_MESSAGES = 10;
String selector = "vegetable='radish'";
@@ -580,26 +560,12 @@
{
if (connSource != null)
{
- try
- {
- connSource.close();
- }
- catch (Exception e)
- {
- log.error("Failed to close connection", e);
- }
+ connSource.close();
}
if (connTarget != null)
{
- try
- {
- connTarget.close();
- }
- catch (Exception e)
- {
- log.error("Failed to close connection", e);
- }
+ connTarget.close();
}
if (bridge != null)
@@ -607,23 +573,7 @@
bridge.stop();
}
- try
- {
- ServerManagement.undeployQueue("sourceQueue", 0);
- }
- catch (Exception e)
- {
- log.error("Failed to undeploy", e);
- }
-
- try
- {
- ServerManagement.undeployQueue("destQueue", 1);
- }
- catch (Exception e)
- {
- log.error("Failed to undeploy", e);
- }
+ removeAllMessages(sourceQueue.getQueueName(), true, 0);
}
}
@@ -645,9 +595,7 @@
mgr.begin();
started = mgr.getTransaction();
-
- setUpAdministeredObjects(true);
-
+
final int NUM_MESSAGES = 10;
bridge = new Bridge(cff0, cff1, sourceTopic, destQueue,
@@ -660,10 +608,7 @@
this.sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, false);
- this.checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES);
-
- this.checkNoneReceived(cf1, destQueue, 2000);
-
+ this.checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES);
}
finally
{
@@ -702,9 +647,7 @@
Bridge bridge = null;
try
- {
- this.setUpAdministeredObjects(true);
-
+ {
final int NUM_MESSAGES = 10;
bridge = new Bridge(cff0, cff1, sourceTopic, destQueue,
@@ -717,9 +660,7 @@
sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, false);
- checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES);
-
- this.checkNoneReceived(cf1, destQueue, 2000);
+ checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES);
}
finally
{
@@ -736,8 +677,6 @@
try
{
- this.setUpAdministeredObjects(true);
-
final int NUM_MESSAGES = 10;
bridge = new Bridge(cff0, cff1, sourceTopic, destQueue,
@@ -750,10 +689,7 @@
sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, true);
- checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES);
-
- this.checkNoneReceived(cf1, destQueue, 2000);
-
+ checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES);
}
finally
{
@@ -761,63 +697,16 @@
{
bridge.stop();
}
- }
- }
-
- public void testTimeout() throws Exception
- {
- Bridge bridge = null;
-
- try
- {
- this.setUpAdministeredObjects(true);
- final int NUM_MESSAGES = 10;
-
- bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
- null, null, null, null,
- null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
- NUM_MESSAGES, -1,
- null, null, false);
-
- bridge.start();
-
- boolean persistent = true;
-
- //Send half the messges
-
- this.sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent);
-
- //Verify none are received
-
- this.checkNoneReceived(cf1, destQueue, 2000);
-
- log.info("Waiting");
- Thread.sleep(120000);
-
- //Send the other half
-
- this.sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent);
-
- //This should now be receivable
-
- this.checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES);
-
-
- this.checkNoneReceived(cf1, destQueue, 2000);
-
- this.checkNoneReceived(cf0, sourceQueue, 2000);
- }
- finally
- {
- if (bridge != null)
- {
- log.info("Stopping bridge");
- bridge.stop();
- }
+ //Now unsubscribe
+ Connection conn = cf0.createConnection();
+ conn.setClientID("clientid123");
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ sess.unsubscribe("subTest");
+ conn.close();
}
}
-
+
public void testMessageIDInHeader() throws Exception
{
Bridge bridge = null;
@@ -828,8 +717,6 @@
try
{
- this.setUpAdministeredObjects(true);
-
final int NUM_MESSAGES = 10;
bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
@@ -974,8 +861,6 @@
try
{
- this.setUpAdministeredObjects(true);
-
final int NUM_MESSAGES = 10;
bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
@@ -1064,9 +949,7 @@
Thread t = null;
try
- {
- this.setUpAdministeredObjects(true);
-
+ {
bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
null, null, null, null,
null, 5000, 10, qosMode,
@@ -1081,7 +964,7 @@
MessageProducer prod = sessSend.createProducer(sourceQueue);
- final int NUM_MESSAGES = 2000;
+ final int NUM_MESSAGES = 250;
StressSender sender = new StressSender();
sender.sess = sessSend;
@@ -1094,11 +977,7 @@
t.start();
this.checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES);
-
- this.checkNoneReceived(cf1, destQueue, 2000);
-
- this.checkNoneReceived(cf0, sourceQueue, 2000);
-
+
t.join();
if (sender.ex != null)
@@ -1144,9 +1023,7 @@
Thread t = null;
try
- {
- this.setUpAdministeredObjects(true);
-
+ {
bridge = new Bridge(cff0, cff0, sourceQueue, localDestQueue,
null, null, null, null,
null, 5000, 10, qosMode,
@@ -1174,11 +1051,7 @@
t.start();
this.checkAllMessageReceivedInOrder(cf0, localDestQueue, 0, NUM_MESSAGES);
-
- this.checkNoneReceived(cf0, localDestQueue, 2000);
-
- this.checkNoneReceived(cf0, sourceQueue, 2000);
-
+
t.join();
if (sender.ex != null)
@@ -1221,8 +1094,6 @@
try
{
- this.setUpAdministeredObjects(true);
-
final int NUM_MESSAGES = 10;
bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
@@ -1239,7 +1110,7 @@
//Verify none are received
- this.checkNoneReceived(cf1, destQueue, 2000);
+ this.checkEmpty(destQueue, 1);
//Send the other half
@@ -1264,12 +1135,6 @@
this.checkAllMessageReceivedInOrder(cf1, destQueue, NUM_MESSAGES, 1);
this.checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES - 1);
-
- //Make sure no messages are left
-
- this.checkNoneReceived(cf1, destQueue, 2000);
-
- this.checkNoneReceived(cf0, sourceQueue, 2000);
}
finally
{
@@ -1281,17 +1146,12 @@
}
}
-
-
-
private void testNoMaxBatchTimeSameServer(int qosMode, boolean persistent) throws Exception
{
Bridge bridge = null;
try
{
- this.setUpAdministeredObjects(true);
-
final int NUM_MESSAGES = 10;
bridge = new Bridge(cff0, cff0, sourceQueue, localDestQueue,
@@ -1304,7 +1164,7 @@
this.sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent);
- this.checkNoneReceived(cf1, destQueue, 2000);
+ this.checkEmpty(destQueue, 1);
//Send the other half
@@ -1315,9 +1175,9 @@
this.checkAllMessageReceivedInOrder(cf0, localDestQueue, 0, NUM_MESSAGES);
- this.checkNoneReceived(cf0, localDestQueue, 2000);
+ this.checkEmpty(localDestQueue, 0);
- this.checkNoneReceived(cf0, sourceQueue, 2000);
+ this.checkEmpty(sourceQueue, 0);
//Send another batch with one more than batch size
@@ -1334,12 +1194,6 @@
this.checkAllMessageReceivedInOrder(cf0, localDestQueue, NUM_MESSAGES, 1);
this.checkAllMessageReceivedInOrder(cf0, localDestQueue, 0, NUM_MESSAGES - 1);
-
- //Make sure no messages are left
-
- this.checkNoneReceived(cf0, localDestQueue, 2000);
-
- this.checkNoneReceived(cf0, sourceQueue, 2000);
}
finally
{
@@ -1356,15 +1210,13 @@
try
{
- this.setUpAdministeredObjects(true);
-
final long MAX_BATCH_TIME = 3000;
final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it
bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
null, null, null, null,
- null, 5000, 10, qosMode,
+ null, 3000, 10, qosMode,
MAX_BATCH_SIZE, MAX_BATCH_TIME,
null, null, false);
@@ -1378,22 +1230,11 @@
//Verify none are received
- this.checkNoneReceived(cf1, destQueue, 2000);
+ this.checkEmpty(destQueue, 1);
- //Wait a bit longer
-
- Thread.sleep(1500);
-
//Messages should now be receivable
- this.checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES);
-
- this.checkNoneReceived(cf1, destQueue, 2000);
-
- //Make sure no messages are left in the source dest
-
- this.checkNoneReceived(cf0, sourceQueue, 2000);
-
+ this.checkAllMessageReceivedInOrder(cf1, destQueue, 0, NUM_MESSAGES);
}
finally
{
@@ -1410,15 +1251,13 @@
try
{
- this.setUpAdministeredObjects(true);
-
final long MAX_BATCH_TIME = 3000;
final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it
bridge = new Bridge(cff0, cff0, sourceQueue, localDestQueue,
null, null, null, null,
- null, 5000, 10, qosMode,
+ null, 3000, 10, qosMode,
MAX_BATCH_SIZE, MAX_BATCH_TIME,
null, null, false);
@@ -1434,22 +1273,11 @@
//Verify none are received
- this.checkNoneReceived(cf0, localDestQueue, 2000);
+ this.checkEmpty(localDestQueue, 0);;
- //Wait a bit longer
-
- Thread.sleep(1500);
-
//Messages should now be receivable
this.checkAllMessageReceivedInOrder(cf0, localDestQueue, 0, NUM_MESSAGES);
-
- this.checkNoneReceived(cf0, localDestQueue, 2000);
-
- //Make sure no messages are left in the source dest
-
- this.checkNoneReceived(cf0, sourceQueue, 2000);
-
}
finally
{
Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java 2007-07-25 10:43:58 UTC (rev 2925)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java 2007-07-25 19:13:28 UTC (rev 2926)
@@ -29,7 +29,6 @@
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
-import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
@@ -60,17 +59,17 @@
{
private static final Logger log = Logger.getLogger(BridgeTestBase.class);
- protected int nodeCount = 2;
+ protected static ServiceContainer sc;
- protected ServiceContainer sc;
+ protected static ConnectionFactoryFactory cff0, cff1;
- protected ConnectionFactoryFactory cff0, cff1;
+ protected static ConnectionFactory cf0, cf1;
- protected ConnectionFactory cf0, cf1;
+ protected static Queue sourceQueue, destQueue, localDestQueue;
- protected Destination sourceQueue, destQueue, sourceTopic, localDestQueue;
+ protected static Topic sourceTopic;
- protected boolean useArjuna;
+ protected static boolean firstTime = true;
public BridgeTestBase(String name)
{
@@ -79,97 +78,55 @@
protected void setUp() throws Exception
{
- if (!ServerManagement.isRemote())
- {
- throw new IllegalStateException("This test should only be run in remote mode");
- }
-
super.setUp();
-
- log.info("Starting " + nodeCount + " servers");
-
- for (int i = 0; i < nodeCount; i++)
- {
- // make sure all servers are created and started; make sure that database is zapped
- // ONLY for the first server, the others rely on values they expect to find in shared
- // tables; don't clear the database for those.
- ServerManagement.start(i, "all", i == 0);
- }
- //We need a local transaction and recovery manager
- //We must start this after the remote servers have been created or it won't
- //have deleted the database and the recovery manager may attempt to recover transactions
- if (useArjuna)
+ if (firstTime)
{
+ //Start the servers
+
+ ServerManagement.start(0, "all", true);
+
+ ServerManagement.start(1, "all", false);
+
+ ServerManagement.deployQueue("sourceQueue", 0);
+
+ ServerManagement.deployTopic("sourceTopic", 0);
+
+ ServerManagement.deployQueue("localDestQueue", 0);
+
+ ServerManagement.deployQueue("destQueue", 1);
+
+ setUpAdministeredObjects();
+
+ //We need a local transaction and recovery manager
+ //We must start this after the remote servers have been created or it won't
+ //have deleted the database and the recovery manager may attempt to recover transactions
sc = new ServiceContainer("jbossjta");
- }
- else
- {
- sc = new ServiceContainer("transaction");
- }
- sc.start(false);
-
- ServerManagement.undeployQueue("sourceQueue", 0);
-
- ServerManagement.undeployTopic("sourceTopic", 0);
-
- ServerManagement.undeployQueue("localDestQueue", 0);
- ServerManagement.undeployQueue("destQueue", 1);
-
- ServerManagement.deployQueue("sourceQueue", 0);
-
- ServerManagement.deployTopic("sourceTopic", 0);
-
- ServerManagement.deployQueue("localDestQueue", 0);
-
- ServerManagement.deployQueue("destQueue", 1);
+ sc.start(false);
+
+ firstTime = false;
+ }
+
}
+
protected void tearDown() throws Exception
{
- try
- {
- ServerManagement.undeployQueue("sourceQueue", 0);
- }
- catch (Exception e)
- {
- log.error("Failed to undeploy", e);
- }
-
- try
- {
- ServerManagement.undeployTopic("sourceTopic", 0);
- }
- catch (Exception e)
- {
- log.error("Failed to undeploy", e);
- }
-
- try
- {
- ServerManagement.undeployQueue("destQueue", 1);
- }
- catch (Exception e)
- {
- log.error("Failed to undeploy", e);
- }
-
- try
- {
- ServerManagement.undeployQueue("localDestQueue", 0);
- }
- catch (Exception e)
- {
- log.error("Failed to undeploy", e);
- }
+ super.tearDown();
- sc.stop();
+ //sc.stop();
- super.tearDown();
+ checkEmpty(sourceQueue);
+ checkEmpty(localDestQueue);
+ checkEmpty(destQueue, 1);
+
+ // Check no subscriptions left lying around
+
+ checkNoSubscriptions(sourceTopic);
}
- protected void setUpAdministeredObjects(boolean drain) throws Exception
+ protected void setUpAdministeredObjects() throws Exception
{
InitialContext ic0 = null, ic1 = null;
try
@@ -196,16 +153,7 @@
sourceTopic = (Topic)ic0.lookup("/topic/sourceTopic");
- localDestQueue = (Queue)ic0.lookup("/queue/localDestQueue");
-
- if (drain)
- {
- this.drainDestination(cf0, sourceQueue);
-
- this.drainDestination(cf1, destQueue);
-
- this.drainDestination(cf0, localDestQueue);
- }
+ localDestQueue = (Queue)ic0.lookup("/queue/localDestQueue");
}
finally
{
@@ -225,8 +173,6 @@
{
Connection conn = null;
- log.trace("Sending " + numMessages + " messages");
-
try
{
conn = cf.createConnection();
@@ -243,8 +189,6 @@
prod.send(tm);
}
-
- log.trace("Sent the messages");
}
finally
{
@@ -255,44 +199,12 @@
}
}
- protected void checkNoneReceived(ConnectionFactory cf, Destination dest, long timeout) throws Exception
- {
- Connection conn = null;
-
- log.trace("checkNoneReceived");
- try
- {
- conn = cf.createConnection();
-
- conn.start();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sess.createConsumer(dest);
-
- Message m = cons.receive(timeout);
-
- assertNull(m);
-
- log.trace("Check complete");
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- protected void checkMessagesReceived(ConnectionFactory cf, Destination dest, int qosMode, int numMessages) throws Exception
+ protected void checkMessagesReceived(ConnectionFactory cf, Destination dest, int qosMode,
+ int numMessages, boolean longWaitForFirst) throws Exception
{
Connection conn = null;
-
- log.trace("checkMessagesReceived");
-
+
try
{
conn = cf.createConnection();
@@ -308,16 +220,20 @@
Set msgs = new HashSet();
int count = 0;
-
+
+ //We always wait longer for the first one - it may take some time to arrive especially if we are
+ //waiting for recovery to kick in
while (true)
{
- TextMessage tm = (TextMessage)cons.receive(3000);
+ TextMessage tm = (TextMessage)cons.receive(count == 0 ? (longWaitForFirst ? 60000 : 10000) : 5000);
if (tm == null)
{
break;
}
+ log.info("Got message " + tm.getText());
+
msgs.add(tm.getText());
count++;
@@ -360,10 +276,7 @@
protected void checkAllMessageReceivedInOrder(ConnectionFactory cf, Destination dest, int start, int numMessages) throws Exception
{
- Connection conn = null;
-
- log.trace("checkAllMessageReceievedInOrder");
-
+ Connection conn = null;
try
{
conn = cf.createConnection();
@@ -378,14 +291,12 @@
for (int i = 0; i < numMessages; i++)
{
- TextMessage tm = (TextMessage)cons.receive(3000);
+ TextMessage tm = (TextMessage)cons.receive(30000);
assertNotNull(tm);
assertEquals("message" + (i + start), tm.getText());
}
-
- log.trace("Check complete");
}
finally
{
Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java 2007-07-25 10:43:58 UTC (rev 2925)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java 2007-07-25 19:13:28 UTC (rev 2926)
@@ -40,26 +40,7 @@
{
super(name);
}
-
- protected void setUp() throws Exception
- {
- if (!ServerManagement.isRemote())
- {
- fail("Test should only be run in a remote configuration");
- }
-
- useArjuna = false;
-
- super.setUp();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- log.debug(this + " torn down");
- }
-
+
// Crash and reconnect
// Once and only once
@@ -114,7 +95,6 @@
public void testRetryConnectionOnStartup() throws Exception
{
- setUpAdministeredObjects(true);
ServerManagement.kill(1);
Bridge bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
@@ -130,6 +110,9 @@
assertTrue(bridge.isFailed());
ServerManagement.start(1, "all", false);
+ ServerManagement.deployQueue("destQueue", 1);
+ setUpAdministeredObjects();
+
Thread.sleep(3000);
assertTrue(bridge.isStarted());
@@ -160,9 +143,7 @@
Bridge bridge = null;
try
- {
- setUpAdministeredObjects(true);
-
+ {
bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
null, null, null, null,
null, 1000, -1, qosMode,
@@ -179,7 +160,7 @@
//Verify none are received
- checkNoneReceived(cf1, destQueue, 2000);
+ checkEmpty(destQueue, 1);
//Now crash the dest server
@@ -188,8 +169,8 @@
ServerManagement.kill(1);
//Wait a while before starting up to simulate the dest being down for a while
- log.info("Waiting 15 secs before bringing server back up");
- Thread.sleep(10000);
+ log.info("Waiting 5 secs before bringing server back up");
+ Thread.sleep(5000);
log.info("Done wait");
//Restart the server
@@ -199,9 +180,9 @@
ServerManagement.start(1, "all", false);
ServerManagement.deployQueue("destQueue", 1);
-
- setUpAdministeredObjects(false);
+ setUpAdministeredObjects();
+
//Send some more messages
log.info("Sending more messages");
@@ -210,13 +191,7 @@
log.info("Sent messages");
- Thread.sleep(2000);
-
- checkMessagesReceived(cf1, destQueue, qosMode, NUM_MESSAGES);
-
- //Make sure no messages are left in the source dest
-
- this.checkNoneReceived(cf0, sourceQueue, 2000);
+ checkMessagesReceived(cf1, destQueue, qosMode, NUM_MESSAGES, false);
}
finally
{
@@ -249,8 +224,6 @@
try
{
- setUpAdministeredObjects(true);
-
bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
null, null, null, null,
null, 1000, -1, Bridge.QOS_ONCE_AND_ONLY_ONCE,
@@ -259,15 +232,14 @@
bridge.start();
- final int NUM_MESSAGES = 10;
-
+ final int NUM_MESSAGES = 10;
//Send some messages
this.sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent);
//verify none are received
- this.checkNoneReceived(cf1, destQueue, 2000);
+ checkEmpty(destQueue, 1);
//Now crash the dest server
@@ -276,8 +248,8 @@
ServerManagement.kill(1);
//Wait a while before starting up to simulate the dest being down for a while
- log.info("Waiting 15 secs before bringing server back up");
- Thread.sleep(15000);
+ log.info("Waiting 5 secs before bringing server back up");
+ Thread.sleep(5000);
log.info("Done wait");
//Restart the server
@@ -285,19 +257,12 @@
ServerManagement.start(1, "all", false);
ServerManagement.deployQueue("destQueue", 1);
-
- setUpAdministeredObjects(false);
+ setUpAdministeredObjects();
+
sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent);
- checkMessagesReceived(cf1, destQueue, Bridge.QOS_ONCE_AND_ONLY_ONCE, NUM_MESSAGES);
-
- //Make sure no messages are left in the source dest
-
- checkNoneReceived(cf0, sourceQueue, 2000);
-
- log.info("Got here");
-
+ checkMessagesReceived(cf1, destQueue, Bridge.QOS_ONCE_AND_ONLY_ONCE, NUM_MESSAGES, false);
}
finally
{
Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectWithRecoveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectWithRecoveryTest.java 2007-07-25 10:43:58 UTC (rev 2925)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectWithRecoveryTest.java 2007-07-25 19:13:28 UTC (rev 2926)
@@ -48,13 +48,6 @@
protected void setUp() throws Exception
{
- if (!ServerManagement.isRemote())
- {
- fail("Test should only be run in a remote configuration");
- }
-
- useArjuna = true;
-
super.setUp();
//Now install local JMSProviderAdaptor classes
@@ -71,13 +64,13 @@
}
protected void tearDown() throws Exception
- {
+ {
+ super.tearDown();
+
sc.stopRecoveryManager();
sc.uninstallJMSProviderAdaptor("adaptor1");
- super.tearDown();
-
log.debug(this + " torn down");
}
@@ -94,8 +87,6 @@
try
{
- setUpAdministeredObjects(true);
-
final int NUM_MESSAGES = 10;
bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
@@ -130,27 +121,18 @@
ServerManagement.start(1, "all", false);
- log.info("Restarted server");
+ log.info("Restarted server");
ServerManagement.deployQueue("destQueue", 1);
+ this.setUpAdministeredObjects();
+
log.info("Deployed queue");
-
- //Give enough time for transaction recovery to happen
- Thread.sleep(45000);
-
- log.info("Slept");
-
- setUpAdministeredObjects(false);
-
- checkMessagesReceived(cf1, destQueue, Bridge.QOS_ONCE_AND_ONLY_ONCE, NUM_MESSAGES);
- //Make sure no messages are left in the source dest
-
- this.checkNoneReceived(cf0, sourceQueue, 5000);
-
- log.info("Got here");
-
+ log.info("*** waiting for recovery");
+
+ //There may be a long wait for the first time (need to let recovery kick in)
+ checkMessagesReceived(cf1, destQueue, Bridge.QOS_ONCE_AND_ONLY_ONCE, NUM_MESSAGES, true);
}
finally
{
@@ -168,9 +150,6 @@
}
}
-
-
- // Inner classes -------------------------------------------------------------------
-
+ // Inner classes -------------------------------------------------------------------
}
More information about the jboss-cvs-commits
mailing list