KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > bugs > CraigsBugTest


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 package org.apache.activemq.bugs;
18
19 import org.apache.activemq.ActiveMQConnectionFactory;
20 import org.apache.activemq.EmbeddedBrokerTestSupport;
21 import org.apache.activemq.command.ActiveMQQueue;
22
23 import javax.jms.Connection JavaDoc;
24 import javax.jms.JMSException JavaDoc;
25 import javax.jms.Message JavaDoc;
26 import javax.jms.MessageConsumer JavaDoc;
27 import javax.jms.Session JavaDoc;
28
29 /**
30  *
31  * @version $Revision: $
32  */

33 public class CraigsBugTest extends EmbeddedBrokerTestSupport {
34     
35     public void testConnectionFactory() throws Exception JavaDoc {
36         final ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616");
37         final ActiveMQQueue queue = new ActiveMQQueue("testqueue");
38         final Connection JavaDoc conn = cf.createConnection();
39
40         Runnable JavaDoc r = new Runnable JavaDoc() {
41             public void run() {
42                 try {
43                     Session JavaDoc session = conn.createSession(false, 1);
44                     MessageConsumer JavaDoc consumer = session.createConsumer(queue, null);
45                     Message JavaDoc msg = consumer.receive(1000);
46                 }
47                 catch (JMSException JavaDoc e) {
48                     e.printStackTrace();
49                 }
50             }
51         };
52         new Thread JavaDoc(r).start();
53         conn.start();
54
55         try {
56             synchronized (this) {
57                 wait(3000);
58             }
59         }
60         catch (InterruptedException JavaDoc e) {
61             e.printStackTrace();
62         }
63     }
64
65     protected void setUp() throws Exception JavaDoc {
66         bindAddress = "tcp://localhost:61616";
67         super.setUp();
68     }
69     
70     
71 }
72
Popular Tags