Modified: lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestOutlinkExtractor.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestOutlinkExtractor.java?rev=374796&r1=374795&r2=374796&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestOutlinkExtractor.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestOutlinkExtractor.java Fri Feb 3 16:38:32 2006 @@ -18,7 +18,8 @@ import org.apache.nutch.parse.Outlink; import org.apache.nutch.parse.OutlinkExtractor; -import org.apache.nutch.util.NutchConf; +import org.apache.hadoop.conf.Configuration; +import org.apache.nutch.util.NutchConfiguration; import junit.framework.TestCase; @@ -31,15 +32,15 @@ */ public class TestOutlinkExtractor extends TestCase { - private static NutchConf nutchConf = new NutchConf(); + private static Configuration conf = NutchConfiguration.create(); public void testGetNoOutlinks() { Outlink[] outlinks = null; - outlinks = OutlinkExtractor.getOutlinks(null, nutchConf); + outlinks = OutlinkExtractor.getOutlinks(null, conf); assertNotNull(outlinks); assertEquals(0, outlinks.length); - outlinks = OutlinkExtractor.getOutlinks("", nutchConf); + outlinks = OutlinkExtractor.getOutlinks("", conf); assertNotNull(outlinks); assertEquals(0, outlinks.length); } @@ -48,7 +49,7 @@ Outlink[] outlinks = OutlinkExtractor.getOutlinks( "Test with http://www.nutch.org/index.html is it found? " + "What about www.google.com at http://www.google.de " + - "A longer URL could be http://www.sybit.com/solutions/portals.html", nutchConf); + "A longer URL could be http://www.sybit.com/solutions/portals.html", conf); assertTrue("Url not found!", outlinks.length == 3); assertEquals("Wrong URL", "http://www.nutch.org/index.html", outlinks[0].getToUrl()); @@ -60,7 +61,7 @@ Outlink[] outlinks = OutlinkExtractor.getOutlinks( "Test with http://www.nutch.org/index.html is it found? " + "What about www.google.com at http://www.google.de " + - "A longer URL could be http://www.sybit.com/solutions/portals.html", "http://www.sybit.de", nutchConf); + "A longer URL could be http://www.sybit.com/solutions/portals.html", "http://www.sybit.de", conf); assertTrue("Url not found!", outlinks.length == 3); assertEquals("Wrong URL", "http://www.nutch.org/index.html", outlinks[0].getToUrl()); @@ -70,7 +71,7 @@ public void testGetOutlinksFtp() { Outlink[] outlinks = OutlinkExtractor.getOutlinks( "Test with ftp://www.nutch.org is it found? " + - "What about www.google.com at ftp://www.google.de", nutchConf); + "What about www.google.com at ftp://www.google.de", conf); assertTrue("Url not found!", outlinks.length >1); assertEquals("Wrong URL", "ftp://www.nutch.org/", outlinks[0].getToUrl());
Modified: lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParseData.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParseData.java?rev=374796&r1=374795&r2=374796&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParseData.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParseData.java Fri Feb 3 16:38:32 2006 @@ -16,9 +16,12 @@ package org.apache.nutch.parse; -import org.apache.nutch.io.*; +import org.apache.hadoop.io.*; +import org.apache.hadoop.conf.Configuration; +import org.apache.nutch.util.NutchConfiguration; + +import org.apache.nutch.util.WritableTestUtils; import org.apache.nutch.protocol.ContentProperties; -import org.apache.nutch.util.NutchConf; import junit.framework.TestCase; @@ -26,7 +29,7 @@ public class TestParseData extends TestCase { - private NutchConf nutchConf = new NutchConf(); + private Configuration conf = NutchConfiguration.create(); public TestParseData(String name) { super(name); } @@ -35,8 +38,8 @@ String title = "The Foo Page"; Outlink[] outlinks = new Outlink[] { - new Outlink("http://foo.com/", "Foo", nutchConf), - new Outlink("http://bar.com/", "Bar", nutchConf) + new Outlink("http://foo.com/", "Foo", conf), + new Outlink("http://bar.com/", "Bar", conf) }; ContentProperties metaData = new ContentProperties(); @@ -44,9 +47,9 @@ metaData.put("Charset", "UTF-8"); ParseData r = new ParseData(ParseStatus.STATUS_SUCCESS, title, outlinks, metaData); - r.setConf(nutchConf); + r.setConf(conf); - TestWritable.testWritable(r); + WritableTestUtils.testWritable(r, conf); } } Modified: lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParseText.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParseText.java?rev=374796&r1=374795&r2=374796&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParseText.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParseText.java Fri Feb 3 16:38:32 2006 @@ -16,7 +16,9 @@ package org.apache.nutch.parse; -import org.apache.nutch.io.*; +import org.apache.hadoop.io.*; +import org.apache.nutch.util.WritableTestUtils; + import junit.framework.TestCase; /** Unit tests for ParseText. */ @@ -30,7 +32,7 @@ ParseText s = new ParseText(page); - TestWritable.testWritable(s); + WritableTestUtils.testWritable(s); } } Modified: lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParserFactory.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParserFactory.java?rev=374796&r1=374795&r2=374796&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParserFactory.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/parse/TestParserFactory.java Fri Feb 3 16:38:32 2006 @@ -21,7 +21,8 @@ // Nutch imports import org.apache.nutch.plugin.Extension; -import org.apache.nutch.util.NutchConf; +import org.apache.hadoop.conf.Configuration; +import org.apache.nutch.util.NutchConfiguration; /** * Unit test for new parse plugin selection. @@ -31,18 +32,18 @@ */ public class TestParserFactory extends TestCase { - private NutchConf nutchConf; + private Configuration conf; private ParserFactory parserFactory; public TestParserFactory(String name) { super(name); } /** Inits the Test Case with the test parse-plugin file */ protected void setUp() throws Exception { - nutchConf = new NutchConf(); - nutchConf.set("plugin.includes", ".*"); - nutchConf.set("parse.plugin.file", + conf = NutchConfiguration.create(); + conf.set("plugin.includes", ".*"); + conf.set("parse.plugin.file", "org/apache/nutch/parse/parse-plugin-test.xml"); - parserFactory = new ParserFactory(nutchConf); + parserFactory = new ParserFactory(conf); } /** Unit test for <code>getParser(String, String)</code> method. */ Modified: lucene/nutch/trunk/src/test/org/apache/nutch/plugin/SimpleTestPlugin.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/plugin/SimpleTestPlugin.java?rev=374796&r1=374795&r2=374796&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/plugin/SimpleTestPlugin.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/plugin/SimpleTestPlugin.java Fri Feb 3 16:38:32 2006 @@ -17,7 +17,7 @@ package org.apache.nutch.plugin; -import org.apache.nutch.util.NutchConf; +import org.apache.hadoop.conf.Configuration; /** * Simple Test plugin @@ -28,11 +28,11 @@ /** * @param pDescriptor - * @param nutchConf + * @param conf */ - public SimpleTestPlugin(PluginDescriptor pDescriptor, NutchConf nutchConf) { + public SimpleTestPlugin(PluginDescriptor pDescriptor, Configuration conf) { - super(pDescriptor, nutchConf); + super(pDescriptor, conf); } /* Modified: lucene/nutch/trunk/src/test/org/apache/nutch/plugin/TestPluginSystem.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/plugin/TestPluginSystem.java?rev=374796&r1=374795&r2=374796&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/plugin/TestPluginSystem.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/plugin/TestPluginSystem.java Fri Feb 3 16:38:32 2006 @@ -27,7 +27,8 @@ import junit.framework.TestCase; -import org.apache.nutch.util.NutchConf; +import org.apache.hadoop.conf.Configuration; +import org.apache.nutch.util.NutchConfiguration; /** * Unit tests for the plugin system @@ -38,17 +39,17 @@ private int fPluginCount; private LinkedList fFolders = new LinkedList(); - private NutchConf nutchConf ; + private Configuration conf ; private PluginRepository repository; protected void setUp() throws Exception { - this.nutchConf = new NutchConf(); - nutchConf.set("plugin.includes", ".*"); -// String string = this.nutchConf.get("plugin.includes", ""); -// nutchConf.set("plugin.includes", string + "|Dummy*"); + this.conf = NutchConfiguration.create(); + conf.set("plugin.includes", ".*"); +// String string = this.conf.get("plugin.includes", ""); +// conf.set("plugin.includes", string + "|Dummy*"); fPluginCount = 5; createDummyPlugins(fPluginCount); - this.repository = nutchConf.getPluginRepository(); + this.repository = PluginRepository.get(conf); } /* @@ -166,12 +167,12 @@ * @return a PluginFolderPath */ private String getPluginFolder() { - String[] strings = nutchConf.getStrings("plugin.folders"); + String[] strings = conf.getStrings("plugin.folders"); if (strings == null || strings.length == 0) fail("no plugin directory setuped.."); String name = strings[0]; - return new PluginManifestParser(nutchConf, this.repository).getPluginFolder(name).toString(); + return new PluginManifestParser(conf, this.repository).getPluginFolder(name).toString(); } /** @@ -264,4 +265,4 @@ public static void main(String[] args) throws IOException { new TestPluginSystem().createPluginManifest(1, "/"); } -} \ No newline at end of file +} Modified: lucene/nutch/trunk/src/test/org/apache/nutch/protocol/TestContent.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/protocol/TestContent.java?rev=374796&r1=374795&r2=374796&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/protocol/TestContent.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/protocol/TestContent.java Fri Feb 3 16:38:32 2006 @@ -16,8 +16,11 @@ package org.apache.nutch.protocol; -import org.apache.nutch.io.*; -import org.apache.nutch.util.NutchConf; +import org.apache.hadoop.io.*; +import org.apache.hadoop.conf.Configuration; +import org.apache.nutch.util.NutchConfiguration; + +import org.apache.nutch.util.WritableTestUtils; import junit.framework.TestCase; @@ -25,7 +28,7 @@ public class TestContent extends TestCase { - private static NutchConf nutchConf = new NutchConf(); + private static Configuration conf = NutchConfiguration.create(); public TestContent(String name) { super(name); } @@ -40,9 +43,9 @@ metaData.put("Content-Type", "text/html"); Content r = new Content(url, url, page.getBytes("UTF8"), "text/html", - metaData, nutchConf); + metaData, conf); - TestWritable.testWritable(r); + WritableTestUtils.testWritable(r); assertEquals("text/html", r.getMetadata().get("Content-Type")); assertEquals("text/html", r.getMetadata().get("content-type")); } @@ -55,49 +58,49 @@ c = new Content("http://www.foo.com/", "http://www.foo.com/", "".getBytes("UTF8"), - "text/html; charset=UTF-8", p, nutchConf); + "text/html; charset=UTF-8", p, conf); assertEquals("text/html", c.getContentType()); c = new Content("http://www.foo.com/foo.html", "http://www.foo.com/", "".getBytes("UTF8"), - "", p, nutchConf); + "", p, conf); assertEquals("text/html", c.getContentType()); c = new Content("http://www.foo.com/foo.html", "http://www.foo.com/", "".getBytes("UTF8"), - null, p, nutchConf); + null, p, conf); assertEquals("text/html", c.getContentType()); c = new Content("http://www.foo.com/", "http://www.foo.com/", "<html></html>".getBytes("UTF8"), - "", p, nutchConf); + "", p, conf); assertEquals("text/html", c.getContentType()); c = new Content("http://www.foo.com/foo.html", "http://www.foo.com/", "<html></html>".getBytes("UTF8"), - "text/plain", p, nutchConf); + "text/plain", p, conf); assertEquals("text/html", c.getContentType()); c = new Content("http://www.foo.com/foo.png", "http://www.foo.com/", "<html></html>".getBytes("UTF8"), - "text/plain", p, nutchConf); + "text/plain", p, conf); assertEquals("text/html", c.getContentType()); c = new Content("http://www.foo.com/", "http://www.foo.com/", "".getBytes("UTF8"), - "", p, nutchConf); + "", p, conf); assertEquals("", c.getContentType()); c = new Content("http://www.foo.com/", "http://www.foo.com/", "".getBytes("UTF8"), - null, p, nutchConf); + null, p, conf); assertNull(c.getContentType()); } Modified: lucene/nutch/trunk/src/test/org/apache/nutch/protocol/TestContentProperties.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/protocol/TestContentProperties.java?rev=374796&r1=374795&r2=374796&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/protocol/TestContentProperties.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/protocol/TestContentProperties.java Fri Feb 3 16:38:32 2006 @@ -16,8 +16,11 @@ package org.apache.nutch.protocol; -import org.apache.nutch.io.TestWritable; -import org.apache.nutch.util.NutchConf; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.io.*; + +import org.apache.nutch.util.WritableTestUtils; +import org.apache.nutch.util.NutchConfiguration; import junit.framework.TestCase; @@ -52,14 +55,14 @@ for (int i = 0; i < 10; i++) { properties.setProperty("key", "" + i); } - TestWritable.testWritable(properties); + WritableTestUtils.testWritable(properties); Content content = new Content("url", "url", new byte[0], "text/html", - new ContentProperties(), new NutchConf()); + new ContentProperties(), NutchConfiguration.create()); ContentProperties metadata = content.getMetadata(); for (int i = 0; i < 100; i++) { metadata.setProperty("aKey", "" + i); } - TestWritable.testWritable(content); + WritableTestUtils.testWritable(content); } - + } Modified: lucene/nutch/trunk/src/test/org/apache/nutch/searcher/TestHitDetails.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/searcher/TestHitDetails.java?rev=374796&r1=374795&r2=374796&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/searcher/TestHitDetails.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/searcher/TestHitDetails.java Fri Feb 3 16:38:32 2006 @@ -16,7 +16,7 @@ package org.apache.nutch.searcher; -import org.apache.nutch.io.*; +import org.apache.hadoop.io.*; import junit.framework.TestCase; public class TestHitDetails extends TestCase { Modified: lucene/nutch/trunk/src/test/org/apache/nutch/searcher/TestQuery.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/searcher/TestQuery.java?rev=374796&r1=374795&r2=374796&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/searcher/TestQuery.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/searcher/TestQuery.java Fri Feb 3 16:38:32 2006 @@ -20,40 +20,41 @@ import junit.framework.TestCase; import java.util.Arrays; import org.apache.nutch.analysis.NutchAnalysis; -import org.apache.nutch.util.NutchConf; +import org.apache.hadoop.conf.Configuration; +import org.apache.nutch.util.NutchConfiguration; public class TestQuery extends TestCase { - private static NutchConf nutchConf = new NutchConf(); + private static Configuration conf = NutchConfiguration.create(); public TestQuery(String name) { super(name); } public void testRequiredTerm() throws Exception { - Query query = new Query(nutchConf); + Query query = new Query(conf); query.addRequiredTerm("bobo"); testQuery(query, "bobo"); } public void testProhibitedTerm() throws Exception { - Query query = new Query(nutchConf); + Query query = new Query(conf); query.addProhibitedTerm("bobo"); testQuery(query, "-bobo"); } public void testRequiredPhrase() throws Exception { - Query query = new Query(nutchConf); + Query query = new Query(conf); query.addRequiredPhrase(new String[] {"bobo", "bogo"}); testQuery(query, "\"bobo bogo\""); } public void testProhibitedPhrase() throws Exception { - Query query = new Query(nutchConf); + Query query = new Query(conf); query.addProhibitedPhrase(new String[] {"bobo", "bogo"}); testQuery(query, "-\"bobo bogo\""); } public void testComplex() throws Exception { - Query query = new Query(nutchConf); + Query query = new Query(conf); query.addRequiredTerm("bobo"); query.addProhibitedTerm("bono"); query.addRequiredPhrase(new String[] {"bobo", "bogo"}); @@ -73,7 +74,7 @@ public static void testQueryParser(Query query, String string) throws Exception { - Query after = NutchAnalysis.parseQuery(string, nutchConf); + Query after = NutchAnalysis.parseQuery(string, conf); assertEquals(after, query); assertEquals(after.toString(), string); } @@ -86,7 +87,7 @@ ByteArrayInputStream iBuf = new ByteArrayInputStream(oBuf.toByteArray()); DataInputStream in = new DataInputStream(iBuf); - Query after = Query.read(in, nutchConf); + Query after = Query.read(in, conf); assertEquals(after, query); } @@ -99,7 +100,7 @@ public static void testQueryTerms(String query, String[] terms) throws Exception { - assertTrue(Arrays.equals(NutchAnalysis.parseQuery(query, nutchConf).getTerms(), + assertTrue(Arrays.equals(NutchAnalysis.parseQuery(query, conf).getTerms(), terms)); } Added: lucene/nutch/trunk/src/test/org/apache/nutch/util/WritableTestUtils.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/util/WritableTestUtils.java?rev=374796&view=auto ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/util/WritableTestUtils.java (added) +++ lucene/nutch/trunk/src/test/org/apache/nutch/util/WritableTestUtils.java Fri Feb 3 16:38:32 2006 @@ -0,0 +1,49 @@ +/** + * Copyright 2005 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.util; + +import org.apache.hadoop.io.*; +import org.apache.hadoop.conf.*; + +import junit.framework.TestCase; + +public class WritableTestUtils { + + /** Utility method for testing writables. */ + public static void testWritable(Writable before) throws Exception { + testWritable(before, null); + } + + /** Utility method for testing writables. */ + public static void testWritable(Writable before, Configuration conf) + throws Exception { + DataOutputBuffer dob = new DataOutputBuffer(); + before.write(dob); + + DataInputBuffer dib = new DataInputBuffer(); + dib.reset(dob.getData(), dob.getLength()); + + Writable after = (Writable)before.getClass().newInstance(); + if (conf != null) { + ((Configurable)after).setConf(conf); + } + after.readFields(dib); + + TestCase.assertEquals(before, after); + } + +}
