You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by js...@apache.org on 2006/07/20 06:39:20 UTC
svn commit: r423755 -
/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java
Author: jstrachan
Date: Wed Jul 19 21:39:20 2006
New Revision: 423755
URL: http://svn.apache.org/viewvc?rev=423755&view=rev
Log:
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
Added:
incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java (with props)
Added: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java?rev=423755&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java (added)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java Wed Jul 19 21:39:20 2006
@@ -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());
+ }
+}
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java
------------------------------------------------------------------------------
svn:eol-style = native