activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r711264 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java
Date Tue, 04 Nov 2008 14:38:21 GMT
Author: gtully
Date: Tue Nov  4 06:38:20 2008
New Revision: 711264

URL: http://svn.apache.org/viewvc?rev=711264&view=rev
Log:
have master wait for slave to ensure slave is always present for duration of test

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java?rev=711264&r1=711263&r2=711264&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/MasterSlaveTempQueueMemoryTest.java
Tue Nov  4 06:38:20 2008
@@ -19,7 +19,6 @@
 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 @@
         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 @@
             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());
     }



Mime
View raw message