KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > ConnectionCleanupTest


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;
19
20 import javax.jms.JMSException JavaDoc;
21 import javax.jms.Session JavaDoc;
22
23 import org.apache.activemq.ActiveMQConnection;
24 import org.apache.activemq.ActiveMQConnectionFactory;
25
26 import junit.framework.TestCase;
27
28 /**
29  * @version $Revision: 1.2 $
30  */

31 public class ConnectionCleanupTest extends TestCase {
32
33     private ActiveMQConnection connection;
34
35     protected void setUp() throws Exception JavaDoc {
36         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
37         connection = (ActiveMQConnection) factory.createConnection();
38     }
39
40     /**
41      * @see junit.framework.TestCase#tearDown()
42      */

43     protected void tearDown() throws Exception JavaDoc {
44         connection.close();
45     }
46
47     /**
48      * @throws JMSException
49      */

50     public void testChangeClientID() throws JMSException JavaDoc {
51         
52         connection.setClientID("test");
53         Session JavaDoc session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
54         
55         try {
56             connection.setClientID("test");
57             //fail("Should have received JMSException");
58
} catch ( JMSException JavaDoc e ) {
59         }
60         
61         connection.cleanup();
62         connection.setClientID("test");
63         
64         connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
65         
66         try {
67             connection.setClientID("test");
68             //fail("Should have received JMSException");
69
} catch ( JMSException JavaDoc e ) {
70         }
71     }
72
73 }
74
Popular Tags