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/27 18:14:39 UTC

svn commit: r426116 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/ test/java/org/apache/activemq/broker/ test/resources/org/apache/activemq/broker/

Author: jstrachan
Date: Thu Jul 27 09:14:38 2006
New Revision: 426116

URL: http://svn.apache.org/viewvc?rev=426116&view=rev
Log:
added a test case to show the auto-creation of destinations on startup working to fix AMQ-828. For documentation see: http://activemq.org/site/configure-startup-destinations.html

Added:
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java   (with props)
    incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/destinations-on-start.xml   (with props)
Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=426116&r1=426115&r2=426116&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java Thu Jul 27 09:14:38 2006
@@ -837,7 +837,7 @@
     /**
      * Sets whether or not
      * <a href="http://incubator.apache.org/activemq/virtual-destinations.html">Virtual Topics</a>
-     * should be supported by defaut if they have not been explicitly configured.
+     * should be supported by default if they have not been explicitly configured.
      */
     public void setUseVirtualTopics(boolean useVirtualTopics) {
         this.useVirtualTopics = useVirtualTopics;
@@ -852,6 +852,17 @@
      */
     public void setDestinationInterceptors(DestinationInterceptor[] destinationInterceptors) {
         this.destinationInterceptors = destinationInterceptors;
+    }
+    
+    public ActiveMQDestination[] getDestinations() {
+        return destinations;
+    }
+
+    /**
+     * Sets the destinations which should be loaded/created on startup
+     */
+    public void setDestinations(ActiveMQDestination[] destinations) {
+        this.destinations = destinations;
     }
 
     // Implementation methods

Added: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java?rev=426116&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java (added)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java Thu Jul 27 09:14:38 2006
@@ -0,0 +1,68 @@
+/*
+ * 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.broker;
+
+import org.apache.activemq.EmbeddedBrokerTestSupport;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.xbean.XBeanBrokerFactory;
+
+import java.net.URI;
+import java.util.Set;
+
+/**
+ * 
+ * @version $Revision$
+ */
+public class CreateDestinationsOnStartupViaXBeanTest extends EmbeddedBrokerTestSupport {
+
+    public void testNewDestinationsAreCreatedOnStartup() throws Exception {
+        assertQueueCreated("FOO.BAR", true);
+        assertQueueCreated("FOO.DoesNotExist", false);
+        
+        assertTopicCreated("SOME.TOPIC", true);
+        assertTopicCreated("FOO.DoesNotExist", false);
+    }
+
+    protected void assertQueueCreated(String name, boolean expected) throws Exception {
+        assertDestinationCreated(new ActiveMQQueue(name), expected);
+    }
+    
+    protected void assertTopicCreated(String name, boolean expected) throws Exception {
+        assertDestinationCreated(new ActiveMQTopic(name), expected);
+    }
+
+    protected void assertDestinationCreated(ActiveMQDestination destination, boolean expected) throws Exception {
+        Set answer = broker.getBroker().getDestinations(destination);
+        int size = expected ? 1 : 0;
+        assertEquals("Could not find destination: " + destination + ". Size of found destinations: " + answer, size, answer.size());
+    }
+    
+    protected BrokerService createBroker() throws Exception {
+        XBeanBrokerFactory factory = new XBeanBrokerFactory();
+        BrokerService answer = factory.createBroker(new URI(getBrokerConfigUri()));
+        
+        // lets disable persistence as we are a test
+        answer.setPersistent(false);
+        
+        return answer;
+    }
+
+    protected String getBrokerConfigUri() {
+        return "org/apache/activemq/broker/destinations-on-start.xml";
+    }
+}

Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/destinations-on-start.xml
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/destinations-on-start.xml?rev=426116&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/destinations-on-start.xml (added)
+++ incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/destinations-on-start.xml Thu Jul 27 09:14:38 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<!-- this file can only be parsed using the xbean-spring library -->
+<!-- START SNIPPET: xbean -->
+<beans>
+
+  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
+
+  <broker xmlns="http://activemq.org/config/1.0">
+    <destinations>
+      <queue physicalName="FOO.BAR" />
+      <topic physicalName="SOME.TOPIC" />
+    </destinations>
+
+  </broker>
+
+</beans>
+<!-- END SNIPPET: xbean -->

Propchange: incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/destinations-on-start.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/destinations-on-start.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/destinations-on-start.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml