1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package org.archive.util;
27
28 import org.apache.commons.httpclient.URIException;
29
30 import junit.framework.Test;
31 import junit.framework.TestCase;
32 import junit.framework.TestSuite;
33
34 /***
35 * JUnit test suite for SURT
36 *
37 * @author gojomo
38 * @version $ Id$
39 */
40 public class SURTTest extends TestCase {
41 /***
42 * Create a new MemQueueTest object
43 *
44 * @param testName
45 * the name of the test
46 */
47 public SURTTest(final String testName) {
48 super(testName);
49 }
50
51 /***
52 * run all the tests for MemQueueTest
53 *
54 * @param argv
55 * the command line arguments
56 */
57 public static void main(String argv[]) {
58 junit.textui.TestRunner.run(suite());
59 }
60
61 /***
62 * return the suite of tests for MemQueueTest
63 *
64 * @return the suite of test
65 */
66 public static Test suite() {
67 return new TestSuite(SURTTest.class);
68 }
69
70 public void testMisc() throws URIException {
71 assertEquals("",
72 "http://(org,archive,www,)",
73 SURT.fromURI("http://www.archive.org"));
74
75 assertEquals("",
76 "http://(org,archive,www,)/movies/movies.php",
77 SURT.fromURI("http://www.archive.org/movies/movies.php"));
78
79 assertEquals("",
80 "http://(org,archive,www,:8080)/movies/movies.php",
81 SURT.fromURI("http://www.archive.org:8080/movies/movies.php"));
82
83 assertEquals("",
84 "http://(org,archive,www,@user:pass)/movies/movies.php",
85 SURT.fromURI("http://user:pass@www.archive.org/movies/movies.php"));
86
87 assertEquals("",
88 "http://(org,archive,www,:8080@user:pass)/movies/movies.php",
89 SURT.fromURI("http://user:pass@www.archive.org:8080/movies/movies.php"));
90
91 assertEquals("",
92 "http://(org,archive,www,)/movies/movies.php#top",
93 SURT.fromURI("http://www.archive.org/movies/movies.php#top"));
94 }
95
96 public void testAtSymbolInPath() throws URIException {
97 assertEquals("@ in path",
98 "http://(com,example,www,)/foo@bar",
99 SURT.fromURI("http://www.example.com/foo@bar"));
100 }
101
102 /***
103 * Verify that dotted-quad numeric IP address is unreversed as per change
104 * requested in: [ 1572391 ] SURTs for IP-address URIs unhelpful
105 *
106 * @throws URIException
107 */
108 public void testDottedQuadAuthority() throws URIException {
109 assertEquals("dotted-quad IP authority",
110 "http://(127.2.34.5)/foo",
111 SURT.fromURI("http://127.2.34.5/foo"));
112 }
113 }
114