1   /*** 
2    * 
3    * Copyright 2004 Protique Ltd
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.codehaus.activemq;
19  
20  import javax.jms.Connection;
21  import javax.jms.Session;
22  
23  /***
24   * @version $Revision: 1.11 $
25   */
26  public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTestSupport {
27  
28      protected Connection sendConnection;
29      protected Connection receiveConnection;
30      protected Session receiveSession;
31  
32      protected void setUp() throws Exception {
33          super.setUp();
34  
35          connectionFactory = createConnectionFactory();
36  
37          sendConnection = createConnection();
38          sendConnection.start();
39  
40          receiveConnection = createConnection();
41          receiveConnection.start();
42  
43          System.out.println("Created sendConnection: " + sendConnection);
44          System.out.println("Created receiveConnection: " + receiveConnection);
45  
46          session = sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
47          receiveSession = receiveConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
48  
49          System.out.println("Created sendSession: " + session);
50          System.out.println("Created receiveSession: " + receiveSession);
51  
52          producer = session.createProducer(null);
53  
54          System.out.println("Created producer: " + producer);
55  
56          if (topic) {
57              destination = receiveSession.createTopic(getSubject());
58          }
59          else {
60              destination = receiveSession.createQueue(getSubject());
61          }
62  
63          System.out.println("Created destination: " + destination + " of type: " + destination.getClass());
64  
65          consumer = receiveSession.createConsumer(destination);
66          consumer.setMessageListener(this);
67  
68  
69          System.out.println("Started connections");
70      }
71  
72      protected ActiveMQConnectionFactory createConnectionFactory() {
73          return new ActiveMQConnectionFactory("vm://localhost");
74      }
75  
76      protected void tearDown() throws Exception {
77          session.close();
78          receiveSession.close();
79  
80          sendConnection.close();
81          // TODO
82          //receiveConnection.close();
83      }
84  }