activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r831876 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/advisory/ main/java/org/apache/activemq/network/ main/java/org/apache/activemq/transport/vm/ test/java/org/apache/activemq/ test/java/org/apache/activemq/usecases/
Date Mon, 02 Nov 2009 12:35:13 GMT
Author: gtully
Date: Mon Nov  2 12:35:12 2009
New Revision: 831876

URL: http://svn.apache.org/viewvc?rev=831876&view=rev
Log:
make networkbridge tests more resilient to time related issues on slow machines

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEventSource.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkConnector.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsUsingTcpTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NoDuplicateOnTopicNetworkTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEventSource.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEventSource.java?rev=831876&r1=831875&r2=831876&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEventSource.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/ConsumerEventSource.java
Mon Nov  2 12:35:12 2009
@@ -23,7 +23,6 @@
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
-import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
 import javax.jms.Session;
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkConnector.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkConnector.java?rev=831876&r1=831875&r2=831876&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkConnector.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkConnector.java
Mon Nov  2 12:35:12 2009
@@ -18,6 +18,7 @@
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -281,5 +282,9 @@
         }
         return removeSucceeded;
     }
+    
+    public Collection<NetworkBridge> activeBridges() {
+        return bridges.values();
+    }
 
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransport.java?rev=831876&r1=831875&r2=831876&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
Mon Nov  2 12:35:12 2009
@@ -32,8 +32,6 @@
 import org.apache.activemq.transport.TransportDisposedIOException;
 import org.apache.activemq.transport.TransportListener;
 import org.apache.activemq.util.IOExceptionSupport;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 
 /**

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java?rev=831876&r1=831875&r2=831876&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
Mon Nov  2 12:35:12 2009
@@ -53,6 +53,7 @@
 import org.apache.activemq.network.NetworkConnector;
 import org.apache.activemq.util.IdGenerator;
 import org.apache.activemq.util.MessageIdList;
+import org.apache.activemq.util.Wait;
 import org.apache.activemq.xbean.BrokerFactoryBean;
 import org.springframework.core.io.Resource;
 
@@ -96,10 +97,10 @@
     // By default, bridge them using add network connector of the local broker
     // and the first connector of the remote broker
     protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker,
boolean dynamicOnly, int networkTTL, boolean conduit) throws Exception {
-        List transportConnectors = remoteBroker.getTransportConnectors();
+        List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
         URI remoteURI;
         if (!transportConnectors.isEmpty()) {
-            remoteURI = ((TransportConnector)transportConnectors.get(0)).getConnectUri();
+            remoteURI = transportConnectors.get(0).getConnectUri();
             NetworkConnector connector = new DiscoveryNetworkConnector(new URI("static:"
+ remoteURI));
             connector.setDynamicOnly(dynamicOnly);
             connector.setNetworkTTL(networkTTL);
@@ -126,14 +127,14 @@
         Collection<BrokerItem> brokerList = brokers.values();
         for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext();) {
             BrokerService broker = i.next().broker;
-            List transportConnectors = broker.getTransportConnectors();
+            List<TransportConnector> transportConnectors = broker.getTransportConnectors();
 
             if (transportConnectors.isEmpty()) {
                 broker.addConnector(new URI(AUTO_ASSIGN_TRANSPORT));
                 transportConnectors = broker.getTransportConnectors();
             }
 
-            TransportConnector transport = (TransportConnector)transportConnectors.get(0);
+            TransportConnector transport = transportConnectors.get(0);
             transport.setDiscoveryUri(new URI("multicast://default?group=" + groupName));
             NetworkConnector nc = broker.addNetworkConnector("multicast://default?group="
+ groupName);
             nc.setNetworkTTL(ttl);
@@ -145,6 +146,19 @@
         maxSetupTime = 8000;
     }
 
+    
+    protected void waitForBridgeFormation() throws Exception {
+        for (BrokerItem brokerItem : brokers.values()) {
+            final BrokerService broker = brokerItem.broker;
+            if (!broker.getNetworkConnectors().isEmpty()) {
+                Wait.waitFor(new Wait.Condition() {
+                    public boolean isSatisified() throws Exception {
+                        return !broker.getNetworkConnectors().get(0).activeBridges().isEmpty();
+                    }});
+            }
+        }
+    }
+
     protected void startAllBrokers() throws Exception {
         Collection<BrokerItem> brokerList = brokers.values();
         for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext();) {
@@ -465,6 +479,7 @@
                 try {
                     c.close();
                 } catch (ConnectionClosedException e) {
+                } catch (JMSException e) {
                 }
             }
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java?rev=831876&r1=831875&r2=831876&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java
Mon Nov  2 12:35:12 2009
@@ -43,12 +43,13 @@
 
     private static final Log LOG = LogFactory.getLog(MultiBrokersMultiClientsTest.class);
 
-    protected Map consumerMap;
+    protected Map<String, MessageConsumer> consumerMap;
     Map<Thread, Throwable> unhandeledExceptions = new HashMap<Thread, Throwable>();
 
     public void testTopicAllConnected() throws Exception {
         bridgeAllBrokers();
         startAllBrokers();
+        waitForBridgeFormation();
 
         // Setup topic destination
         Destination dest = createDestination("TEST.FOO", true);
@@ -99,6 +100,7 @@
     public void testQueueAllConnected() throws Exception {
         bridgeAllBrokers();
         startAllBrokers();
+        this.waitForBridgeFormation();
 
         // Setup topic destination
         Destination dest = createDestination("TEST.FOO", false);
@@ -132,7 +134,7 @@
         int totalMsg = 0;
         for (int i = 1; i <= BROKER_COUNT; i++) {
             for (int j = 0; j < CONSUMER_COUNT; j++) {
-                MessageIdList msgs = getConsumerMessages("Broker" + i, (MessageConsumer)consumerMap.get("Consumer:"
+ i + ":" + j));
+                MessageIdList msgs = getConsumerMessages("Broker" + i, consumerMap.get("Consumer:"
+ i + ":" + j));
                 totalMsg += msgs.getMessageCount();
             }
         }
@@ -153,7 +155,7 @@
             createBroker(new URI("broker:()/Broker" + i + "?persistent=false&useJmx=false"));
         }
 
-        consumerMap = new HashMap();
+        consumerMap = new HashMap<String, MessageConsumer>();
     }
 
     public void uncaughtException(Thread t, Throwable e) {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsUsingTcpTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsUsingTcpTest.java?rev=831876&r1=831875&r2=831876&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsUsingTcpTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsUsingTcpTest.java
Mon Nov  2 12:35:12 2009
@@ -46,14 +46,14 @@
     }
 
     protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws
Exception {
-        List remoteTransports = remoteBroker.getTransportConnectors();
-        List localTransports = localBroker.getTransportConnectors();
+        List<TransportConnector> remoteTransports = remoteBroker.getTransportConnectors();
+        List<TransportConnector> localTransports = localBroker.getTransportConnectors();
 
         URI remoteURI;
         URI localURI;
         if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) {
-            remoteURI = ((TransportConnector)remoteTransports.get(0)).getConnectUri();
-            localURI = ((TransportConnector)localTransports.get(0)).getConnectUri();
+            remoteURI = remoteTransports.get(0).getConnectUri();
+            localURI = localTransports.get(0).getConnectUri();
 
             // Ensure that we are connecting using tcp
             if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:"))
{
@@ -77,8 +77,8 @@
 
         // Assign a tcp connector to each broker
         int j = 0;
-        for (Iterator i = brokers.values().iterator(); i.hasNext();) {
-            ((BrokerItem)i.next()).broker.addConnector("tcp://localhost:" + (61616 + j++));
+        for (Iterator<BrokerItem> i = brokers.values().iterator(); i.hasNext();) {
+            i.next().broker.addConnector("tcp://localhost:" + (61616 + j++));
         }
 
         bridges = new ArrayList<DemandForwardingBridge>();

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NoDuplicateOnTopicNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NoDuplicateOnTopicNetworkTest.java?rev=831876&r1=831875&r2=831876&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NoDuplicateOnTopicNetworkTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NoDuplicateOnTopicNetworkTest.java
Mon Nov  2 12:35:12 2009
@@ -34,14 +34,15 @@
 import javax.jms.TextMessage;
 import javax.jms.Topic;
 
+import junit.framework.TestCase;
+
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.network.NetworkConnector;
+import org.apache.activemq.util.Wait;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import junit.framework.TestCase;
-
 public class NoDuplicateOnTopicNetworkTest extends TestCase {
     private static final Log LOG = LogFactory
             .getLog(NoDuplicateOnTopicNetworkTest.class);
@@ -71,6 +72,25 @@
         Thread.sleep(3000);
         broker1 = createAndStartBroker("broker1", BROKER_1);
         Thread.sleep(1000);
+        
+        waitForBridgeFormation();
+    }
+    
+    protected void waitForBridgeFormation() throws Exception {
+        Wait.waitFor(new Wait.Condition() {
+            public boolean isSatisified() throws Exception {
+                return !broker3.getNetworkConnectors().get(0).activeBridges().isEmpty();
+            }});
+ 
+        Wait.waitFor(new Wait.Condition() {
+            public boolean isSatisified() throws Exception {
+                return !broker2.getNetworkConnectors().get(0).activeBridges().isEmpty();
+            }});
+
+        Wait.waitFor(new Wait.Condition() {
+            public boolean isSatisified() throws Exception {
+                return !broker1.getNetworkConnectors().get(0).activeBridges().isEmpty();
+            }});
     }
 
     private BrokerService createAndStartBroker(String name, String addr)

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java?rev=831876&r1=831875&r2=831876&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java
Mon Nov  2 12:35:12 2009
@@ -63,7 +63,8 @@
         bridgeBrokers("BrokerB", "BrokerC");
 
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 
@@ -90,7 +91,8 @@
         bridgeBrokers("BrokerB", "BrokerC");
 
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 
@@ -121,7 +123,8 @@
         bridgeBrokers("BrokerB", "BrokerC", true, 1, false);
 
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 
@@ -162,7 +165,8 @@
         bridgeBrokers("BrokerB", "BrokerC", true, 1, false);
 
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 
@@ -203,7 +207,8 @@
         bridgeBrokers("BrokerC", "BrokerB");
 
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 
@@ -235,7 +240,8 @@
         bridgeBrokers("BrokerC", "BrokerA");
 
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 
@@ -265,7 +271,8 @@
         bridgeAllBrokers();
 
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 
@@ -311,7 +318,8 @@
     public void testAllConnectedUsingMulticastProducerConsumerOnA() throws Exception {
         bridgeAllBrokers("default", 3, false);
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 
@@ -336,7 +344,8 @@
     public void testAllConnectedWithSpare() throws Exception {
         bridgeAllBrokers("default", 3, false);
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 
@@ -362,6 +371,7 @@
         boolean suppressQueueDuplicateSubscriptions = false;
         bridgeAllBrokers("default", 3, suppressQueueDuplicateSubscriptions);
         startAllBrokers();
+        waitForBridgeFormation();
 
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);    
@@ -419,7 +429,8 @@
         boolean decreaseNetworkConsumerPriority = true;
         bridgeAllBrokers("default", 3, suppressQueueDuplicateSubscriptions, decreaseNetworkConsumerPriority);
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);    
         
@@ -462,7 +473,8 @@
         bridgeAllBrokers("default", 3, true);
         
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 
@@ -531,7 +543,8 @@
         });
         
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
     
         // Setup consumers
         String brokerName = "BrokerA";
@@ -558,7 +571,8 @@
         
         bridgeAllBrokers("default", 3, false);
         startAllBrokers();
-
+        waitForBridgeFormation();
+        
         // Setup destination
         Destination dest = createDestination("TEST.FOO", false);
 



Mime
View raw message