KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > usecases > TwoBrokerTopicSendReceiveUsingJavaConfigurationTest


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.usecases;
19
20 import org.apache.activemq.ActiveMQConnectionFactory;
21 import org.apache.activemq.broker.BrokerService;
22
23 import javax.jms.JMSException JavaDoc;
24
25 /**
26  * @version $Revision: 1.1.1.1 $
27  */

28 public class TwoBrokerTopicSendReceiveUsingJavaConfigurationTest extends TwoBrokerTopicSendReceiveTest {
29     BrokerService receiveBroker;
30     BrokerService sendBroker;
31
32     protected ActiveMQConnectionFactory createReceiverConnectionFactory() throws JMSException JavaDoc {
33         try {
34             receiveBroker = new BrokerService();
35             receiveBroker.setUseJmx(false);
36             receiveBroker.setPersistent(false);
37             receiveBroker.addConnector("tcp://localhost:62002");
38             receiveBroker.addNetworkConnector("static:failover:tcp://localhost:62001");
39             receiveBroker.start();
40
41             ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:62002");
42             return factory;
43         } catch (Exception JavaDoc e) {
44             e.printStackTrace();
45             return null;
46         }
47     }
48
49     protected ActiveMQConnectionFactory createSenderConnectionFactory() throws JMSException JavaDoc {
50         try {
51             sendBroker = new BrokerService();
52             sendBroker.setUseJmx(false);
53             sendBroker.setPersistent(false);
54             sendBroker.addConnector("tcp://localhost:62001");
55             sendBroker.addNetworkConnector("static:failover:tcp://localhost:62002");
56             sendBroker.start();
57
58             ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:62001");
59             return factory;
60         } catch (Exception JavaDoc e) {
61             e.printStackTrace();
62             return null;
63         }
64     }
65
66     protected void tearDown() throws Exception JavaDoc {
67         super.tearDown();
68         if (sendBroker != null) {
69             sendBroker.stop();
70         }
71         if (receiveBroker != null) {
72             receiveBroker.stop();
73         }
74     }
75
76 }
77
Popular Tags