1 2 3 4 package net.nutch.net; 5 6 import java.net.URL ; 7 import junit.framework.TestCase; 8 import net.nutch.net.RegexUrlNormalizer; 9 10 11 public class TestRegexUrlNormalizer extends TestBasicUrlNormalizer { 12 public TestRegexUrlNormalizer(String name) { super(name); } 13 14 public void testNormalizer() throws Exception { 15 normalizeTest("http://foo.com/foo.php?f=2&PHPSESSID=cdc993a493e899bed04f4d0c8a462a03", 16 "http://foo.com/foo.php?f=2"); 17 normalizeTest("http://foo.com/foo.php?f=2&PHPSESSID=cdc993a493e899bed04f4d0c8a462a03&q=3", 18 "http://foo.com/foo.php?f=2&q=3"); 19 normalizeTest("http://foo.com/foo.php?PHPSESSID=cdc993a493e899bed04f4d0c8a462a03&f=2", 20 "http://foo.com/foo.php?f=2"); 21 normalizeTest("http://foo.com/foo.php?PHPSESSID=cdc993a493e899bed04f4d0c8a462a03", 22 "http://foo.com/foo.php"); 23 } 24 25 private void normalizeTest(String weird, String normal) throws Exception { 26 String testSrcDir = System.getProperty("test.src.dir"); 27 String path = testSrcDir + "/net/nutch/net/test-regex-normalize.xml"; 28 RegexUrlNormalizer normalizer = new RegexUrlNormalizer(path); 29 assertEquals(normal, normalizer.normalize(weird)); 30 } 31 32 public static void main(String [] args) throws Exception { 33 new TestRegexUrlNormalizer("test").testNormalizer(); 34 new TestBasicUrlNormalizer("test").testNormalizer(); } 36 37 38 39 } 40 | Popular Tags |