activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r417744 - /incubator/activemq/trunk/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java
Date Wed, 28 Jun 2006 12:50:30 GMT
Author: rajdavies
Date: Wed Jun 28 05:50:30 2006
New Revision: 417744

URL: http://svn.apache.org/viewvc?rev=417744&view=rev
Log:
test case for: http://issues.apache.org/activemq/browse/AMQ-755
ensure temp destination infomation is propagated around network of brokers correctly

Added:
    incubator/activemq/trunk/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java

Added: incubator/activemq/trunk/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java?rev=417744&view=auto
==============================================================================
--- incubator/activemq/trunk/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java
(added)
+++ incubator/activemq/trunk/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java
Wed Jun 28 05:50:30 2006
@@ -0,0 +1,95 @@
+/**
+ * 
+ * Copyright 2005-2006 The Apache Software Foundation
+ * 
+ * Licensed 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 java.net.URI;
+import java.util.Iterator;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+import org.apache.activemq.JmsMultipleBrokersTestSupport;
+/**
+ * @version $Revision: 1.1.1.1 $
+ */
+public class ThreeBrokerTempQueueNetworkTest extends JmsMultipleBrokersTestSupport{
+    protected static final int MESSAGE_COUNT=100;
+
+    /**
+     * BrokerA -> BrokerB -> BrokerC
+     */
+    public void testTempQueueCleanup() throws Exception{
+        // Setup broker networks
+        bridgeBrokers("BrokerA","BrokerB",false,2);
+        bridgeBrokers("BrokerB","BrokerC",false,2);
+        startAllBrokers();
+        BrokerItem brokerItem=(BrokerItem) brokers.get("BrokerC");
+        Connection conn=brokerItem.createConnection();
+        conn.start();
+        Session sess=conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
+        TemporaryQueue tempQ=sess.createTemporaryQueue();
+        Thread.sleep(5000);
+        for(Iterator i=brokers.values().iterator();i.hasNext();){
+            BrokerItem bi=(BrokerItem) i.next();
+            assertEquals("No queues on broker "+bi.broker.getBrokerName(),1,bi.broker.getAdminView()
+                            .getTemporaryQueues().length);
+        }
+        tempQ.delete();
+        Thread.sleep(2000);
+        for(Iterator i=brokers.values().iterator();i.hasNext();){
+            BrokerItem bi=(BrokerItem) i.next();
+            assertEquals("Temp queue left behind on broker "+bi.broker.getBrokerName(),0,bi.broker.getAdminView()
+                            .getTemporaryQueues().length);
+        }
+    }
+
+    // this actually uses 4 brokers ...
+    public void testTempQueueRecovery() throws Exception{
+        // Setup broker networks
+        bridgeBrokers("BrokerA","BrokerB",false,3);
+        bridgeBrokers("BrokerB","BrokerC",false,3);
+        startAllBrokers();
+        BrokerItem brokerItem=(BrokerItem) brokers.get("BrokerC");
+        Connection conn=brokerItem.createConnection();
+        conn.start();
+        Session sess=conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
+        TemporaryQueue tempQ=sess.createTemporaryQueue();
+        Thread.sleep(5000);
+        for(Iterator i=brokers.values().iterator();i.hasNext();){
+            BrokerItem bi=(BrokerItem) i.next();
+            assertEquals("No queues on broker "+bi.broker.getBrokerName(),1,bi.broker.getAdminView()
+                            .getTemporaryQueues().length);
+        }
+        createBroker(new URI("broker:(tcp://localhost:61619)/BrokerD?persistent=false&useJmx=true"));
+        bridgeBrokers("BrokerD","BrokerA",false,3);
+        BrokerItem newBroker=(BrokerItem) brokers.get("BrokerD");
+        newBroker.broker.start();
+        Thread.sleep(1000);
+        assertEquals("No queues on broker D",1,newBroker.broker.getAdminView().getTemporaryQueues().length);
+        tempQ.delete();
+        Thread.sleep(2000);
+        for(Iterator i=brokers.values().iterator();i.hasNext();){
+            BrokerItem bi=(BrokerItem) i.next();
+            assertEquals("Temp queue left behind on broker "+bi.broker.getBrokerName(),0,bi.broker.getAdminView()
+                            .getTemporaryQueues().length);
+        }
+    }
+
+    public void setUp() throws Exception{
+        super.setAutoFail(true);
+        super.setUp();
+        createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=false&useJmx=true"));
+        createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=false&useJmx=true"));
+        createBroker(new URI("broker:(tcp://localhost:61618)/BrokerC?persistent=false&useJmx=true"));
+    }
+}



Mime
View raw message