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
This commit is contained in:
Timothy A. Bish 2012-07-03 19:04:49 +00:00
parent 902c6e98aa
commit bb1e246c1b
1 changed files with 11 additions and 11 deletions

View File

@ -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