activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r999816 - in /activemq/trunk/activemq-core/src/test/java/org/apache/activemq: ./ usecases/
Date Wed, 22 Sep 2010 08:50:54 GMT
Author: dejanb
Date: Wed Sep 22 08:50:54 2010
New Revision: 999816

URL: http://svn.apache.org/viewvc?rev=999816&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2927 - test case

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/BrokerQueueNetworkWithDisconnectTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MulticastDiscoveryOnFaultyNetworkTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java

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=999816&r1=999815&r2=999816&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
Wed Sep 22 08:50:54 2010
@@ -85,25 +85,29 @@ public class JmsMultipleBrokersTestSuppo
         BrokerService localBroker = brokers.get(localBrokerName).broker;
         BrokerService remoteBroker = brokers.get(remoteBrokerName).broker;
 
-        bridgeBrokers(localBroker, remoteBroker, dynamicOnly, 1, true);
+        bridgeBrokers(localBroker, remoteBroker, dynamicOnly, 1, true, false);
     }
 
     protected NetworkConnector bridgeBrokers(String localBrokerName, String remoteBrokerName,
boolean dynamicOnly, int networkTTL, boolean conduit) throws Exception {
         BrokerService localBroker = brokers.get(localBrokerName).broker;
         BrokerService remoteBroker = brokers.get(remoteBrokerName).broker;
 
-        return bridgeBrokers(localBroker, remoteBroker, dynamicOnly, networkTTL, conduit);
+        return bridgeBrokers(localBroker, remoteBroker, dynamicOnly, networkTTL, conduit,
false);
     }
 
     // Overwrite this method to specify how you want to bridge the two brokers
     // 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 {
+    protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker,
boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception {
         List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
         URI remoteURI;
         if (!transportConnectors.isEmpty()) {
             remoteURI = transportConnectors.get(0).getConnectUri();
-            NetworkConnector connector = new DiscoveryNetworkConnector(new URI("static:"
+ remoteURI));
+            String uri = "static:(" + remoteURI + ")";
+            if (failover) {
+                uri = "static:(failover:(" + remoteURI + "))";
+            }
+            NetworkConnector connector = new DiscoveryNetworkConnector(new URI(uri));
             connector.setDynamicOnly(dynamicOnly);
             connector.setNetworkTTL(networkTTL);
             connector.setConduitSubscriptions(conduit);

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java?rev=999816&r1=999815&r2=999816&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java
Wed Sep 22 08:50:54 2010
@@ -20,6 +20,9 @@ import org.apache.activemq.JmsMultipleBr
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.network.NetworkConnector;
+import org.apache.activemq.util.MessageIdList;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 
 import javax.jms.MessageConsumer;
@@ -28,6 +31,8 @@ import java.net.URI;
 
 public class AMQ2927Test extends JmsMultipleBrokersTestSupport {
 
+    private static final Log LOG = LogFactory.getLog(AMQ2927Test.class);
+
     ActiveMQQueue queue = new ActiveMQQueue("TEST");
 
     @Override
@@ -46,31 +51,72 @@ public class AMQ2927Test extends JmsMult
         
     }
 
-    public void testFailoverRestart() throws Exception {
+    public void testRestartSend() throws Exception {
 
         Thread.sleep(1000);
 
-        System.out.println("restarting broker");
+        LOG.info("restarting broker");
 
         restartBroker("BrokerA");
 
         Thread.sleep(5000);
 
-        System.out.println("sending message");
+        LOG.info("sending message");
+
+        sendMessages("BrokerA", queue, 1);
+
+        Thread.sleep(3000);
+
+        LOG.info("consuming message");
+
+        MessageConsumer consumerA = createConsumer("BrokerA", queue);
+        MessageConsumer consumerB = createConsumer("BrokerB", queue);
+
+        Thread.sleep(1000);
+
+        MessageIdList messagesA = getConsumerMessages("BrokerA", consumerA);
+        MessageIdList messagesB = getConsumerMessages("BrokerB", consumerB);
+
+        LOG.info("consumerA = " + messagesA);
+        LOG.info("consumerB = " + messagesB);
+
+        messagesA.assertMessagesReceived(0);
+        messagesB.assertMessagesReceived(1);
+
+    }
+
+
+    public void testSendRestart() throws Exception {
+
+        Thread.sleep(1000);
+
+        LOG.info("sending message");
 
         sendMessages("BrokerA", queue, 1);
 
         Thread.sleep(3000);
 
-        System.out.println("consuming message");
+        LOG.info("restarting broker");
+
+        restartBroker("BrokerA");
+
+        Thread.sleep(5000);
+
+        LOG.info("consuming message");
 
         MessageConsumer consumerA = createConsumer("BrokerA", queue);
         MessageConsumer consumerB = createConsumer("BrokerB", queue);
 
         Thread.sleep(1000);
 
-        System.out.println("consumerA = " + getConsumerMessages("BrokerA", consumerA));
-        System.out.println("consumerB = " + getConsumerMessages("BrokerB", consumerB)); 
+        MessageIdList messagesA = getConsumerMessages("BrokerA", consumerA);
+        MessageIdList messagesB = getConsumerMessages("BrokerB", consumerB);
+
+        LOG.info("consumerA = " + messagesA);
+        LOG.info("consumerB = " + messagesB);
+
+        messagesA.assertMessagesReceived(0);
+        messagesB.assertMessagesReceived(1);
     }
 
     protected void restartBroker(String brokerName) throws Exception {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/BrokerQueueNetworkWithDisconnectTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/BrokerQueueNetworkWithDisconnectTest.java?rev=999816&r1=999815&r2=999816&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/BrokerQueueNetworkWithDisconnectTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/BrokerQueueNetworkWithDisconnectTest.java
Wed Sep 22 08:50:54 2010
@@ -26,7 +26,6 @@ import javax.jms.TextMessage;
 import junit.framework.Test;
 
 import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.JmsMultipleBrokersTestSupport.BrokerItem;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.network.DiscoveryNetworkConnector;
@@ -136,7 +135,7 @@ public class BrokerQueueNetworkWithDisco
 
 
     @Override
-    protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker,
boolean dynamicOnly, int networkTTL, boolean conduit) throws Exception {
+    protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker,
boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception {
         List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
         URI remoteURI;
         if (!transportConnectors.isEmpty()) {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MulticastDiscoveryOnFaultyNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MulticastDiscoveryOnFaultyNetworkTest.java?rev=999816&r1=999815&r2=999816&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MulticastDiscoveryOnFaultyNetworkTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/MulticastDiscoveryOnFaultyNetworkTest.java
Wed Sep 22 08:50:54 2010
@@ -26,13 +26,11 @@ import javax.jms.TextMessage;
 import junit.framework.Test;
 
 import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.JmsMultipleBrokersTestSupport.BrokerItem;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.network.DiscoveryNetworkConnector;
 import org.apache.activemq.network.NetworkConnector;
 import org.apache.activemq.util.MessageIdList;
-import org.apache.activemq.util.SocketProxy;
 
 
 public class MulticastDiscoveryOnFaultyNetworkTest extends JmsMultipleBrokersTestSupport
{
@@ -111,7 +109,7 @@ public class MulticastDiscoveryOnFaultyN
 
 
     @Override
-    protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker,
boolean dynamicOnly, int networkTTL, boolean conduit) throws Exception {
+    protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker,
boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception {
         DiscoveryNetworkConnector connector = new DiscoveryNetworkConnector(new URI("multicast://default?group=TESTERIC&useLocalHost=false"));
         connector.setDynamicOnly(dynamicOnly);
         connector.setNetworkTTL(networkTTL);

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java?rev=999816&r1=999815&r2=999816&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java
Wed Sep 22 08:50:54 2010
@@ -38,7 +38,7 @@ public class ThreeBrokerStompTemporaryQu
     private static final Log LOG = LogFactory.getLog(ThreeBrokerStompTemporaryQueueTest.class);
     private StompConnection stompConnection;
 
-    protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker,
boolean dynamicOnly, int networkTTL, boolean conduit) throws Exception {
+    protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker,
boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception {
         List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
         URI remoteURI;
         if (!transportConnectors.isEmpty()) {



Mime
View raw message