1 /***
2 *
3 * Copyright 2005 LogicBlaze, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18 package org.jencks;
19
20 import junit.framework.TestCase;
21 import org.activemq.ActiveMQConnectionFactory;
22 import org.springframework.context.ConfigurableApplicationContext;
23 import org.springframework.context.support.ClassPathXmlApplicationContext;
24
25 import javax.jms.Connection;
26 import javax.jms.MessageProducer;
27 import javax.jms.Session;
28
29 /***
30 * @version $Revision: 1.2 $
31 */
32 public class JCAContainerTestSupport extends SpringTestSupport {
33
34
35 protected Connection connection;
36 protected Session session;
37 protected MessageProducer producer;
38
39 protected void setUp() throws Exception {
40 super.setUp();
41
42
43 connection = createConnection();
44
45
46 connection.start();
47 session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
48 producer = session.createProducer(null);
49
50 }
51
52
53 protected void tearDown() throws Exception {
54 if (connection != null) {
55 connection.close();
56 }
57 super.tearDown();
58 }
59
60 protected String getBrokerURL() {
61 return "tcp://localhost:61616";
62 }
63
64 protected String getApplicationContextXml() {
65 return "org/jencks/spring.xml";
66 }
67
68 protected Connection createConnection() throws Exception {
69 return new ActiveMQConnectionFactory(getBrokerURL()).createConnection();
70 }
71 }