Fix a couple of tests that sleep for longer than necessary, use the Wait object when possible.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1190615 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2011-10-28 21:57:37 +00:00
parent 9ee2967220
commit f0ed5d0c72
2 changed files with 14 additions and 6 deletions

View File

@ -22,6 +22,8 @@ import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.util.Wait;
import org.apache.activemq.util.Wait.Condition;
public class DestinationGCTest extends EmbeddedBrokerTestSupport {
@ -44,8 +46,12 @@ public class DestinationGCTest extends EmbeddedBrokerTestSupport {
public void testDestinationGc() throws Exception {
assertEquals(1, broker.getAdminView().getQueues().length);
Thread.sleep(7000);
assertEquals(0, broker.getAdminView().getQueues().length);
assertTrue("After GC runs the Queue should be empty.", Wait.waitFor(new Condition() {
@Override
public boolean isSatisified() throws Exception {
return broker.getAdminView().getQueues().length == 0;
}
}));
}
public void testDestinationGcLimit() throws Exception {
@ -59,7 +65,11 @@ public class DestinationGCTest extends EmbeddedBrokerTestSupport {
Thread.sleep(7000);
int queues = broker.getAdminView().getQueues().length;
assertTrue(queues > 0 && queues < 5);
Thread.sleep(10000);
assertEquals(0, broker.getAdminView().getQueues().length);
assertTrue("After GC runs the Queue should be empty.", Wait.waitFor(new Condition() {
@Override
public boolean isSatisified() throws Exception {
return broker.getAdminView().getQueues().length == 0;
}
}));
}
}

View File

@ -57,8 +57,6 @@ public class AMQ2383Test {
assertEquals(sentMsg, receivedMsg);
Thread.sleep(10000);
producerConnection.close();
consumerConnection.close();
}