1 18 package org.apache.activemq.usecases; 19 20 import org.apache.activemq.broker.BrokerService; 21 import org.apache.activemq.xbean.BrokerFactoryBean; 22 import org.apache.activemq.ActiveMQConnectionFactory; 23 import org.springframework.core.io.ClassPathResource; 24 import org.springframework.core.io.Resource; 25 26 import java.io.File ; 27 28 34 public class PublishOnQueueConsumedMessageUsingActivemqXMLTest extends PublishOnTopicConsumedMessageTest { 35 protected static final String JOURNAL_ROOT = "../data/"; 36 BrokerService broker; 37 38 39 40 46 protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { 47 return new ActiveMQConnectionFactory("tcp://localhost:61616"); 48 } 49 50 51 56 protected void setUp() throws Exception { 57 ; 58 File journalFile = new File (JOURNAL_ROOT); 59 recursiveDelete(journalFile); 60 System.out.print("Creating broker... "); 62 broker = createBroker("org/apache/activemq/usecases/activemq.xml"); 63 log.info("Success"); 64 super.setUp(); 65 66 } 67 68 69 70 74 protected void tearDown() throws Exception { 75 log.info("Closing Broker"); 76 if (broker != null) { 77 broker.stop(); 78 } 79 log.info("Broker closed..."); 80 81 82 } 83 84 85 88 89 protected static void recursiveDelete(File file) { 90 if( file.isDirectory() ) { 91 File [] files = file.listFiles(); 92 for (int i = 0; i < files.length; i++) { 93 recursiveDelete(files[i]); 94 } 95 } 96 file.delete(); 97 } 98 99 protected BrokerService createBroker(String resource) throws Exception { 100 return createBroker(new ClassPathResource(resource)); 101 } 102 103 protected BrokerService createBroker(Resource resource) throws Exception { 104 BrokerFactoryBean factory = new BrokerFactoryBean(resource); 105 factory.afterPropertiesSet(); 106 107 BrokerService broker = factory.getBroker(); 108 109 111 112 return broker; 113 } 114 } 115 | Popular Tags |