From 0c2144c3573e79a5872ecf247d9cf46dd3f4abfe Mon Sep 17 00:00:00 2001 From: "Timothy A. Bish" Date: Wed, 11 Apr 2012 14:23:27 +0000 Subject: [PATCH] prevent hanging test stalling the build. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1324779 13f79535-47bb-0310-9956-ffa450edef68 --- .../usecases/ClientRebalanceTest.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/usecases/ClientRebalanceTest.java b/activemq-core/src/test/java/org/apache/activemq/usecases/ClientRebalanceTest.java index ed7c4b3331..b07cf127f4 100644 --- a/activemq-core/src/test/java/org/apache/activemq/usecases/ClientRebalanceTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/usecases/ClientRebalanceTest.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.usecases; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.JmsMultipleBrokersTestSupport; -import org.apache.log4j.Logger; -import org.springframework.core.io.ClassPathResource; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -28,10 +23,20 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.JmsMultipleBrokersTestSupport; +import org.apache.log4j.Logger; +import org.springframework.core.io.ClassPathResource; + public class ClientRebalanceTest extends JmsMultipleBrokersTestSupport { private static final Logger LOG = Logger.getLogger(ClientRebalanceTest.class); private static final String QUEUE_NAME = "Test.ClientRebalanceTest"; - + + protected void setUp() throws Exception { + setAutoFail(true); + super.setUp(); + } + public void testRebalance() throws Exception { createBroker(new ClassPathResource("org/apache/activemq/usecases/rebalance-broker1.xml")); createBroker(new ClassPathResource("org/apache/activemq/usecases/rebalance-broker2.xml")); @@ -40,9 +45,8 @@ public class ClientRebalanceTest extends JmsMultipleBrokersTestSupport { brokers.get("b1").broker.waitUntilStarted(); - LOG.info("Starting connection"); - + ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("failover:(tcp://localhost:61616,tcp://localhost:61617)?randomize=false"); Connection conn = factory.createConnection(); conn.start(); @@ -55,20 +59,17 @@ public class ClientRebalanceTest extends JmsMultipleBrokersTestSupport { Message msg = consumer.receive(2000); assertNotNull(msg); - // introduce third broker createBroker(new ClassPathResource("org/apache/activemq/usecases/rebalance-broker3.xml")); brokers.get("b3").broker.waitUntilStarted(); - - Thread.sleep(1000); + Thread.sleep(1000); LOG.info("Stopping broker 1"); - brokers.get("b1").broker.stop(); brokers.get("b1").broker.waitUntilStopped(); - + Thread.sleep(1000); // should reconnect to some of the remaining brokers producer.send(message); @@ -85,5 +86,4 @@ public class ClientRebalanceTest extends JmsMultipleBrokersTestSupport { msg = consumer.receive(2000); assertNotNull(msg); } - }