From c27db108fdef75bb39752309f05b17fe2b35d79a Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Tue, 4 Nov 2008 14:38:20 +0000 Subject: [PATCH] have master wait for slave to ensure slave is always present for duration of test git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@711264 13f79535-47bb-0310-9956-ffa450edef68 --- .../MasterSlaveTempQueueMemoryTest.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java b/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java index a481fb7f09..7d9fc8b1e3 100644 --- a/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java @@ -19,7 +19,6 @@ package org.apache.activemq.advisory; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; @@ -47,18 +46,35 @@ public class MasterSlaveTempQueueMemoryTest extends TempQueueMemoryTest { bindAddress = masterBindAddress; BrokerService master = super.createBroker(); master.setBrokerName("master"); + master.setUseJmx(false); bindAddress = slaveBindAddress; slave = super.createBroker(); slave.setBrokerName("slave"); slave.setMasterConnectorURI(masterBindAddress); + slave.setUseJmx(false); bindAddress = masterBindAddress; return master; } @Override protected void startBroker() throws Exception { - super.startBroker(); + + // because master will wait for slave to connect it needs + // to be in a separate thread + new Thread() { + public void run() { + try { + broker.setWaitForSlave(true); + broker.start(); + } catch (Exception e) { + fail("failed to start broker, reason:" + e); + e.printStackTrace(); + } + } + }.start(); + slave.start(); + assertTrue("slave is indeed a slave", slave.isSlave()); } @Override @@ -136,18 +152,18 @@ public class MasterSlaveTempQueueMemoryTest extends TempQueueMemoryTest { Message msg = clientSession.createMessage(); producer.send(msg); } + Thread.sleep(5000); RegionBroker slaveRb = (RegionBroker) slave.getBroker().getAdaptor( RegionBroker.class); RegionBroker masterRb = (RegionBroker) broker.getBroker().getAdaptor( RegionBroker.class); - Thread.sleep(4000); assertEquals("inflight match expected", messageCount, masterRb.getDestinationStatistics().getInflight().getCount()); assertEquals("inflight match on slave and master", slaveRb.getDestinationStatistics().getInflight().getCount(), masterRb.getDestinationStatistics().getInflight().getCount()); latch.countDown(); - Thread.sleep(4000); + Thread.sleep(5000); assertEquals("inflight match expected", 0, masterRb.getDestinationStatistics().getInflight().getCount()); assertEquals("inflight match on slave and master", slaveRb.getDestinationStatistics().getInflight().getCount(), masterRb.getDestinationStatistics().getInflight().getCount()); }