01: /*
02: * Conditions Of Use
03: *
04: * This software was developed by employees of the National Institute of
05: * Standards and Technology (NIST), and others.
06: * This software is has been contributed to the public domain.
07: * As a result, a formal license is not needed to use the software.
08: *
09: * This software is provided "AS IS."
10: * NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
11: * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
12: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
13: * AND DATA ACCURACY. NIST does not warrant or make any representations
14: * regarding the use of the software or the results thereof, including but
15: * not limited to the correctness, accuracy, reliability or usefulness of
16: * the software.
17: *
18: *
19: */
20: /*
21: * Created on Jul 25, 2004
22: *
23: *The JAIN-SIP project.
24: */
25: package test.unit.gov.nist.javax.sip.parser;
26:
27: import gov.nist.javax.sip.address.*;
28: import gov.nist.javax.sip.parser.*;
29: import junit.framework.TestCase;
30:
31: /**
32: *
33: */
34: public class URLParserTest extends TestCase {
35:
36: /*
37: * @see TestCase#setUp()
38: */
39: protected void setUp() throws Exception {
40: super .setUp();
41: System.out.println("begin test " + getClass().getName());
42: }
43:
44: /*
45: * @see TestCase#tearDown()
46: */
47: protected void tearDown() throws Exception {
48: super .tearDown();
49: System.out.println("end test " + getClass().getName());
50: }
51:
52: public void testURLParser() {
53: String urls[] = {
54: "sip:j.doe@big.com;lr",
55: "sip:conference=1234@sip.convedia.com;xyz=pqd",
56: "sip:herbivore.ncsl.nist.gov:5070;maddr=129.6.55.251;lc",
57: "sip:1-301-975-3664@foo.bar.com;user=phone",
58: "sip:129.6.55.181",
59: "sip:herbivore.ncsl.nist.gov:5070;maddr=129.6.55.251?method=INVITE&contact=sip:foo.bar.com",
60: "sip:j.doe@big.com",
61: "sip:j.doe:secret@big.com;transport=tcp",
62: "sip:j.doe@big.com?subject=project",
63: "sip:+1-212-555-1212:1234@gateway.com;user=phone",
64: "sip:1212@gateway.com",
65: "sip:alice@10.1.2.3",
66: "sip:alice@example.com",
67: "sip:alice",
68: "sip:alice@registrar.com;method=REGISTER",
69: "sip:annc@10.10.30.186:6666;early=no;play=http://10.10.30.186:8080/examples/pin.vxml",
70: "tel:+463-1701-4291", "tel:46317014291",
71: "http://10.10.30.186:8080/examples/pin.vxml" };
72:
73: try {
74: for (int i = 0; i < urls.length; i++) {
75:
76: String url = urls[i];
77: URLParser urlParser = new URLParser(url);
78: GenericURI uri = urlParser.parse();
79: assertEquals(uri, new URLParser(uri.encode()).parse());
80: }
81: } catch (Exception ex) {
82: fail(getClass().getName());
83: }
84:
85: }
86:
87: }
|