KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ca > commons > jndi > ConnectionDataTest


1 /**
2  * Created by IntelliJ IDEA.
3  * User: erstr01
4  * Date: Dec 20, 2002
5  * Time: 3:45:33 PM
6  * To change this template use Options | File Templates.
7  */

8 package com.ca.commons.jndi;
9
10 import junit.framework.*;
11
12
13
14 public class ConnectionDataTest extends TestCase
15 {
16
17     public static ConnectionData testConnection;
18
19     public ConnectionDataTest(String JavaDoc name)
20     {
21         super(name);
22     }
23
24
25
26     public static Test suite()
27     {
28         return new TestSuite(ConnectionDataTest.class);
29     }
30
31     protected void setUp()
32     {
33     }
34
35     public static void main(String JavaDoc[] args)
36     {
37         junit.textui.TestRunner.run(suite());
38     }
39
40     public void testGetPort()
41     {
42         ConnectionData testConnection, dsmlURL;
43         testConnection = new ConnectionData();
44         testConnection.setURL("ldap://bloop:19389");
45         assertEquals("port I 19389 " + testConnection.getPort(), 19389, testConnection.getPort());
46         testConnection.setProtocol(ConnectionData.DSML);
47         testConnection.setURL("dsml://bloop:19389/myserver/stuff");
48         assertEquals("port II 19389 " + testConnection.getPort(), 19389, testConnection.getPort());
49         testConnection.setURL("dsml://fnord.ca.com:19389/myserver/stuff");
50         assertEquals("port III 19389 " + testConnection.getPort(), 19389, testConnection.getPort());
51         testConnection.setURL("dsml://fnord.ca.com:66000/myserver/stuff");
52         assertEquals("port IV 66000 (-1) " + testConnection.getPort(), -1, testConnection.getPort());
53         testConnection.setURL("dsml://fnord.ca.com:-500/myserver/stuff");
54         assertEquals("port V -500 (-1) " + testConnection.getPort(), -1, testConnection.getPort());
55     }
56
57     public void testGetHost()
58     {
59         ConnectionData testConnection, dsmlURL;
60         testConnection = new ConnectionData();
61         testConnection.setURL("ldap://bloop:19389");
62         assertEquals("host bloop " + testConnection.getHost(), "bloop", testConnection.getHost());
63         testConnection.setProtocol(ConnectionData.DSML);
64         testConnection.setURL("http://bloop:19389/myserver/stuff");
65         assertEquals("host bloop " + testConnection.getHost(), "bloop", testConnection.getHost());
66         testConnection.setURL("http://fnord.ca.com:19389/myserver/stuff");
67         assertEquals("host fnord.ca.com " + testConnection.getHost(), "fnord.ca.com", testConnection.getHost());
68     }
69
70 }
71
Popular Tags