mirror of https://github.com/apache/activemq.git
To help with the development of Virtual Topics I've added a test case to confirm that destinations are lazily created when a consumer is created. For more background see the dev thread: http://www.nabble.com/Re%3A-Virtual-Topics-%28was-Re%3A-Failover-topic-subscribers%29-tf1942508.html#a5404863
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@423755 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b3d89a755b
commit
c13a547e1e
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* 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 org.apache.activemq.EmbeddedBrokerTestSupport;
|
||||||
|
import org.apache.activemq.command.ActiveMQDestination;
|
||||||
|
import org.apache.activemq.command.ActiveMQQueue;
|
||||||
|
|
||||||
|
import javax.jms.Connection;
|
||||||
|
import javax.jms.Destination;
|
||||||
|
import javax.jms.Session;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @version $Revision: $
|
||||||
|
*/
|
||||||
|
public class NewConsumerCreatesDestinationTest extends EmbeddedBrokerTestSupport {
|
||||||
|
|
||||||
|
private Connection connection;
|
||||||
|
private ActiveMQQueue wildcard;
|
||||||
|
|
||||||
|
public void testNewConsumerCausesNewDestinationToBeAutoCreated() throws Exception {
|
||||||
|
connection = createConnection();
|
||||||
|
|
||||||
|
// lets create a wildcard thats kinda like those used by Virtual Topics
|
||||||
|
String wildcardText = "org.*" + getDestinationString().substring("org.apache".length());
|
||||||
|
wildcard = new ActiveMQQueue(wildcardText);
|
||||||
|
|
||||||
|
System.out.println("Using wildcard: " + wildcard);
|
||||||
|
System.out.println("on destination: " + destination);
|
||||||
|
|
||||||
|
assertDestinationCreated(destination, false);
|
||||||
|
assertDestinationCreated(wildcard, false);
|
||||||
|
|
||||||
|
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
|
session.createConsumer(destination);
|
||||||
|
|
||||||
|
assertDestinationCreated(destination, true);
|
||||||
|
assertDestinationCreated(wildcard, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
if (connection != null) {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void assertDestinationCreated(Destination destination, boolean expected) throws Exception {
|
||||||
|
Set answer = broker.getBroker().getDestinations((ActiveMQDestination) destination);
|
||||||
|
int size = expected ? 1 : 0;
|
||||||
|
assertEquals("Size of found destinations: " + answer, size, answer.size());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue