mirror of https://github.com/apache/activemq.git
make test more tolerant to slower machines, resolve intermittent failure
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@798852 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6f3c99991d
commit
763e331318
|
@ -26,6 +26,7 @@ import org.apache.activemq.command.ConsumerInfo;
|
|||
import org.apache.activemq.command.Message;
|
||||
import org.apache.activemq.command.ProducerInfo;
|
||||
import org.apache.activemq.command.SessionInfo;
|
||||
import org.apache.activemq.util.Wait;
|
||||
|
||||
public class DemandForwardingBridgeTest extends NetworkTestSupport {
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class DemandForwardingBridgeTest extends NetworkTestSupport {
|
|||
destination = createDestinationInfo(connection1, connectionInfo1, destinationType);
|
||||
|
||||
// Start a consumer on a remote broker
|
||||
StubConnection connection2 = createRemoteConnection();
|
||||
final StubConnection connection2 = createRemoteConnection();
|
||||
ConnectionInfo connectionInfo2 = createConnectionInfo();
|
||||
SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
|
||||
connection2.send(connectionInfo2);
|
||||
|
@ -73,11 +74,14 @@ public class DemandForwardingBridgeTest extends NetworkTestSupport {
|
|||
// Now create remote consumer that should cause message to move to this
|
||||
// remote consumer.
|
||||
ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
|
||||
connection2.send(consumerInfo2);
|
||||
connection2.request(consumerInfo2);
|
||||
|
||||
// Make sure the message was delivered via the remote.
|
||||
m = receiveMessage(connection2);
|
||||
assertNotNull(m);
|
||||
assertTrue("message was received", Wait.waitFor(new Wait.Condition() {
|
||||
public boolean isSatisified() throws Exception {
|
||||
return receiveMessage(connection2) != null;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void initCombosForTestAddConsumerThenSend() {
|
||||
|
|
|
@ -32,9 +32,11 @@ public class Wait {
|
|||
|
||||
public static boolean waitFor(final Condition condition, final long duration) throws Exception {
|
||||
final long expiry = System.currentTimeMillis() + duration;
|
||||
while (!condition.isSatisified() && System.currentTimeMillis() < expiry) {
|
||||
boolean conditionSatisified = condition.isSatisified();
|
||||
while (!conditionSatisified && System.currentTimeMillis() < expiry) {
|
||||
Thread.sleep(1000);
|
||||
conditionSatisified = condition.isSatisified();
|
||||
}
|
||||
return condition.isSatisified();
|
||||
return conditionSatisified;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue