1 18 package org.apache.activemq.config; 19 20 import junit.framework.TestCase; 21 import org.apache.activemq.ActiveMQConnectionFactory; 22 import org.apache.activemq.broker.BrokerFactory; 23 import org.apache.activemq.broker.BrokerService; 24 25 import javax.jms.Connection ; 26 import javax.jms.JMSException ; 27 import java.io.File ; 28 29 32 public class BrokerXmlConfigTest extends TestCase { 33 private BrokerService broker; 34 35 public void testStartBrokerUsingXmlConfig() throws Exception { 36 Connection connection = null; 37 try { 38 ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); 39 connection = connectionFactory.createConnection(); 40 connection.start(); 41 connection.close(); 42 connection = null; 43 } 44 catch (Exception e) { 45 if (connection != null) { 46 try { 47 connection.close(); 48 } 49 catch (JMSException e1) { 50 } 52 } 53 throw e; 54 } 55 } 56 57 protected void setUp() throws Exception { 58 System.setProperty("activemq.base", "target"); 59 broker = BrokerFactory.createBroker("xbean:src/release/conf/activemq.xml"); 61 } 62 63 protected void tearDown() throws Exception { 64 if (broker != null) { 65 broker.stop(); 66 } 67 } 68 } 69 | Popular Tags |