001: /* SURTTest
002: *
003: * $Id: SURTTest.java 4717 2006-11-13 17:34:07Z gojomo $
004: *
005: * Created Tue Jan 20 14:17:59 PST 2004
006: *
007: * Copyright (C) 2004 Internet Archive.
008: *
009: * This file is part of the Heritrix web crawler (crawler.archive.org).
010: *
011: * Heritrix is free software; you can redistribute it and/or modify
012: * it under the terms of the GNU Lesser Public License as published by
013: * the Free Software Foundation; either version 2.1 of the License, or
014: * any later version.
015: *
016: * Heritrix is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
019: * GNU Lesser Public License for more details.
020: *
021: * You should have received a copy of the GNU Lesser Public License
022: * along with Heritrix; if not, write to the Free Software
023: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024: */
025:
026: package org.archive.util;
027:
028: import org.apache.commons.httpclient.URIException;
029:
030: import junit.framework.Test;
031: import junit.framework.TestCase;
032: import junit.framework.TestSuite;
033:
034: /**
035: * JUnit test suite for SURT
036: *
037: * @author gojomo
038: * @version $ Id$
039: */
040: public class SURTTest extends TestCase {
041: /**
042: * Create a new MemQueueTest object
043: *
044: * @param testName
045: * the name of the test
046: */
047: public SURTTest(final String testName) {
048: super (testName);
049: }
050:
051: /**
052: * run all the tests for MemQueueTest
053: *
054: * @param argv
055: * the command line arguments
056: */
057: public static void main(String argv[]) {
058: junit.textui.TestRunner.run(suite());
059: }
060:
061: /**
062: * return the suite of tests for MemQueueTest
063: *
064: * @return the suite of test
065: */
066: public static Test suite() {
067: return new TestSuite(SURTTest.class);
068: }
069:
070: public void testMisc() throws URIException {
071: assertEquals("", "http://(org,archive,www,)", SURT
072: .fromURI("http://www.archive.org"));
073:
074: assertEquals(
075: "",
076: "http://(org,archive,www,)/movies/movies.php",
077: SURT
078: .fromURI("http://www.archive.org/movies/movies.php"));
079:
080: assertEquals(
081: "",
082: "http://(org,archive,www,:8080)/movies/movies.php",
083: SURT
084: .fromURI("http://www.archive.org:8080/movies/movies.php"));
085:
086: assertEquals(
087: "",
088: "http://(org,archive,www,@user:pass)/movies/movies.php",
089: SURT
090: .fromURI("http://user:pass@www.archive.org/movies/movies.php"));
091:
092: assertEquals(
093: "",
094: "http://(org,archive,www,:8080@user:pass)/movies/movies.php",
095: SURT
096: .fromURI("http://user:pass@www.archive.org:8080/movies/movies.php"));
097:
098: assertEquals(
099: "",
100: "http://(org,archive,www,)/movies/movies.php#top",
101: SURT
102: .fromURI("http://www.archive.org/movies/movies.php#top"));
103: }
104:
105: public void testAtSymbolInPath() throws URIException {
106: assertEquals("@ in path", "http://(com,example,www,)/foo@bar",
107: SURT.fromURI("http://www.example.com/foo@bar"));
108: }
109:
110: /**
111: * Verify that dotted-quad numeric IP address is unreversed as per change
112: * requested in: [ 1572391 ] SURTs for IP-address URIs unhelpful
113: *
114: * @throws URIException
115: */
116: public void testDottedQuadAuthority() throws URIException {
117: assertEquals("dotted-quad IP authority",
118: "http://(127.2.34.5)/foo", SURT
119: .fromURI("http://127.2.34.5/foo"));
120: }
121: }
|