KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > archive > util > SURTTest


1 /* SURTTest
2  *
3  * $Id: SURTTest.java,v 1.5.16.1 2007/01/13 01:31:40 stack-sf Exp $
4  *
5  * Created Tue Jan 20 14:17:59 PST 2004
6  *
7  * Copyright (C) 2004 Internet Archive.
8  *
9  * This file is part of the Heritrix web crawler (crawler.archive.org).
10  *
11  * Heritrix is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser Public License as published by
13  * the Free Software Foundation; either version 2.1 of the License, or
14  * any later version.
15  *
16  * Heritrix is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser Public License
22  * along with Heritrix; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 JavaDoc 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 JavaDoc 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
115
Popular Tags