01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.net.protocol.transport;
05:
06: import com.tc.test.TCTestCase;
07:
08: public class ConnectionIDTest extends TCTestCase {
09:
10: private static final String VALID_SERVER_ID = "aaBBccddeeff11223344556677889900";
11: private static final String INVALID_SERVER_ID1 = "Gabbccddeeff11223344556677889900"; // bad char
12: private static final String INVALID_SERVER_ID2 = "abbccddeeff11223344556677889900"; // bad length
13:
14: public void test() {
15: try {
16: ConnectionID connectionID = ConnectionID.parse("12."
17: + VALID_SERVER_ID);
18: assertEquals(12, connectionID.getChannelID());
19: assertEquals(VALID_SERVER_ID, connectionID.getServerID());
20: } catch (InvalidConnectionIDException e) {
21: fail(e);
22: }
23:
24: try {
25: ConnectionID.parse("");
26: fail();
27: } catch (InvalidConnectionIDException e) {
28: // expected
29: }
30:
31: try {
32: ConnectionID.parse(null);
33: fail();
34: } catch (InvalidConnectionIDException e) {
35: // expected
36: }
37:
38: try {
39: ConnectionID.parse("sdljksdf");
40: fail();
41: } catch (InvalidConnectionIDException e) {
42: // expected
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: try {
74: ConnectionID.parse("144." + INVALID_SERVER_ID2);
75: fail();
76: } catch (InvalidConnectionIDException e) {
77: // expected
78: }
79:
80: }
81:
82: }
|