01: package test.unit.gov.nist.javax.sip.parser;
02:
03: import gov.nist.core.HostNameParser;
04: import gov.nist.core.HostPort;
05:
06: import java.text.ParseException;
07:
08: import junit.framework.TestCase;
09:
10: /**
11: * @author sli
12: *
13: */
14: public class HostNameParserTest extends TestCase {
15:
16: private final static String validHostNames[] = {
17: "foo.bar.com:1234", "proxima.chaplin.bt.co.uk",
18: "129.6.55.181:2345", "foo.bar.com: 1234",
19: "foo.bar.com : 1234 ",
20: "[3ffe:33:0:0:202:2dff:fe32:c31c%4]",
21: "[3ffe:33:0:0:202:2dff:fe32:c31c%4:1234]" };
22:
23: private final static String invalidHostNames[] = { ":1234", };
24:
25: public void testHostNameParser() {
26: for (int i = 0; i < validHostNames.length; i++) {
27: try {
28: String hostName = validHostNames[i];
29: System.out.println("hostName=" + hostName);
30: HostNameParser hnp = new HostNameParser(hostName);
31: HostPort hp = hnp.hostPort(true);
32: System.out.println("[" + hp.encode() + "]");
33: } catch (ParseException ex) {
34: fail(ex.getMessage());
35: }
36: }
37: }
38: }
|