From bb1e246c1b122addf6ca05709d339496c082e05e Mon Sep 17 00:00:00 2001 From: "Timothy A. Bish" Date: Tue, 3 Jul 2012 19:04:49 +0000 Subject: [PATCH] The start time needs to be set before stopping broker1 in order to account for context switching that can cause the failover process to start before the current call to track the failover start time. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1356868 13f79535-47bb-0310-9956-ffa450edef68 --- .../failover/InitalReconnectDelayTest.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java b/activemq-core/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java index 83346bf3fb..5e728cba25 100644 --- a/activemq-core/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java @@ -16,6 +16,16 @@ */ package org.apache.activemq.transport.failover; +import static org.junit.Assert.assertTrue; + +import java.util.Date; +import java.util.concurrent.CountDownLatch; + +import javax.jms.Connection; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.junit.After; @@ -24,15 +34,6 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.Connection; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import java.util.Date; -import java.util.concurrent.CountDownLatch; - -import static org.junit.Assert.assertTrue; - public class InitalReconnectDelayTest { private static final transient Logger LOG = LoggerFactory.getLogger(InitalReconnectDelayTest.class); @@ -59,17 +60,16 @@ public class InitalReconnectDelayTest { //Halt the broker1... LOG.info("Stopping the Broker1..."); + start = (new Date()).getTime(); broker1.stop(); LOG.info("Attempting to send... failover should kick in..."); - start = (new Date()).getTime(); producer.send(session.createTextMessage("TEST")); end = (new Date()).getTime(); //Inital reconnection should kick in and be darned close to what we expected LOG.info("Failover took " + (end - start) + " ms."); assertTrue("Failover took " + (end - start) + " ms and should be > 14000.", (end - start) > 14000); - } @Before