On my old dual core Macbook this test sometimes fails because the listener has a four second wait and the test only allocates five seconds for processing of the messages to complete after the producer transaction commit is called.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1437739 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-01-23 21:21:23 +00:00
parent 2dd8b61a4b
commit 6d2f262ceb
1 changed files with 13 additions and 5 deletions

View File

@ -70,7 +70,7 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
long done = System.currentTimeMillis() + getMaxTestTime();
synchronized (testMutex) {
while (!testMutex.testCompleted && System.currentTimeMillis() < done) {
testMutex.wait(TimeUnit.SECONDS.toMillis(5));
testMutex.wait(TimeUnit.SECONDS.toMillis(10));
}
}
@ -84,6 +84,7 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
return new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
}
@Override
protected void setUp() throws Exception {
setAutoFail(true);
bindAddress = "tcp://localhost:0";
@ -98,12 +99,14 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
connection.start();
}
@Override
protected void tearDown() throws Exception {
connectionConsumer.close();
connection.close();
super.tearDown();
}
@Override
protected BrokerService createBroker() throws Exception {
BrokerService answer = super.createBroker();
PolicyMap policyMap = new PolicyMap();
@ -130,6 +133,7 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
serverSession = new TestServerSession(this);
}
@Override
public ServerSession getServerSession() throws JMSException {
synchronized (this) {
if (serverSessionInUse) {
@ -155,13 +159,16 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
session.setMessageListener(new TestMessageListener());
}
@Override
public Session getSession() throws JMSException {
return session;
}
@Override
public void start() throws JMSException {
// use a separate thread to process the message asynchronously
new Thread() {
@Override
public void run() {
// let the session deliver the message
session.run();
@ -187,6 +194,7 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
}
private class TestMessageListener implements MessageListener {
@Override
public void onMessage(Message message) {
try {
String text = ((TextMessage)message).getText();