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 javax.jms.Connection;
21  import javax.jms.MessageProducer;
22  import javax.jms.Session;
23  
24  import org.activemq.ActiveMQConnectionFactory;
25  
26  /***
27   * @version $Revision: 1.3 $
28   */
29  public abstract class JCAContainerTestSupport extends SpringTestSupport {
30  
31      // to send some messages
32      protected Connection connection;
33      protected Session session;
34      protected MessageProducer producer;
35  
36      protected void setUp() throws Exception {
37          super.setUp();
38  
39          // now lets create the JMS connection
40          connection = createConnection();
41  
42          // start the connection in case we do some consumption on it
43          connection.start();
44          session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
45          producer = session.createProducer(null);
46  
47      }
48  
49  
50      protected void tearDown() throws Exception {
51          if (connection != null) {
52              connection.close();
53          }
54          super.tearDown();
55      }
56  
57      protected String getBrokerURL() {
58          return "tcp://localhost:61616";
59      }
60  
61      protected String getApplicationContextXml() {
62          return "org/jencks/spring.xml";
63      }
64  
65      protected Connection createConnection() throws Exception {
66          return new ActiveMQConnectionFactory(getBrokerURL()).createConnection();
67      }
68  }