From 3307d575286bdd2c282ac19091b1f4c1dcee067f Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Wed, 2 May 2012 10:18:29 +0000 Subject: [PATCH] ensure test is more deterministic and does not hang ci build git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1332977 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/activemq/bugs/AMQ2571Test.java | 13 +++++++------ .../usecases/DurableSubscriptionOfflineTest.java | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2571Test.java b/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2571Test.java index ee2b3fe9cb..533ae0c939 100644 --- a/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2571Test.java +++ b/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2571Test.java @@ -32,6 +32,7 @@ public class AMQ2571Test extends EmbeddedBrokerTestSupport { public void testTempQueueClosing() { try { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(this.bindAddress); + connectionFactory.setAlwaysSyncSend(true); // First create session that will own the TempQueue Connection connectionA = connectionFactory.createConnection(); @@ -56,13 +57,13 @@ public class AMQ2571Test extends EmbeddedBrokerTestSupport { Thread sendingThread = new Thread(new Runnable() { public void run() { try { - for (int i = 0; i < 100000; i++) { + long end = System.currentTimeMillis() + 5*60*1000; + // wait for exception on send + while (System.currentTimeMillis() < end) { producerB.send(message); } } catch (JMSException e) { - // We don't get this exception every time. - // Not getting it means that we don't know if the - // creator of the TempQueue has disconnected. + e.printStackTrace(); } } }); @@ -72,7 +73,7 @@ public class AMQ2571Test extends EmbeddedBrokerTestSupport { // Now close connection A. This will remove the TempQueue. connectionA.close(); // Wait for the thread to finish. - sendingThread.join(); + sendingThread.join(5*60*1000); // Sleep for a while to make sure that we should know that the // TempQueue is gone. @@ -95,6 +96,7 @@ public class AMQ2571Test extends EmbeddedBrokerTestSupport { @Override protected void setUp() throws Exception { bindAddress = "vm://localhost"; + setAutoFail(true); super.setUp(); } @@ -103,7 +105,6 @@ public class AMQ2571Test extends EmbeddedBrokerTestSupport { BrokerService answer = new BrokerService(); answer.setPersistent(false); answer.setUseJmx(false); - answer.addConnector(bindAddress); return answer; } } \ No newline at end of file diff --git a/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java b/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java index 9a0e117c44..c8596a2d25 100644 --- a/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java @@ -1610,7 +1610,7 @@ public class DurableSubscriptionOfflineTest extends org.apache.activemq.TestSupp } executorService.shutdown(); executorService.awaitTermination(10, TimeUnit.MINUTES); - assertTrue("No exceptions", exceptions.isEmpty()); + assertTrue("No exceptions " + exceptions.elements(), exceptions.isEmpty()); } public static class Listener implements MessageListener { @@ -1649,6 +1649,7 @@ public class DurableSubscriptionOfflineTest extends org.apache.activemq.TestSupp } } catch (JMSException e) { + e.printStackTrace(); exceptions.add(e); } }