ARTEMIS-893 Fix FailoverTransactionTest.testWaitForMissingRedeliveries

This commit is contained in:
Howard Gao 2016-12-15 23:33:01 +08:00 committed by Clebert Suconic
parent 0c18c343e9
commit 8348cdd2b6
1 changed files with 48 additions and 34 deletions

View File

@ -385,6 +385,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
LOG.info("Received: " + msg); LOG.info("Received: " + msg);
Assert.assertNull("no messges left dangling but got: " + msg, msg); Assert.assertNull("no messges left dangling but got: " + msg, msg);
connection.close(); connection.close();
proxy.close();
} }
@Test @Test
@ -857,6 +858,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
broker.stop(); broker.stop();
broker = createBroker(); broker = createBroker();
broker.start(); broker.start();
Assert.assertNotNull("should get rolledback message from original restarted broker", consumer.receive(20000)); Assert.assertNotNull("should get rolledback message from original restarted broker", consumer.receive(20000));
} finally { } finally {
connection.close(); connection.close();
@ -872,6 +874,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")?jms.consumerFailoverRedeliveryWaitPeriod=30000"); ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")?jms.consumerFailoverRedeliveryWaitPeriod=30000");
configureConnectionFactory(cf); configureConnectionFactory(cf);
Connection connection = cf.createConnection(); Connection connection = cf.createConnection();
try {
connection.start(); connection.start();
final Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); final Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
final Queue destination = producerSession.createQueue(QUEUE_NAME); final Queue destination = producerSession.createQueue(QUEUE_NAME);
@ -890,6 +893,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
broker.start(); broker.start();
final CountDownLatch commitDone = new CountDownLatch(1); final CountDownLatch commitDone = new CountDownLatch(1);
final CountDownLatch gotException = new CountDownLatch(1);
// will block pending re-deliveries // will block pending re-deliveries
new Thread() { new Thread() {
@Override @Override
@ -898,7 +902,14 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
try { try {
consumerSession.commit(); consumerSession.commit();
commitDone.countDown(); commitDone.countDown();
} catch (JMSException ignored) { }
catch (JMSException ignored) {
System.out.println("--->err: got exfeption:");
ignored.printStackTrace();
gotException.countDown();
}
finally {
commitDone.countDown();
} }
} }
}.start(); }.start();
@ -908,10 +919,13 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
broker.start(); broker.start();
Assert.assertTrue("commit was successful", commitDone.await(30, TimeUnit.SECONDS)); Assert.assertTrue("commit was successful", commitDone.await(30, TimeUnit.SECONDS));
Assert.assertTrue("got exception on commit", gotException.await(30, TimeUnit.SECONDS));
Assert.assertNull("should not get committed message", consumer.receive(5000)); Assert.assertNotNull("should get failed committed message", consumer.receive(5000));
} finally {
connection.close(); connection.close();
} }
}
@Test @Test
public void testReDeliveryWhilePending() throws Exception { public void testReDeliveryWhilePending() throws Exception {