AMQ-6411 - tidy up latch between runs. Have not seen repeat of npe yet

This commit is contained in:
gtully 2016-09-01 16:53:02 +01:00
parent f8bc19b96d
commit a9c7f7122b

View File

@ -115,9 +115,9 @@ public class AMQ4952Test {
protected ActiveMQQueue QUEUE_NAME = new ActiveMQQueue("duptest.store");
private final CountDownLatch stopConsumerBroker = new CountDownLatch(1);
private final CountDownLatch consumerBrokerRestarted = new CountDownLatch(1);
private final CountDownLatch consumerRestartedAndMessageForwarded = new CountDownLatch(1);
private CountDownLatch stopConsumerBroker;
private CountDownLatch consumerBrokerRestarted;
private CountDownLatch consumerRestartedAndMessageForwarded;
private EmbeddedDataSource localDataSource;
@ -134,6 +134,15 @@ public class AMQ4952Test {
System.setProperty("derby.system.home", new File(IOHelper.getDefaultDataDirectory()).getCanonicalPath());
}
public void repeat() throws Exception {
for (int i=0; i<10; i++) {
LOG.info("Iteration: " + i);
testConsumerBrokerRestart();
tearDown();
setUp();
}
}
@Test
public void testConsumerBrokerRestart() throws Exception {
@ -155,7 +164,11 @@ public class AMQ4952Test {
MessageConsumer messageConsumer = consumerSession.createConsumer(QUEUE_NAME);
while (true) {
TextMessage textMsg = (TextMessage) messageConsumer.receive(5000);
TextMessage textMsg = (TextMessage) messageConsumer.receive(1000);
if (textMsg == null) {
textMsg = (TextMessage) messageConsumer.receive(4000);
}
if (textMsg == null) {
return receivedMessageCount;
@ -266,6 +279,10 @@ public class AMQ4952Test {
@Before
public void setUp() throws Exception {
LOG.debug("Running with enableCursorAudit set to {}", this.enableCursorAudit);
stopConsumerBroker = new CountDownLatch(1);
consumerBrokerRestarted = new CountDownLatch(1);
consumerRestartedAndMessageForwarded = new CountDownLatch(1);
doSetUp();
}