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
This commit is contained in:
Gary Tully 2012-05-02 10:18:29 +00:00
parent 937c1e8cbc
commit 3307d57528
2 changed files with 9 additions and 7 deletions

View File

@ -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;
}
}

View File

@ -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);
}
}