mirror of https://github.com/apache/activemq.git
test case for: http://issues.apache.org/activemq/browse/AMQ-755
ensure temp destination infomation is propagated around network of brokers correctly git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@417744 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e8952f6b37
commit
7606053815
|
@ -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"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue