Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 29BB8200BF0 for ; Thu, 15 Dec 2016 23:51:30 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 284B9160B13; Thu, 15 Dec 2016 22:51:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4B20F160B15 for ; Thu, 15 Dec 2016 23:51:29 +0100 (CET) Received: (qmail 74457 invoked by uid 500); 15 Dec 2016 22:51:28 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 74438 invoked by uid 99); 15 Dec 2016 22:51:28 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Dec 2016 22:51:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4F1BCE7DFC; Thu, 15 Dec 2016 22:51:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Thu, 15 Dec 2016 22:51:29 -0000 Message-Id: <69af474bc217475387100338f9d1979a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] activemq-artemis git commit: ARTEMIS-893 Fix FailoverTransactionTest.testWaitForMissingRedeliveries archived-at: Thu, 15 Dec 2016 22:51:30 -0000 ARTEMIS-893 Fix FailoverTransactionTest.testWaitForMissingRedeliveries Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/8348cdd2 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/8348cdd2 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/8348cdd2 Branch: refs/heads/master Commit: 8348cdd2b6b9986c07ada93b7de2f5ee390eac6e Parents: 0c18c34 Author: Howard Gao Authored: Thu Dec 15 23:33:01 2016 +0800 Committer: Clebert Suconic Committed: Thu Dec 15 17:51:13 2016 -0500 ---------------------------------------------------------------------- .../failover/FailoverTransactionTest.java | 78 ++++++++++++-------- 1 file changed, 46 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8348cdd2/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java index 2b7895a..d1f91d0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java @@ -385,6 +385,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { LOG.info("Received: " + msg); Assert.assertNull("no messges left dangling but got: " + msg, msg); connection.close(); + proxy.close(); } @Test @@ -857,6 +858,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { broker.stop(); broker = createBroker(); broker.start(); + Assert.assertNotNull("should get rolledback message from original restarted broker", consumer.receive(20000)); } finally { connection.close(); @@ -872,45 +874,57 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")?jms.consumerFailoverRedeliveryWaitPeriod=30000"); configureConnectionFactory(cf); Connection connection = cf.createConnection(); - connection.start(); - final Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - final Queue destination = producerSession.createQueue(QUEUE_NAME); - final Session consumerSession = connection.createSession(true, Session.SESSION_TRANSACTED); - MessageConsumer consumer = consumerSession.createConsumer(destination); + try { + connection.start(); + final Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + final Queue destination = producerSession.createQueue(QUEUE_NAME); + final Session consumerSession = connection.createSession(true, Session.SESSION_TRANSACTED); + MessageConsumer consumer = consumerSession.createConsumer(destination); - produceMessage(producerSession, destination); - Message msg = consumer.receive(20000); - if (msg == null) { - AutoFailTestSupport.dumpAllThreads("missing-"); - } - Assert.assertNotNull("got message just produced", msg); + produceMessage(producerSession, destination); + Message msg = consumer.receive(20000); + if (msg == null) { + AutoFailTestSupport.dumpAllThreads("missing-"); + } + Assert.assertNotNull("got message just produced", msg); - broker.stop(); - broker = createBroker(); - broker.start(); + broker.stop(); + broker = createBroker(); + broker.start(); - final CountDownLatch commitDone = new CountDownLatch(1); - // will block pending re-deliveries - new Thread() { - @Override - public void run() { - LOG.info("doing async commit..."); - try { - consumerSession.commit(); - commitDone.countDown(); - } catch (JMSException ignored) { + final CountDownLatch commitDone = new CountDownLatch(1); + final CountDownLatch gotException = new CountDownLatch(1); + // will block pending re-deliveries + new Thread() { + @Override + public void run() { + LOG.info("doing async commit..."); + try { + consumerSession.commit(); + commitDone.countDown(); + } + catch (JMSException ignored) { + System.out.println("--->err: got exfeption:"); + ignored.printStackTrace(); + gotException.countDown(); + } + finally { + commitDone.countDown(); + } } - } - }.start(); + }.start(); - broker.stop(); - broker = createBroker(); - broker.start(); + broker.stop(); + broker = createBroker(); + 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)); - connection.close(); + Assert.assertNotNull("should get failed committed message", consumer.receive(5000)); + } finally { + connection.close(); + } } @Test