KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > xbean > ConnectorXBeanConfigTest


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.xbean;
19
20 import java.net.URI JavaDoc;
21 import java.util.List JavaDoc;
22
23 import junit.framework.TestCase;
24
25 import org.apache.activemq.broker.BrokerFactory;
26 import org.apache.activemq.broker.BrokerService;
27 import org.apache.activemq.broker.TransportConnector;
28 import org.apache.activemq.command.ActiveMQQueue;
29 import org.apache.activemq.command.ActiveMQTopic;
30 import org.apache.activemq.network.NetworkConnector;
31
32 /**
33  *
34  * @version $Revision: 1.1 $
35  */

36 public class ConnectorXBeanConfigTest extends TestCase {
37
38     protected BrokerService brokerService;
39
40     public void testConnectorConfiguredCorrectly() throws Exception JavaDoc {
41         
42         TransportConnector connector = (TransportConnector) brokerService.getTransportConnectors().get(0);
43         
44         assertEquals( new URI JavaDoc("tcp://localhost:61636"), connector.getUri() );
45         assertTrue( connector.getTaskRunnerFactory() == brokerService.getTaskRunnerFactory() );
46         
47         
48         NetworkConnector netConnector = (NetworkConnector) brokerService.getNetworkConnectors().get(0);
49         List JavaDoc excludedDestinations = netConnector.getExcludedDestinations();
50         assertEquals(new ActiveMQQueue("exclude.test.foo"), excludedDestinations.get(0));
51         assertEquals(new ActiveMQTopic("exclude.test.bar"), excludedDestinations.get(1));
52         
53         List JavaDoc dynamicallyIncludedDestinations = netConnector.getDynamicallyIncludedDestinations();
54         assertEquals(new ActiveMQQueue("include.test.foo"), dynamicallyIncludedDestinations.get(0));
55         assertEquals(new ActiveMQTopic("include.test.bar"), dynamicallyIncludedDestinations.get(1));
56         
57     }
58
59     protected void setUp() throws Exception JavaDoc {
60         brokerService = createBroker();
61         brokerService.start();
62     }
63
64     protected void tearDown() throws Exception JavaDoc {
65         if (brokerService != null) {
66             brokerService.stop();
67         }
68     }
69
70     protected BrokerService createBroker() throws Exception JavaDoc {
71         String JavaDoc uri = "org/apache/activemq/xbean/connector-test.xml";
72         return BrokerFactory.createBroker(new URI JavaDoc("xbean:"+uri));
73     }
74
75 }
76
Popular Tags