mirror of https://github.com/apache/activemq.git
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
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@426116 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5196499946
commit
4bd8a8bf85
|
@ -837,7 +837,7 @@ public class BrokerService implements Service, Serializable {
|
||||||
/**
|
/**
|
||||||
* Sets whether or not
|
* Sets whether or not
|
||||||
* <a href="http://incubator.apache.org/activemq/virtual-destinations.html">Virtual Topics</a>
|
* <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) {
|
public void setUseVirtualTopics(boolean useVirtualTopics) {
|
||||||
this.useVirtualTopics = useVirtualTopics;
|
this.useVirtualTopics = useVirtualTopics;
|
||||||
|
@ -853,6 +853,17 @@ public class BrokerService implements Service, Serializable {
|
||||||
public void setDestinationInterceptors(DestinationInterceptor[] destinationInterceptors) {
|
public void setDestinationInterceptors(DestinationInterceptor[] destinationInterceptors) {
|
||||||
this.destinationInterceptors = 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
|
// Implementation methods
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
|
@ -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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 -->
|
Loading…
Reference in New Issue