KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.jms.Connection JavaDoc;
21 import javax.jms.ConnectionFactory JavaDoc;
22
23 import junit.framework.TestCase;
24
25 import org.apache.activemq.ActiveMQConnectionFactory;
26 import org.apache.activemq.broker.BrokerService;
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.springframework.context.support.AbstractApplicationContext;
30 import org.springframework.context.support.ClassPathXmlApplicationContext;
31
32 /**
33  *
34  * @author Neil Clayton
35  * @version $Revision: 426366 $
36  */

37 public class MultipleTestsWithSpringFactoryBeanTest extends TestCase {
38     
39     protected static final Log log = LogFactory.getLog(MultipleTestsWithSpringFactoryBeanTest.class);
40     
41     protected AbstractApplicationContext context;
42     protected BrokerService service;
43     private Connection JavaDoc connection;
44
45     public void test1() throws Exception JavaDoc {
46     }
47     
48     public void test2() throws Exception JavaDoc {
49     }
50     
51     protected void setUp() throws Exception JavaDoc {
52         log.info("### starting up the test case: " + getName());
53         
54         super.setUp();
55         context = new ClassPathXmlApplicationContext("org/apache/activemq/xbean/spring2.xml");
56         service = (BrokerService) context.getBean("broker");
57         
58         // already started
59
service.start();
60         
61         connection = createConnectionFactory().createConnection();
62         connection.start();
63         log.info("### started up the test case: " + getName());
64     }
65
66     protected void tearDown() throws Exception JavaDoc {
67         connection.close();
68         
69         // stopped as part of the context
70
service.stop();
71         context.close();
72         super.tearDown();
73         
74         log.info("### closed down the test case: " + getName());
75     }
76
77     protected ConnectionFactory JavaDoc createConnectionFactory() {
78         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
79         factory.setBrokerURL("vm://localhost");
80         return factory;
81     }
82 }
83
Popular Tags