activemq-commits mailing list archives

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

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

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java

Added: 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=999814&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java
Wed Sep 22 08:50:24 2010
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.usecases;
+
+import org.apache.activemq.JmsMultipleBrokersTestSupport;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.network.NetworkConnector;
+
+
+import javax.jms.MessageConsumer;
+import java.net.URI;
+
+
+public class AMQ2927Test extends JmsMultipleBrokersTestSupport {
+
+    ActiveMQQueue queue = new ActiveMQQueue("TEST");
+
+    @Override
+    public void setUp() throws Exception {
+        super.setAutoFail(true);
+        super.setUp();
+        createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=true&useJmx=false&deleteAllMessagesOnStartup=true"));
+        createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=true&useJmx=false"));
+        NetworkConnector aTOb = bridgeBrokers(brokers.get("BrokerA").broker, brokers.get("BrokerB").broker,
false, 2, true, true);
+        aTOb.addStaticallyIncludedDestination(queue);
+        NetworkConnector bTOa = bridgeBrokers(brokers.get("BrokerB").broker, brokers.get("BrokerA").broker,
false, 2, true, true);
+        bTOa.addStaticallyIncludedDestination(queue);
+
+        startAllBrokers();
+        waitForBridgeFormation();
+        
+    }
+
+    public void testFailoverRestart() throws Exception {
+
+        Thread.sleep(1000);
+
+        System.out.println("restarting broker");
+
+        restartBroker("BrokerA");
+
+        Thread.sleep(5000);
+
+        System.out.println("sending message");
+
+        sendMessages("BrokerA", queue, 1);
+
+        Thread.sleep(3000);
+
+        System.out.println("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)); 
+    }
+
+    protected void restartBroker(String brokerName) throws Exception {
+        destroyBroker("BrokerA");
+        BrokerService broker = createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=true&useJmx=false"));
+        NetworkConnector aTOb = bridgeBrokers(brokers.get("BrokerA").broker, brokers.get("BrokerB").broker,
false, 2, true, true);
+        aTOb.addStaticallyIncludedDestination(queue);
+        broker.start();
+        broker.waitUntilStarted();
+        waitForBridgeFormation();
+    }
+
+}
\ No newline at end of file



Mime
View raw message