1 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 VALID_SERVER_ID = "aaBBccddeeff11223344556677889900"; 11 private static final String INVALID_SERVER_ID1 = "Gabbccddeeff11223344556677889900"; private static final String INVALID_SERVER_ID2 = "abbccddeeff11223344556677889900"; 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 } 29 30 try { 31 ConnectionID.parse(null); 32 fail(); 33 } catch (InvalidConnectionIDException e) { 34 } 36 37 try { 38 ConnectionID.parse("sdljksdf"); 39 fail(); 40 } catch (InvalidConnectionIDException e) { 41 } 43 44 45 try { 46 ConnectionID.parse("." + VALID_SERVER_ID); 47 fail(); 48 } catch (InvalidConnectionIDException e) { 49 } 51 52 try { 53 ConnectionID.parse(VALID_SERVER_ID + "."); 54 fail(); 55 } catch (InvalidConnectionIDException e) { 56 } 58 59 try { 60 ConnectionID.parse(VALID_SERVER_ID + ".42"); 61 fail(); 62 } catch (InvalidConnectionIDException e) { 63 } 65 66 try { 67 ConnectionID.parse("212." + INVALID_SERVER_ID1); 68 fail(); 69 } catch (InvalidConnectionIDException e) { 70 } 72 73 74 try { 75 ConnectionID.parse("144." + INVALID_SERVER_ID2); 76 fail(); 77 } catch (InvalidConnectionIDException e) { 78 } 80 81 } 82 83 } 84 | Popular Tags |