Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B311F10AF5 for ; Mon, 15 Dec 2014 23:21:46 +0000 (UTC) Received: (qmail 95299 invoked by uid 500); 15 Dec 2014 23:21:46 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 95140 invoked by uid 500); 15 Dec 2014 23:21:46 -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 95019 invoked by uid 99); 15 Dec 2014 23:21:46 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Dec 2014 23:21:46 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 36D749C872D; Mon, 15 Dec 2014 23:21:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hadrian@apache.org To: commits@activemq.apache.org Date: Mon, 15 Dec 2014 23:21:48 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [03/17] activemq git commit: Convert to JUnit 4 test and add a timeout, also remove the tcp transport connector on a fixed port as its not needed. Convert to JUnit 4 test and add a timeout, also remove the tcp transport connector on a fixed port as its not needed. Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/1e3f4f19 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/1e3f4f19 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/1e3f4f19 Branch: refs/heads/activemq-5.10.x Commit: 1e3f4f192b6240271112e2d8dc46413925b46364 Parents: 95a70bb Author: Timothy Bish Authored: Thu Jun 5 17:52:01 2014 -0400 Committer: Hadrian Zbarcea Committed: Mon Dec 15 13:53:38 2014 -0500 ---------------------------------------------------------------------- .../transport/vm/VMTransportWaitForTest.java | 48 +++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/1e3f4f19/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java index 505e65c..faa93e4 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java @@ -16,28 +16,32 @@ */ package org.apache.activemq.transport.vm; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.net.URI; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javax.jms.JMSException; -import junit.framework.TestCase; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; +import org.junit.Test; -public class VMTransportWaitForTest extends TestCase { +public class VMTransportWaitForTest { - private static final String VM_BROKER_URI_NO_WAIT = + private static final String VM_BROKER_URI_NO_WAIT = "vm://localhost?broker.persistent=false&create=false"; - - private static final String VM_BROKER_URI_WAIT_FOR_START = + + private static final String VM_BROKER_URI_WAIT_FOR_START = VM_BROKER_URI_NO_WAIT + "&waitForStart=20000"; - + CountDownLatch started = new CountDownLatch(1); CountDownLatch gotConnection = new CountDownLatch(1); + @Test(timeout=90000) public void testWaitFor() throws Exception { try { ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI_NO_WAIT)); @@ -45,32 +49,32 @@ public class VMTransportWaitForTest extends TestCase { fail("expect broker not exist exception"); } catch (JMSException expectedOnNoBrokerAndNoCreate) { } - - // spawn a thread that will wait for an embedded broker to start via vm://.. + + // spawn a thread that will wait for an embedded broker to start via + // vm://.. Thread t = new Thread() { + @Override public void run() { - try { - started.countDown(); - ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI_WAIT_FOR_START)); - cf.createConnection(); - gotConnection.countDown(); - - } catch (Exception e) { - e.printStackTrace(); - fail("unexpected exception: " + e); - } + try { + started.countDown(); + ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI_WAIT_FOR_START)); + cf.createConnection(); + gotConnection.countDown(); + } catch (Exception e) { + e.printStackTrace(); + fail("unexpected exception: " + e); + } } }; t.start(); started.await(20, TimeUnit.SECONDS); Thread.yield(); assertFalse("has not got connection", gotConnection.await(2, TimeUnit.SECONDS)); - + BrokerService broker = new BrokerService(); broker.setPersistent(false); - broker.addConnector("tcp://localhost:61616"); broker.start(); assertTrue("has got connection", gotConnection.await(400, TimeUnit.MILLISECONDS)); - broker.stop(); + broker.stop(); } }