Apache Nutch is an extensible and scalable web crawler
NUTCH-280 added minimal test case and a fix for it, reported by Grant Glouser
Sami Sirend65b0bb5f59c
diff --git a/src/plugin/build.xml b/src/plugin/build.xmlindex 06fb40a7f..b06199fb3 100755--- a/src/plugin/build.xml+++ b/src/plugin/build.xml@@ -80,6 +80,7 @@<!-- <ant dir="parse-rtf" target="test"/> --><ant dir="parse-swf" target="test"/><ant dir="parse-zip" target="test"/>+ <ant dir="query-url" target="test"/><ant dir="urlfilter-automaton" target="test"/><ant dir="urlfilter-regex" target="test"/><ant dir="urlfilter-suffix" target="test"/>diff --git a/src/plugin/query-url/src/java/org/apache/nutch/searcher/url/URLQueryFilter.java b/src/plugin/query-url/src/java/org/apache/nutch/searcher/url/URLQueryFilter.javaindex 094afb75c..ef84c8e57 100644--- a/src/plugin/query-url/src/java/org/apache/nutch/searcher/url/URLQueryFilter.java+++ b/src/plugin/query-url/src/java/org/apache/nutch/searcher/url/URLQueryFilter.java@@ -24,17 +24,13 @@ import org.apache.hadoop.conf.Configuration;* BasicIndexingFilter.*/public class URLQueryFilter extends FieldQueryFilter {- private Configuration conf;public URLQueryFilter() {super("url");}public void setConf(Configuration conf) {- this.conf = conf;+ super.setConf(conf);}- public Configuration getConf() {- return this.conf;- }}diff --git a/src/plugin/query-url/src/test/org/apache/nutch/searcher/url/TestURLQueryFilter.java b/src/plugin/query-url/src/test/org/apache/nutch/searcher/url/TestURLQueryFilter.javanew file mode 100644index 000000000..868a8139a--- /dev/null+++ b/src/plugin/query-url/src/test/org/apache/nutch/searcher/url/TestURLQueryFilter.java@@ -0,0 +1,43 @@+/*+ * Copyright 2006 The Apache Software Foundation+ *+ * Licensed 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.searcher.url;++import org.apache.hadoop.conf.Configuration;+import org.apache.lucene.search.BooleanQuery;+import org.apache.nutch.searcher.Query;+import org.apache.nutch.util.NutchConfiguration;++import junit.framework.TestCase;++public class TestURLQueryFilter extends TestCase {++ public TestURLQueryFilter(String name) {+ super(name);+ }++ public void testURLQueryFilter() {+ Configuration conf = NutchConfiguration.create();+ URLQueryFilter urlQueryFilter = new URLQueryFilter();+ urlQueryFilter.setConf(conf);+ try {+ Query q = Query.parse("url:www.apache.org", conf);+ BooleanQuery result = new BooleanQuery();+ urlQueryFilter.filter(q, result);+ } catch (Exception e) {+ fail("Should not throw any exception!");+ }+ }+}