1 17 package org.apache.activemq.broker; 18 19 import org.apache.activemq.EmbeddedBrokerTestSupport; 20 import org.apache.activemq.command.ActiveMQDestination; 21 import org.apache.activemq.command.ActiveMQQueue; 22 import org.apache.activemq.command.ActiveMQTopic; 23 import org.apache.activemq.xbean.XBeanBrokerFactory; 24 25 import java.net.URI ; 26 import java.util.Set ; 27 28 32 public class CreateDestinationsOnStartupViaXBeanTest extends EmbeddedBrokerTestSupport { 33 34 public void testNewDestinationsAreCreatedOnStartup() throws Exception { 35 assertQueueCreated("FOO.BAR", true); 36 assertQueueCreated("FOO.DoesNotExist", false); 37 38 assertTopicCreated("SOME.TOPIC", true); 39 assertTopicCreated("FOO.DoesNotExist", false); 40 } 41 42 protected void assertQueueCreated(String name, boolean expected) throws Exception { 43 assertDestinationCreated(new ActiveMQQueue(name), expected); 44 } 45 46 protected void assertTopicCreated(String name, boolean expected) throws Exception { 47 assertDestinationCreated(new ActiveMQTopic(name), expected); 48 } 49 50 protected void assertDestinationCreated(ActiveMQDestination destination, boolean expected) throws Exception { 51 Set answer = broker.getBroker().getDestinations(destination); 52 int size = expected ? 1 : 0; 53 assertEquals("Could not find destination: " + destination + ". Size of found destinations: " + answer, size, answer.size()); 54 } 55 56 protected BrokerService createBroker() throws Exception { 57 XBeanBrokerFactory factory = new XBeanBrokerFactory(); 58 BrokerService answer = factory.createBroker(new URI (getBrokerConfigUri())); 59 60 answer.setPersistent(false); 62 63 return answer; 64 } 65 66 protected String getBrokerConfigUri() { 67 return "org/apache/activemq/broker/destinations-on-start.xml"; 68 } 69 } 70 | Popular Tags |