Update of /cvsroot/nutch/playground/src/test/net/nutch/net
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10313/src/test/net/nutch/net

Added Files:
        TestUrlNormalizer.java 
Log Message:
intial commit

--- NEW FILE: TestUrlNormalizer.java ---
/* Copyright (c) 2003 The Nutch Organization.  All rights reserved.   */
/* Use subject to the conditions in http://www.nutch.org/LICENSE.txt. */

package net.nutch.net;

import java.net.URL;
import junit.framework.TestCase;

/** Unit tests for UrlNormalizer. */
public class TestUrlNormalizer extends TestCase {
  public TestUrlNormalizer(String name) { super(name); }

  public void testNormalizer() throws Exception {
    // check that leading and trailing spaces are removed
    normalizeTest(" http://foo.com/ ", "http://foo.com/";);

    // check that protocol is lower cased
    normalizeTest("HTTP://foo.com/";, "http://foo.com/";);

    // check that host is lower cased
    normalizeTest("http://Foo.Com/index.html";, "http://foo.com/index.html";);
    normalizeTest("http://Foo.Com/index.html";, "http://foo.com/index.html";);

    // check that port number is normalized
    normalizeTest("http://foo.com:80/index.html";, "http://foo.com/index.html";);
    normalizeTest("http://foo.com:81/";, "http://foo.com:81/";);

    // check that null path is normalized
    normalizeTest("http://foo.com";, "http://foo.com/";);

//     // check that encoding is normalized
//     normalizeTest("http://foo.com/%66oo.html";, "http://foo.com/foo.html";);
  }

  private void normalizeTest(String weird, String normal) throws Exception {
    assertEquals(normal, UrlNormalizer.normalize(weird));
  }
        
  public static void main(String[] args) throws Exception {
    new TestUrlNormalizer("test").testNormalizer();
  }



}



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Nutch-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nutch-cvs

Reply via email to