activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r420699 - in /incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases: TwoBrokerTopicSendReceiveTest.java TwoBrokerTopicSendReceiveUsingHttpTest.java TwoBrokerTopicSendReceiveUsingTcpTest.java
Date Tue, 11 Jul 2006 03:59:54 GMT
Author: chirino
Date: Mon Jul 10 20:59:54 2006
New Revision: 420699

URL: http://svn.apache.org/viewvc?rev=420699&view=rev
Log:
Make the tests more reliable by explicity creating and shutting down the brokers.  Also wait
for the brokers to be setup before running the tests

Modified:
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingHttpTest.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingTcpTest.java

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java?rev=420699&r1=420698&r2=420699&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java
Mon Jul 10 20:59:54 2006
@@ -16,14 +16,17 @@
  */
 package org.apache.activemq.usecases;
 
+import java.util.HashMap;
+import java.util.Iterator;
+
 import javax.jms.Connection;
 import javax.jms.JMSException;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.xbean.BrokerFactoryBean;
 import org.apache.activemq.test.JmsTopicSendReceiveWithTwoConnectionsTest;
+import org.apache.activemq.util.ServiceSupport;
+import org.apache.activemq.xbean.BrokerFactoryBean;
 import org.springframework.core.io.ClassPathResource;
 
 /**
@@ -33,10 +36,18 @@
 
     protected ActiveMQConnectionFactory sendFactory;
     protected ActiveMQConnectionFactory receiveFactory;
+    protected HashMap brokers = new HashMap();
 
     protected void setUp() throws Exception {
         sendFactory = createSenderConnectionFactory();
         receiveFactory = createReceiverConnectionFactory();
+
+        // Give server enough time to setup,
+        // so we don't lose messages when connection fails
+        log.info("Waiting for brokers Initialize.");
+        Thread.sleep(5000);
+        log.info("Brokers should be initialized by now.. starting test.");
+        
         super.setUp();
     }
 
@@ -50,6 +61,11 @@
 
     protected void tearDown() throws Exception {
         super.tearDown();
+    	for (Iterator iter = brokers.values().iterator(); iter.hasNext();) {
+			BrokerService broker = (BrokerService) iter.next();
+			ServiceSupport.dispose(broker);
+			iter.remove();
+		}
     }
 
     protected Connection createReceiveConnection() throws JMSException {
@@ -64,11 +80,10 @@
         try {
             BrokerFactoryBean brokerFactory = new BrokerFactoryBean(new ClassPathResource(config));
             brokerFactory.afterPropertiesSet();
-
             BrokerService broker = brokerFactory.getBroker();
-            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(((TransportConnector)broker.getTransportConnectors().get(0)).getConnectUri());
-
-            return factory;
+            brokers.put(brokerName, broker);
+            
+            return new ActiveMQConnectionFactory(connectUrl);
 
         } catch (Exception e) {
             e.printStackTrace();

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingHttpTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingHttpTest.java?rev=420699&r1=420698&r2=420699&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingHttpTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingHttpTest.java
Mon Jul 10 20:59:54 2006
@@ -25,14 +25,6 @@
  */
 public class TwoBrokerTopicSendReceiveUsingHttpTest extends TwoBrokerTopicSendReceiveTest
{
 
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        // Give jetty server enough time to setup,
-        // so we don't lose messages when connection fails
-        Thread.sleep(5000);
-    }
-
     protected ActiveMQConnectionFactory createReceiverConnectionFactory() throws JMSException
{
         return createConnectionFactory("org/apache/activemq/usecases/receiver-http.xml",
"receiver", "vm://receiver");
     }

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingTcpTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingTcpTest.java?rev=420699&r1=420698&r2=420699&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingTcpTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingTcpTest.java
Mon Jul 10 20:59:54 2006
@@ -46,7 +46,6 @@
         senderBroker = brokerFactory.getBroker();
 
         super.setUp();
-        Thread.sleep(2000);
     }
 
     protected void tearDown() throws Exception {



Mime
View raw message