KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > net > protocol > transport > ConnectionIDTest


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.net.protocol.transport;
5
6 import com.tc.test.TCTestCase;
7
8 public class ConnectionIDTest extends TCTestCase {
9
10   private static final String JavaDoc VALID_SERVER_ID = "aaBBccddeeff11223344556677889900";
11   private static final String JavaDoc INVALID_SERVER_ID1 = "Gabbccddeeff11223344556677889900"; // bad char
12
private static final String JavaDoc INVALID_SERVER_ID2 = "abbccddeeff11223344556677889900"; // bad length
13

14   public void test() {
15     try {
16       ConnectionID connectionID = ConnectionID.parse("12." + VALID_SERVER_ID);
17       assertEquals(12, connectionID.getChannelID());
18       assertEquals(VALID_SERVER_ID, connectionID.getServerID());
19     } catch (InvalidConnectionIDException e) {
20       fail(e);
21     }
22
23     try {
24       ConnectionID.parse("");
25       fail();
26     } catch (InvalidConnectionIDException e) {
27       // expected
28
}
29
30     try {
31       ConnectionID.parse(null);
32       fail();
33     } catch (InvalidConnectionIDException e) {
34       // expected
35
}
36
37     try {
38       ConnectionID.parse("sdljksdf");
39       fail();
40     } catch (InvalidConnectionIDException e) {
41       // expected
42
}
43
44
45     try {
46       ConnectionID.parse("." + VALID_SERVER_ID);
47       fail();
48     } catch (InvalidConnectionIDException e) {
49       // expected
50
}
51
52     try {
53       ConnectionID.parse(VALID_SERVER_ID + ".");
54       fail();
55     } catch (InvalidConnectionIDException e) {
56       // expected
57
}
58
59     try {
60       ConnectionID.parse(VALID_SERVER_ID + ".42");
61       fail();
62     } catch (InvalidConnectionIDException e) {
63       // expected
64
}
65
66     try {
67       ConnectionID.parse("212." + INVALID_SERVER_ID1);
68       fail();
69     } catch (InvalidConnectionIDException e) {
70       // expected
71
}
72
73
74     try {
75       ConnectionID.parse("144." + INVALID_SERVER_ID2);
76       fail();
77     } catch (InvalidConnectionIDException e) {
78       // expected
79
}
80
81   }
82
83 }
84
Popular Tags