KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > transport > tcp > TransportUriTest


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.transport.tcp;
18
19 import org.apache.activemq.ActiveMQConnectionFactory;
20 import org.apache.activemq.EmbeddedBrokerTestSupport;
21 import org.apache.activemq.broker.BrokerService;
22
23 import javax.jms.Connection JavaDoc;
24 import javax.jms.JMSException JavaDoc;
25
26 /**
27  * @version $Revision: 467692 $
28  */

29 public class TransportUriTest extends EmbeddedBrokerTestSupport {
30
31     private String JavaDoc postfix = "?tcpNoDelay=true&keepAlive=true";
32     private Connection JavaDoc connection;
33
34     public void testUriOptionsWork() throws Exception JavaDoc {
35         String JavaDoc uri = bindAddress + postfix;
36 // System.out.println("Connecting via: " + uri);
37

38         connection = new ActiveMQConnectionFactory(uri).createConnection();
39         connection.start();
40     }
41
42     public void testBadVersionNumberDoesNotWork() throws Exception JavaDoc {
43         String JavaDoc uri = bindAddress + postfix + "&minmumWireFormatVersion=65535";
44 // System.out.println("Connecting via: " + uri);
45

46         try {
47             connection = new ActiveMQConnectionFactory(uri).createConnection();
48             connection.start();
49             fail("Should have thrown an exception!");
50         }
51         catch (Exception JavaDoc expected) {
52         }
53     }
54
55
56     public void testBadPropertyNameFails() throws Exception JavaDoc {
57         String JavaDoc uri = bindAddress + postfix + "&cheese=abc";
58 // System.out.println("Connecting via: " + uri);
59

60         try {
61             connection = new ActiveMQConnectionFactory(uri).createConnection();
62             connection.start();
63             fail("Should have thrown an exception!");
64         }
65         catch (Exception JavaDoc expected) {
66         }
67     }
68
69
70     protected void setUp() throws Exception JavaDoc {
71         bindAddress = "tcp://localhost:6161";
72         super.setUp();
73     }
74
75     protected void tearDown() throws Exception JavaDoc {
76         if (connection != null) {
77             try {
78                 connection.close();
79             }
80             catch (JMSException JavaDoc e) {
81                 e.printStackTrace();
82             }
83         }
84         super.tearDown();
85     }
86
87     protected BrokerService createBroker() throws Exception JavaDoc {
88         BrokerService answer = new BrokerService();
89         answer.setUseJmx(false);
90         answer.setPersistent(isPersistent());
91         answer.addConnector(bindAddress);
92         return answer;
93     }
94 }
95
Popular Tags