Source code: org/activemq/gbean/ConnectorTest.java
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.activemq.gbean;
19
20 import junit.framework.TestCase;
21
22 /**
23 * Tests to ensure that URL parsing and updating doesn't blow up
24 *
25 * @version $Revision: 1.0$
26 */
27 public class ConnectorTest extends TestCase {
28 public ActiveMQConnectorGBean test;
29
30 protected void setUp() throws Exception {
31 }
32
33 public void testURLManipulation() {
34 test = new ActiveMQConnectorGBean(null, "foo", "localhost", 1234);
35 assertEquals("foo://localhost:1234", test.getUrl());
36 assertEquals("foo", test.getProtocol());
37 assertEquals("localhost", test.getHost());
38 assertEquals(1234, test.getPort());
39 test.setHost("0.0.0.0");
40 assertEquals("foo://0.0.0.0:1234", test.getUrl());
41 assertEquals("foo", test.getProtocol());
42 assertEquals("0.0.0.0", test.getHost());
43 assertEquals(1234, test.getPort());
44 test.setPort(8765);
45 assertEquals("foo://0.0.0.0:8765", test.getUrl());
46 assertEquals("foo", test.getProtocol());
47 assertEquals("0.0.0.0", test.getHost());
48 assertEquals(8765, test.getPort());
49 test.setProtocol("bar");
50 assertEquals("bar://0.0.0.0:8765", test.getUrl());
51 assertEquals("bar", test.getProtocol());
52 assertEquals("0.0.0.0", test.getHost());
53 assertEquals(8765, test.getPort());
54 test = new ActiveMQConnectorGBean(null, "vm", "localhost", -1);
55 assertEquals("vm://localhost", test.getUrl());
56 assertEquals("vm", test.getProtocol());
57 assertEquals("localhost", test.getHost());
58 assertEquals(-1, test.getPort());
59 }
60 }