You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by ma...@apache.org on 2013/06/24 15:13:00 UTC

svn commit: r1496023 - in /nutch/branches/2.x: ./ src/plugin/ src/plugin/urlfilter-prefix/src/test/ src/plugin/urlfilter-prefix/src/test/org/ src/plugin/urlfilter-prefix/src/test/org/apache/ src/plugin/urlfilter-prefix/src/test/org/apache/nutch/ src/pl...

Author: markus
Date: Mon Jun 24 13:12:59 2013
New Revision: 1496023

URL: http://svn.apache.org/r1496023
Log:
NUTCH-1126 JUnit test for urlfilter-prefix

Added:
    nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/
    nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/org/
    nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/org/apache/
    nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/org/apache/nutch/
    nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/org/apache/nutch/urlfilter/
    nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/org/apache/nutch/urlfilter/prefix/
    nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/org/apache/nutch/urlfilter/prefix/TestPrefixURLFilter.java
Modified:
    nutch/branches/2.x/CHANGES.txt
    nutch/branches/2.x/src/plugin/build.xml

Modified: nutch/branches/2.x/CHANGES.txt
URL: http://svn.apache.org/viewvc/nutch/branches/2.x/CHANGES.txt?rev=1496023&r1=1496022&r2=1496023&view=diff
==============================================================================
--- nutch/branches/2.x/CHANGES.txt (original)
+++ nutch/branches/2.x/CHANGES.txt Mon Jun 24 13:12:59 2013
@@ -2,6 +2,8 @@ Nutch Change Log
 
 Current Development
 
+* NUTCH-1126 JUnit test for urlfilter-prefix (Talat UYARER via markus)
+
 * NUTCH-1585 Ensure duplicate tags do not exist in microformat-reltag tag set (lewismc)
 
 * NUTCH-1475 Index-More Plugin -- A better fall back value for date field (James Sullivan, snagel via lewismc)

Modified: nutch/branches/2.x/src/plugin/build.xml
URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/plugin/build.xml?rev=1496023&r1=1496022&r2=1496023&view=diff
==============================================================================
--- nutch/branches/2.x/src/plugin/build.xml (original)
+++ nutch/branches/2.x/src/plugin/build.xml Mon Jun 24 13:12:59 2013
@@ -81,7 +81,8 @@
      <ant dir="language-identifier" target="test"/>
      <ant dir="protocol-httpclient" target="test"/>
      <ant dir="urlfilter-automaton" target="test"/>
-     <ant dir="urlfilter-domain" target="test" />
+     <ant dir="urlfilter-domain" target="test"/>
+     <ant dir="urlfilter-prefix" target="test"/>
      <ant dir="urlfilter-regex" target="test"/>
      <ant dir="urlfilter-suffix" target="test"/>
      <ant dir="urlnormalizer-basic" target="test"/>

Added: nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/org/apache/nutch/urlfilter/prefix/TestPrefixURLFilter.java
URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/org/apache/nutch/urlfilter/prefix/TestPrefixURLFilter.java?rev=1496023&view=auto
==============================================================================
--- nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/org/apache/nutch/urlfilter/prefix/TestPrefixURLFilter.java (added)
+++ nutch/branches/2.x/src/plugin/urlfilter-prefix/src/test/org/apache/nutch/urlfilter/prefix/TestPrefixURLFilter.java Mon Jun 24 13:12:59 2013
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nutch.urlfilter.prefix;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import java.io.IOException;
+
+
+/**
+ * JUnit test for <code>PrefixURLFilter</code>.
+ *
+ * @author Talat Uyarer
+ * @author Cihad Guzel
+ */
+public class TestPrefixURLFilter extends TestCase {
+  private static final String prefixes =
+    "# this is a comment\n" +
+    "\n" +
+    "http://\n" +
+    "https://\n" +
+    "file://\n" +
+    "ftp://\n";
+
+  private static final String[] urls = new String[] {
+    "http://www.example.com/",
+    "https://www.example.com/",
+    "ftp://www.example.com/",
+    "file://www.example.com/",
+    "abcd://www.example.com/",
+    "www.example.com/",
+  };
+
+  private static String[] urlsModeAccept = new String[] {
+    urls[0],
+    urls[1],
+    urls[2],
+    urls[3],
+    null,
+    null
+  };
+
+  private PrefixURLFilter filter = null;
+
+  public static Test suite() {
+    return new TestSuite(TestPrefixURLFilter.class);
+  }
+
+  public static void main(String[] args) {
+    TestRunner.run(suite());
+  }
+
+  public void setUp() throws IOException {
+    filter = new PrefixURLFilter(prefixes);
+  }
+
+  public void testModeAccept() {
+    for (int i = 0; i < urls.length; i++) {
+      assertTrue(urlsModeAccept[i] == filter.filter(urls[i]));
+    }
+  }
+}