getNormalizedName(String)
method. */
+ @Test
public void testGetNormalizedName() {
assertEquals("Content-Type", SpellCheckedMetadata
.getNormalizedName("Content-Type"));
@@ -67,6 +55,7 @@
}
/** Test for the add(String, String)
method. */
+ @Test
public void testAdd() {
String[] values = null;
SpellCheckedMetadata meta = new SpellCheckedMetadata();
@@ -96,6 +85,7 @@
}
/** Test for the set(String, String)
method. */
+ @Test
public void testSet() {
String[] values = null;
SpellCheckedMetadata meta = new SpellCheckedMetadata();
@@ -122,6 +112,7 @@
}
/** Test for setAll(Properties)
method. */
+ @Test
public void testSetProperties() {
String[] values = null;
SpellCheckedMetadata meta = new SpellCheckedMetadata();
@@ -149,6 +140,7 @@
}
/** Test for get(String)
method. */
+ @Test
public void testGet() {
SpellCheckedMetadata meta = new SpellCheckedMetadata();
assertNull(meta.get("a-name"));
@@ -160,6 +152,7 @@
}
/** Test for isMultiValued()
method. */
+ @Test
public void testIsMultiValued() {
SpellCheckedMetadata meta = new SpellCheckedMetadata();
assertFalse(meta.isMultiValued("key"));
@@ -170,6 +163,7 @@
}
/** Test for names
method. */
+ @Test
public void testNames() {
String[] names = null;
SpellCheckedMetadata meta = new SpellCheckedMetadata();
@@ -186,6 +180,7 @@
}
/** Test for remove(String)
method. */
+ @Test
public void testRemove() {
SpellCheckedMetadata meta = new SpellCheckedMetadata();
meta.remove("name-one");
@@ -207,6 +202,7 @@
}
/** Test for equals(Object)
method. */
+ @Test
public void testObject() {
SpellCheckedMetadata meta1 = new SpellCheckedMetadata();
SpellCheckedMetadata meta2 = new SpellCheckedMetadata();
@@ -232,6 +228,7 @@
}
/** Test for Writable
implementation. */
+ @Test
public void testWritable() {
SpellCheckedMetadata result = null;
SpellCheckedMetadata meta = new SpellCheckedMetadata();
@@ -259,6 +256,7 @@
* IO Test method, usable only when you plan to do changes in metadata
* to measure relative performance impact.
*/
+ @Test
public final void testHandlingSpeed() {
SpellCheckedMetadata result;
long start = System.currentTimeMillis();
Index: src/test/org/apache/nutch/metadata/TestMetadata.java
===================================================================
--- src/test/org/apache/nutch/metadata/TestMetadata.java (revision 1484186)
+++ src/test/org/apache/nutch/metadata/TestMetadata.java (working copy)
@@ -22,30 +22,16 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Properties;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* JUnit based tests of class {@link org.apache.nutch.metadata.Metadata}.
*/
-public class TestMetadata extends TestCase {
+public class TestMetadata {
private static final String CONTENTTYPE = "contenttype";
- public TestMetadata(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestMetadata.class);
- }
-
- public static void main(String[] args) {
- TestRunner.run(suite());
- }
-
/**
* Test to ensure that only non-null values get written when the
* {@link Metadata} object is written using a Writeable.
@@ -53,6 +39,7 @@
* @since NUTCH-406
*
*/
+ @Test
public void testWriteNonNull() {
Metadata met = new Metadata();
met.add(CONTENTTYPE, null);
@@ -83,6 +70,7 @@
}
/** Test for the add(String, String)
method. */
+ @Test
public void testAdd() {
String[] values = null;
Metadata meta = new Metadata();
@@ -112,6 +100,7 @@
}
/** Test for the set(String, String)
method. */
+ @Test
public void testSet() {
String[] values = null;
Metadata meta = new Metadata();
@@ -138,6 +127,7 @@
}
/** Test for setAll(Properties)
method. */
+ @Test
public void testSetProperties() {
String[] values = null;
Metadata meta = new Metadata();
@@ -165,6 +155,7 @@
}
/** Test for get(String)
method. */
+ @Test
public void testGet() {
Metadata meta = new Metadata();
assertNull(meta.get("a-name"));
@@ -175,6 +166,7 @@
}
/** Test for isMultiValued()
method. */
+ @Test
public void testIsMultiValued() {
Metadata meta = new Metadata();
assertFalse(meta.isMultiValued("key"));
@@ -185,6 +177,7 @@
}
/** Test for names
method. */
+ @Test
public void testNames() {
String[] names = null;
Metadata meta = new Metadata();
@@ -201,6 +194,7 @@
}
/** Test for remove(String)
method. */
+ @Test
public void testRemove() {
Metadata meta = new Metadata();
meta.remove("name-one");
@@ -222,6 +216,7 @@
}
/** Test for equals(Object)
method. */
+ @Test
public void testObject() {
Metadata meta1 = new Metadata();
Metadata meta2 = new Metadata();
@@ -247,6 +242,7 @@
}
/** Test for Writable
implementation. */
+ @Test
public void testWritable() {
Metadata result = null;
Metadata meta = new Metadata();
Index: src/test/org/apache/nutch/protocol/TestProtocolFactory.java
===================================================================
--- src/test/org/apache/nutch/protocol/TestProtocolFactory.java (revision 1484186)
+++ src/test/org/apache/nutch/protocol/TestProtocolFactory.java (working copy)
@@ -20,20 +20,24 @@
import org.apache.nutch.util.NutchConfiguration;
import org.apache.nutch.util.ObjectCache;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class TestProtocolFactory extends TestCase {
+public class TestProtocolFactory {
Configuration conf;
ProtocolFactory factory;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
conf = NutchConfiguration.create();
conf.set("plugin.includes", ".*");
conf.set("http.agent.name", "test-bot");
factory=new ProtocolFactory(conf);
}
+ @Test
public void testGetProtocol(){
//non existing protocol
@@ -69,6 +73,7 @@
}
}
+ @Test
public void testContains(){
assertTrue(factory.contains("http", "http"));
assertTrue(factory.contains("http", "http,ftp"));
Index: src/test/org/apache/nutch/protocol/TestContent.java
===================================================================
--- src/test/org/apache/nutch/protocol/TestContent.java (revision 1484186)
+++ src/test/org/apache/nutch/protocol/TestContent.java (working copy)
@@ -24,17 +24,17 @@
import org.apache.nutch.util.WritableTestUtils;
import org.apache.tika.mime.MimeTypes;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/** Unit tests for Content. */
-public class TestContent extends TestCase {
+public class TestContent {
private static Configuration conf = NutchConfiguration.create();
- public TestContent(String name) { super(name); }
-
+ @Test
public void testContent() throws Exception {
String page = "The Quick Brown Fox Jumped Over the Lazy Fox.";
@@ -55,6 +55,7 @@
}
/** Unit tests for getContentType(String, String, byte[]) method. */
+ @Test
public void testGetContentType() throws Exception {
Content c = null;
Metadata p = new Metadata();
Index: src/test/org/apache/nutch/storage/TestGoraStorage.java
===================================================================
--- src/test/org/apache/nutch/storage/TestGoraStorage.java (revision 1484186)
+++ src/test/org/apache/nutch/storage/TestGoraStorage.java (working copy)
@@ -35,16 +35,34 @@
import org.apache.nutch.util.CrawlTestUtil;
import org.hsqldb.Server;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
/**
* Tests basic Gora functionality by writing and reading webpages.
*/
public class TestGoraStorage extends AbstractNutchTest {
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
/**
* Sequentially read and write pages to a store.
*
* @throws Exception
*/
+ @Test
public void testSinglethreaded() throws Exception {
String id = "singlethread";
readWrite(id, webPageStore);
@@ -87,6 +105,7 @@
*
* @throws Exception
*/
+ @Test
public void testMultithreaded() throws Exception {
// create a fixed thread pool
int numThreads = 8;
@@ -127,6 +146,7 @@
*
* @throws Exception
*/
+ @Test
public void testMultiProcess() throws Exception {
// create and start a hsql server, a stand-alone (memory backed) db
// (important: a stand-alone server should be used because simple
Index: src/test/org/apache/nutch/net/TestURLNormalizers.java
===================================================================
--- src/test/org/apache/nutch/net/TestURLNormalizers.java (revision 1484186)
+++ src/test/org/apache/nutch/net/TestURLNormalizers.java (working copy)
@@ -21,10 +21,12 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.nutch.util.NutchConfiguration;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class TestURLNormalizers extends TestCase {
+public class TestURLNormalizers {
+ @Test
public void testURLNormalizers() {
Configuration conf = NutchConfiguration.create();
String clazz1 = "org.apache.nutch.net.urlnormalizer.regex.RegexURLNormalizer";
Index: src/test/org/apache/nutch/net/TestURLFilters.java
===================================================================
--- src/test/org/apache/nutch/net/TestURLFilters.java (revision 1484186)
+++ src/test/org/apache/nutch/net/TestURLFilters.java (working copy)
@@ -19,14 +19,16 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.nutch.util.NutchConfiguration;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class TestURLFilters extends TestCase {
+public class TestURLFilters {
/**
* Testcase for NUTCH-325.
* @throws URLFilterException
*/
+ @Test
public void testNonExistingUrlFilter() throws URLFilterException {
Configuration conf = NutchConfiguration.create();
String class1 = "NonExistingFilter";
@@ -34,7 +36,12 @@
conf.set(URLFilters.URLFILTER_ORDER, class1 + " " + class2);
URLFilters normalizers = new URLFilters(conf);
- normalizers.filter("http://someurl/");
+ assertNotNull(normalizers);
+ try {
+ normalizers.filter("http://someurl/");
+ } catch (URLFilterException ufe) {
+ fail(ufe.toString());
+ }
}
}
Index: src/test/org/apache/nutch/crawl/TestGenerator.java
===================================================================
--- src/test/org/apache/nutch/crawl/TestGenerator.java (revision 1484186)
+++ src/test/org/apache/nutch/crawl/TestGenerator.java (working copy)
@@ -28,15 +28,16 @@
import org.apache.nutch.util.AbstractNutchTest;
import org.apache.nutch.util.CrawlTestUtil;
import org.apache.nutch.util.TableUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* Basic generator test. 1. Insert entries in webtable 2. Generates entries to
* fetch 3. Verifies that number of generated urls match 4. Verifies that
* highest scoring urls are generated
*
- * @author nutch-dev getExtensions(String)
method. */
+ @Test
public void testGetExtensions() throws Exception {
Extension ext = parserFactory.getExtensions("text/html").get(0);
assertEquals("parse-tika", ext.getDescriptor().getPluginId());
@@ -58,6 +58,7 @@
}
/** Unit test to check getParsers
method */
+ @Test
public void testGetParsers() throws Exception {
Parser [] parsers = parserFactory.getParsers("text/html", "http://foo.com");
assertNotNull(parsers);
Index: src/plugin/feed/src/test/org/apache/nutch/parse/feed/TestFeedParser.java
===================================================================
--- src/plugin/feed/src/test/org/apache/nutch/parse/feed/TestFeedParser.java (revision 1484186)
+++ src/plugin/feed/src/test/org/apache/nutch/parse/feed/TestFeedParser.java (working copy)
@@ -35,8 +35,8 @@
import org.apache.nutch.protocol.ProtocolNotFound;
import org.apache.nutch.util.NutchConfiguration;
-// Junit imports
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
*
@@ -45,7 +45,7 @@
* Test Suite for the {@link FeedParser}.
*
*/
-public class TestFeedParser extends TestCase {
+public class TestFeedParser {
private String fileSeparator = System.getProperty("file.separator");
@@ -67,7 +67,6 @@
* The name of this {@link TestCase}.
*/
public TestFeedParser(String name) {
- super(name);
}
/**
@@ -85,6 +84,7 @@
* @throws ParseException
* If the {@link Parser}Layer cannot be loaded.
*/
+ @Test
public void testParseFetchChannel() throws ProtocolNotFound, ParseException {
String urlString;
Protocol protocol;
Index: src/plugin/parse-swf/src/test/org/apache/nutch/parse/swf/TestSWFParser.java
===================================================================
--- src/plugin/parse-swf/src/test/org/apache/nutch/parse/swf/TestSWFParser.java (revision 1484186)
+++ src/plugin/parse-swf/src/test/org/apache/nutch/parse/swf/TestSWFParser.java (working copy)
@@ -32,14 +32,15 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.nutch.util.NutchConfiguration;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* Unit tests for SWFParser.
*
* @author Andrzej Bialecki
*/
-public class TestSWFParser extends TestCase {
+public class TestSWFParser {
private String fileSeparator = System.getProperty("file.separator");
// This system property is defined in ./src/plugin/build-plugin.xml
@@ -47,10 +48,8 @@
private String[] sampleFiles = new String[]{"test1.swf", "test2.swf", "test3.swf"};
private String[] sampleTexts = new String[]{"test1.txt", "test2.txt", "test3.txt"};
- private String[] texts = new String[sampleTexts.length];
-
+
public TestSWFParser(String name) {
- super(name);
for (int i = 0; i < sampleFiles.length; i++) {
try {
// read the test string
@@ -74,6 +73,7 @@
protected void tearDown() {}
+ @Test
public void testIt() throws ProtocolException, ParseException {
String urlString;
Protocol protocol;
Index: src/plugin/index-more/src/test/org/apache/nutch/indexer/more/TestMoreIndexingFilter.java
===================================================================
--- src/plugin/index-more/src/test/org/apache/nutch/indexer/more/TestMoreIndexingFilter.java (revision 1484186)
+++ src/plugin/index-more/src/test/org/apache/nutch/indexer/more/TestMoreIndexingFilter.java (working copy)
@@ -18,7 +18,8 @@
import java.nio.ByteBuffer;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
import org.apache.avro.util.Utf8;
import org.apache.hadoop.conf.Configuration;
@@ -28,8 +29,9 @@
import org.apache.nutch.util.EncodingDetector;
import org.apache.nutch.util.NutchConfiguration;
-public class TestMoreIndexingFilter extends TestCase {
+public class TestMoreIndexingFilter {
+ @Test
public void testContentType() throws IndexingException {
Configuration conf = NutchConfiguration.create();
assertContentType(conf, "text/html", "text/html");
@@ -45,6 +47,7 @@
/**
* @since NUTCH-901
*/
+ @Test
public void testNoParts(){
Configuration conf = NutchConfiguration.create();
conf.setBoolean("moreIndexingFilter.indexMimeTypeParts", false);
Index: src/plugin/urlnormalizer-pass/src/test/org/apache/nutch/net/urlnormalizer/pass/TestPassURLNormalizer.java
===================================================================
--- src/plugin/urlnormalizer-pass/src/test/org/apache/nutch/net/urlnormalizer/pass/TestPassURLNormalizer.java (revision 1484186)
+++ src/plugin/urlnormalizer-pass/src/test/org/apache/nutch/net/urlnormalizer/pass/TestPassURLNormalizer.java (working copy)
@@ -23,10 +23,12 @@
import org.apache.nutch.net.URLNormalizers;
import org.apache.nutch.util.NutchConfiguration;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class TestPassURLNormalizer extends TestCase {
+public class TestPassURLNormalizer {
+ @Test
public void testPassURLNormalizer() {
Configuration conf = NutchConfiguration.create();
Index: src/plugin/parse-zip/src/test/org/apache/nutch/parse/zip/TestZipParser.java
===================================================================
--- src/plugin/parse-zip/src/test/org/apache/nutch/parse/zip/TestZipParser.java (revision 1484186)
+++ src/plugin/parse-zip/src/test/org/apache/nutch/parse/zip/TestZipParser.java (working copy)
@@ -29,15 +29,16 @@
import org.apache.nutch.util.NutchConfiguration;
import org.apache.hadoop.io.Text;
+import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
/**
* Based on Unit tests for MSWordParser by John Xing
*
* @author Rohit Kulkarni & Ashish Vaidya
*/
-public class TestZipParser extends TestCase {
+public class TestZipParser {
private String fileSeparator = System.getProperty("file.separator");
// This system property is defined in ./src/plugin/build-plugin.xml
@@ -50,13 +51,13 @@
private String expectedText = "textfile.txt This is text file number 1 ";
public TestZipParser(String name) {
- super(name);
}
protected void setUp() {}
protected void tearDown() {}
+ @Test
public void testIt() throws ProtocolException, ParseException {
String urlString;
Protocol protocol;
Index: src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestRobotsMetaProcessor.java
===================================================================
--- src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestRobotsMetaProcessor.java (revision 1484186)
+++ src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestRobotsMetaProcessor.java (working copy)
@@ -17,8 +17,6 @@
package org.apache.nutch.parse.html;
-import junit.framework.TestCase;
-
import org.apache.nutch.parse.HTMLMetaTags;
import java.io.ByteArrayInputStream;
@@ -29,11 +27,11 @@
import org.w3c.dom.*;
import org.apache.html.dom.*;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
/** Unit tests for HTMLMetaProcessor. */
-public class TestRobotsMetaProcessor extends TestCase {
- public TestRobotsMetaProcessor(String name) {
- super(name);
- }
+public class TestRobotsMetaProcessor {
/*
@@ -126,6 +124,7 @@
private URL[][] currURLsAndAnswers;
+ @Test
public void testRobotsMetaProcessor() {
DOMFragmentParser parser= new DOMFragmentParser();;
Index: src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestDOMContentUtils.java
===================================================================
--- src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestDOMContentUtils.java (revision 1484186)
+++ src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestDOMContentUtils.java (working copy)
@@ -17,8 +17,6 @@
package org.apache.nutch.parse.html;
-import junit.framework.TestCase;
-
import org.apache.nutch.parse.Outlink;
import org.apache.hadoop.conf.Configuration;
import org.apache.nutch.util.NutchConfiguration;
@@ -34,10 +32,14 @@
import org.w3c.dom.*;
import org.apache.html.dom.*;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
/**
* Unit tests for DOMContentUtils.
*/
-public class TestDOMContentUtils extends TestCase {
+public class TestDOMContentUtils {
private static final String[] testPages= {
new String("
RegexURLFilter
.
@@ -37,18 +33,6 @@
*/
public class TestRegexURLFilter extends RegexURLFilterBaseTest {
- public TestRegexURLFilter(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestRegexURLFilter.class);
- }
-
- public static void main(String[] args) {
- TestRunner.run(suite());
- }
-
protected URLFilter getURLFilter(Reader rules) {
try {
return new RegexURLFilter(rules);
@@ -58,6 +42,7 @@
}
}
+ @Test
public void test() {
test("WholeWebCrawling");
test("IntranetCrawling");
Index: src/plugin/parse-js/src/test/org/apache/nutch/parse/js/TestJSParseFilter.java
===================================================================
--- src/plugin/parse-js/src/test/org/apache/nutch/parse/js/TestJSParseFilter.java (revision 1484186)
+++ src/plugin/parse-js/src/test/org/apache/nutch/parse/js/TestJSParseFilter.java (working copy)
@@ -19,7 +19,6 @@
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -33,10 +32,10 @@
import org.apache.nutch.storage.WebPage;
import org.apache.nutch.util.MimeUtil;
import org.apache.nutch.util.NutchConfiguration;
+import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.*;
-import junit.framework.TestCase;
-
/**
* JUnit test case for {@link JSParseFilter} which tests
* 1. That 5 outlinks are extracted from JavaScript snippets embedded in HTML
@@ -45,7 +44,7 @@
* @author lewismc
*/
-public class TestJSParseFilter extends TestCase {
+public class TestJSParseFilter {
private String fileSeparator = System.getProperty("file.separator");
@@ -58,50 +57,44 @@
private Configuration conf;
- public TestJSParseFilter(String name) {
- super(name);
+ @Before
+ public void setUp() {
+ conf = NutchConfiguration.create();
+ conf.set("file.content.limit", "-1");
}
-
- protected void setUp() {
- conf = NutchConfiguration.create();
- conf.set("file.content.limit", "-1");
- }
- protected void tearDown() {
- }
-
public Outlink[] getOutlinks(String[] sampleFiles) throws ProtocolException, ParseException, IOException {
- String urlString;
- Parse parse;
+ String urlString;
+ Parse parse;
- urlString = "file:" + sampleDir + fileSeparator + sampleFiles;
- File file = new File(urlString);
- byte[] bytes = new byte[(int) file.length()];
- DataInputStream dip = new DataInputStream(new FileInputStream(file));
- dip.readFully(bytes);
- dip.close();
+ urlString = "file:" + sampleDir + fileSeparator + sampleFiles;
+ File file = new File(urlString);
+ byte[] bytes = new byte[(int) file.length()];
+ DataInputStream dip = new DataInputStream(new FileInputStream(file));
+ dip.readFully(bytes);
+ dip.close();
- WebPage page = new WebPage();
- page.setBaseUrl(new Utf8(urlString));
- page.setContent(ByteBuffer.wrap(bytes));
- MimeUtil mutil = new MimeUtil(conf);
- String mime = mutil.getMimeType(file);
- page.setContentType(new Utf8(mime));
+ WebPage page = new WebPage();
+ page.setBaseUrl(new Utf8(urlString));
+ page.setContent(ByteBuffer.wrap(bytes));
+ MimeUtil mutil = new MimeUtil(conf);
+ String mime = mutil.getMimeType(file);
+ page.setContentType(new Utf8(mime));
- parse = new ParseUtil(conf).parse(urlString, page);
- return parse.getOutlinks();
+ parse = new ParseUtil(conf).parse(urlString, page);
+ return parse.getOutlinks();
}
@Test
public void testOutlinkExtraction() throws ProtocolException, ParseException, IOException {
- String[] filenames = new File(sampleDir).list();
- for (int i = 0; i < filenames.length; i++) {
- if (filenames[i].endsWith(".js") == true) {
- assertEquals("number of outlinks in .js test file should be 5", 5, getOutlinks(sampleFiles));
- // temporarily disabled as a suitable pure JS file could not be be found.
- //} else {
- //assertEquals("number of outlinks in .html file should be X", 5, getOutlinks(sampleFiles));
- }
+ String[] filenames = new File(sampleDir).list();
+ for (int i = 0; i < filenames.length; i++) {
+ if (filenames[i].endsWith(".js") == true) {
+ assertEquals("number of outlinks in .js test file should be 5", 5, getOutlinks(sampleFiles));
+ // temporarily disabled as a suitable pure JS file could not be be found.
+ //} else {
+ //assertEquals("number of outlinks in .html file should be X", 5, getOutlinks(sampleFiles));
+ }
}
}
Index: src/plugin/creativecommons/src/test/org/creativecommons/nutch/TestCCParseFilter.java
===================================================================
--- src/plugin/creativecommons/src/test/org/creativecommons/nutch/TestCCParseFilter.java (revision 1484186)
+++ src/plugin/creativecommons/src/test/org/creativecommons/nutch/TestCCParseFilter.java (working copy)
@@ -17,29 +17,24 @@
package org.creativecommons.nutch;
-import org.apache.nutch.metadata.Metadata;
-import org.apache.nutch.parse.Parse;
import org.apache.nutch.parse.ParseUtil;
-import org.apache.nutch.protocol.Content;
import org.apache.avro.util.Utf8;
import org.apache.hadoop.conf.Configuration;
import org.apache.nutch.storage.WebPage;
import org.apache.nutch.util.MimeUtil;
import org.apache.nutch.util.NutchConfiguration;
-import org.apache.tika.mime.MimeType;
-
-import java.util.Properties;
import java.io.*;
-import java.net.URL;
import java.nio.ByteBuffer;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class TestCCParseFilter extends TestCase {
+public class TestCCParseFilter {
private static final File testDir = new File(
System.getProperty("test.input"));
+ @Test
public void testPages() throws Exception {
pageTest(new File(testDir, "anchor.html"), "http://foo.com/",
"http://creativecommons.org/licenses/by-nc-sa/1.0", "a", null);
@@ -56,7 +51,6 @@
public void pageTest(File file, String url, String license,
String location, String type) throws Exception {
- String contentType = "text/html";
InputStream in = new FileInputStream(file);
ByteArrayOutputStream out = new ByteArrayOutputStream(
(int) file.length());
Index: src/plugin/language-identifier/src/test/org/apache/nutch/analysis/lang/TestHTMLLanguageParser.java
===================================================================
--- src/plugin/language-identifier/src/test/org/apache/nutch/analysis/lang/TestHTMLLanguageParser.java (revision 1484186)
+++ src/plugin/language-identifier/src/test/org/apache/nutch/analysis/lang/TestHTMLLanguageParser.java (working copy)
@@ -21,7 +21,8 @@
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
import org.apache.avro.util.Utf8;
import org.apache.nutch.metadata.Metadata;
@@ -32,7 +33,7 @@
import org.apache.nutch.util.NutchConfiguration;
import org.apache.tika.language.LanguageIdentifier;
-public class TestHTMLLanguageParser extends TestCase {
+public class TestHTMLLanguageParser {
private static Utf8 URL = new Utf8("http://foo.bar/");
@@ -49,6 +50,7 @@
/**
* Test parsing of language identifiers from html
**/
+ @Test
public void testMetaHTMLParsing() {
try {
@@ -71,6 +73,7 @@
}
/** Test of LanguageParser.parseLanguage(String)
method. */
+ @Test
public void testParseLanguage() {
String tests[][] = { { "(SCHEME=ISO.639-1) sv", "sv" },
{ "(SCHEME=RFC1766) sv-FI", "sv" }, { "(SCHEME=Z39.53) SWE", "sv" },
@@ -98,6 +101,7 @@
}
}
+ @Test
public void testLanguageIndentifier() {
try {
long total = 0;
Index: src/plugin/subcollection/src/test/org/apache/nutch/collection/TestSubcollection.java
===================================================================
--- src/plugin/subcollection/src/test/org/apache/nutch/collection/TestSubcollection.java (revision 1484186)
+++ src/plugin/subcollection/src/test/org/apache/nutch/collection/TestSubcollection.java (working copy)
@@ -22,14 +22,16 @@
import org.apache.nutch.util.NutchConfiguration;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class TestSubcollection extends TestCase {
+public class TestSubcollection {
/**Test filtering logic
*
* @throws Exception
*/
+ @Test
public void testFilter() throws Exception {
Subcollection sc=new Subcollection(NutchConfiguration.create());
sc.setWhiteList("www.nutch.org\nwww.apache.org");
@@ -46,6 +48,7 @@
assertEquals(null, sc.filter("http://www.google.com/"));
}
+ @Test
public void testInput(){
StringBuffer xml=new StringBuffer();
xml.append("");
Index: src/plugin/parse-ext/src/test/org/apache/nutch/parse/ext/TestExtParser.java
===================================================================
--- src/plugin/parse-ext/src/test/org/apache/nutch/parse/ext/TestExtParser.java (revision 1484186)
+++ src/plugin/parse-ext/src/test/org/apache/nutch/parse/ext/TestExtParser.java (working copy)
@@ -30,7 +30,8 @@
import org.apache.hadoop.io.Text;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
import java.io.File;
import java.io.FileOutputStream;
@@ -47,7 +48,7 @@
*
* @author John Xing
*/
-public class TestExtParser extends TestCase {
+public class TestExtParser {
private File tempFile = null;
private String urlString = null;
private Content content = null;
@@ -58,7 +59,6 @@
private String expectedMD5sum = "df46711a1a48caafc98b1c3b83aa1526";
public TestExtParser(String name) {
- super(name);
}
protected void setUp() throws ProtocolException, IOException {
@@ -95,6 +95,7 @@
// tempFile.delete();
}
+ @Test
public void testIt() throws ParseException {
String contentType;
Index: src/plugin/urlfilter-suffix/src/test/org/apache/nutch/urlfilter/suffix/TestSuffixURLFilter.java
===================================================================
--- src/plugin/urlfilter-suffix/src/test/org/apache/nutch/urlfilter/suffix/TestSuffixURLFilter.java (revision 1484186)
+++ src/plugin/urlfilter-suffix/src/test/org/apache/nutch/urlfilter/suffix/TestSuffixURLFilter.java (working copy)
@@ -19,10 +19,9 @@
import java.io.IOException;
import java.io.StringReader;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
@@ -30,7 +29,7 @@
*
* @author Andrzej Bialecki
*/
-public class TestSuffixURLFilter extends TestCase {
+public class TestSuffixURLFilter {
private static final String suffixes =
"# this is a comment\n" +
"\n" +
@@ -117,22 +116,12 @@
private SuffixURLFilter filter = null;
- public TestSuffixURLFilter(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestSuffixURLFilter.class);
- }
-
- public static void main(String[] args) {
- TestRunner.run(suite());
- }
-
+ @Before
public void setUp() throws IOException {
filter = new SuffixURLFilter(new StringReader(suffixes));
}
+ @Test
public void testModeAccept() {
filter.setIgnoreCase(false);
filter.setModeAccept(true);
@@ -141,6 +130,7 @@
}
}
+ @Test
public void testModeReject() {
filter.setIgnoreCase(false);
filter.setModeAccept(false);
@@ -149,6 +139,7 @@
}
}
+ @Test
public void testModeAcceptIgnoreCase() {
filter.setIgnoreCase(true);
filter.setModeAccept(true);
@@ -157,6 +148,7 @@
}
}
+ @Test
public void testModeRejectIgnoreCase() {
filter.setIgnoreCase(true);
filter.setModeAccept(false);
@@ -165,6 +157,7 @@
}
}
+ @Test
public void testModeAcceptAndNonPathFilter() {
filter.setModeAccept(true);
filter.setFilterFromPath(false);
@@ -173,6 +166,7 @@
}
}
+ @Test
public void testModeAcceptAndPathFilter() {
filter.setModeAccept(true);
filter.setFilterFromPath(true);
Index: src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java
===================================================================
--- src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java (revision 1484186)
+++ src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java (working copy)
@@ -20,7 +20,10 @@
import java.net.MalformedURLException;
import java.net.URL;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.nutch.net.protocols.Response;
@@ -35,7 +38,7 @@
*
* @author Susam Pal
*/
-public class TestProtocolHttpClient extends TestCase {
+public class TestProtocolHttpClient {
private Server server;
private Configuration conf;
@@ -43,7 +46,8 @@
private int port;
private Http http = new Http();
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
server = new Server();
@@ -69,7 +73,8 @@
http.setConf(conf);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
server.stop();
}
@@ -79,6 +84,7 @@
* @throws Exception
* If an error occurs or the test case fails.
*/
+ @Test
public void testCookies() throws Exception {
startServer(47500);
fetchPage("/cookies.jsp", 200);
@@ -92,6 +98,7 @@
* @throws Exception
* If an error occurs or the test case fails.
*/
+ @Test
public void testNoPreemptiveAuth() throws Exception {
startServer(47500);
fetchPage("/noauth.jsp", 200);
@@ -104,6 +111,7 @@
* @throws Exception
* If an error occurs or the test case fails.
*/
+ @Test
public void testDefaultCredentials() throws Exception {
startServer(47502);
fetchPage("/basic.jsp", 200);
@@ -116,6 +124,7 @@
* @throws Exception
* If an error occurs or the test case fails.
*/
+ @Test
public void testBasicAuth() throws Exception {
startServer(47500);
fetchPage("/basic.jsp", 200);
@@ -132,6 +141,7 @@
* @throws Exception
* If an error occurs or the test case fails.
*/
+ @Test
public void testOtherRealmsNoAuth() throws Exception {
startServer(47501);
fetchPage("/basic.jsp", 200);
@@ -146,6 +156,7 @@
* @throws Exception
* If an error occurs or the test case fails.
*/
+ @Test
public void testDigestAuth() throws Exception {
startServer(47500);
fetchPage("/digest.jsp", 200);
@@ -158,6 +169,7 @@
* @throws Exception
* If an error occurs or the test case fails.
*/
+ @Test
public void testNtlmAuth() throws Exception {
startServer(47501);
fetchPage("/ntlm.jsp", 200);
Index: src/plugin/microformats-reltag/src/test/org/apache/nutch/microformats/reltag/TestRelTagIndexingFilter.java
===================================================================
--- src/plugin/microformats-reltag/src/test/org/apache/nutch/microformats/reltag/TestRelTagIndexingFilter.java (revision 1484186)
+++ src/plugin/microformats-reltag/src/test/org/apache/nutch/microformats/reltag/TestRelTagIndexingFilter.java (working copy)
@@ -24,9 +24,8 @@
import org.apache.nutch.storage.WebPage;
import org.apache.nutch.util.NutchConfiguration;
import org.junit.Test;
+import static org.junit.Assert.*;
-import junit.framework.TestCase;
-
/**
*JUnit test case for {@link RelTagIndexingFilter} which
*simply asserts that a 'tag' field is obtained by the filter.
@@ -34,7 +33,7 @@
*@author lewismc
*/
- public class TestRelTagIndexingFilter extends TestCase {
+ public class TestRelTagIndexingFilter {
@Test
public void testRelTagFields() throws Exception {
Index: src/plugin/microformats-reltag/src/test/org/apache/nutch/microformats/reltag/TestRelTagParser.java
===================================================================
--- src/plugin/microformats-reltag/src/test/org/apache/nutch/microformats/reltag/TestRelTagParser.java (revision 1484186)
+++ src/plugin/microformats-reltag/src/test/org/apache/nutch/microformats/reltag/TestRelTagParser.java (working copy)
@@ -24,15 +24,13 @@
import org.apache.avro.util.Utf8;
import org.apache.hadoop.conf.Configuration;
-import org.apache.nutch.parse.Parse;
import org.apache.nutch.parse.ParseException;
-import org.apache.nutch.parse.ParseUtil;
import org.apache.nutch.protocol.ProtocolException;
import org.apache.nutch.storage.WebPage;
import org.apache.nutch.util.MimeUtil;
import org.apache.nutch.util.NutchConfiguration;
import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
/**
* Junit test for {@link RelTagParser} based mainly John Xing's parser tests.
@@ -45,7 +43,7 @@
* @author lewismc
*
*/
-public class TestRelTagParser extends TestCase {
+public class TestRelTagParser {
private String fileSeparator = System.getProperty("file.separator");
@@ -62,14 +60,12 @@
private Configuration conf;
public TestRelTagParser(String name) {
- super(name);
}
@Test
public void testRelTagParser() throws ProtocolException, ParseException, IOException {
conf = NutchConfiguration.create();
conf.set("file.content.limit", "-1");
- Parse parse;
String urlString = "file:" + sampleDir + fileSeparator + sampleFile;
File file = new File(sampleDir + fileSeparator + sampleFile);
@@ -84,8 +80,6 @@
MimeUtil mimeutil = new MimeUtil(conf);
String mtype = mimeutil.getMimeType(file);
page.setContentType(new Utf8(mtype));
- parse = new ParseUtil(conf).parse(urlString, page);
-
//begin assertion for tests
ByteBuffer bbuf = page.getFromMetadata(new Utf8("Rel-Tag"));
byte[] byteArray = new byte[bbuf.remaining()];
Index: src/plugin/lib-http/src/test/org/apache/nutch/protocol/http/api/TestRobotRulesParser.java
===================================================================
--- src/plugin/lib-http/src/test/org/apache/nutch/protocol/http/api/TestRobotRulesParser.java (revision 1484186)
+++ src/plugin/lib-http/src/test/org/apache/nutch/protocol/http/api/TestRobotRulesParser.java (working copy)
@@ -17,16 +17,19 @@
package org.apache.nutch.protocol.http.api;
+import org.junit.Test;
+
import crawlercommons.robots.BaseRobotRules;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
/**
* JUnit test case which tests
* 1. that robots filtering is performed correctly as per the agent name
* 2. that crawl delay is extracted correctly from the robots file
*
*/
-public class TestRobotRulesParser extends TestCase {
+public class TestRobotRulesParser {
private static final String CONTENT_TYPE = "text/plain";
private static final String SINGLE_AGENT = "Agent1";
@@ -73,13 +76,13 @@
private BaseRobotRules rules;
public TestRobotRulesParser(String name) {
- super(name);
parser = new HttpRobotRulesParser();
}
/**
* Test that the robots rules are interpreted correctly by the robots rules parser.
*/
+ @Test
public void testRobotsAgent() {
rules = parser.parseRules("testRobotsAgent", ROBOTS_STRING.getBytes(), CONTENT_TYPE, SINGLE_AGENT);
@@ -104,6 +107,7 @@
* Test that the crawl delay is extracted from the robots file for respective agent.
* If its not specified for a given agent, default value must be returned.
*/
+ @Test
public void testCrawlDelay() {
// for SINGLE_AGENT, the crawl delay of 10 sec ie. 10000 msec must be returned by the parser
rules = parser.parseRules("testCrawlDelay", ROBOTS_STRING.getBytes(), CONTENT_TYPE, SINGLE_AGENT);
Index: src/plugin/urlnormalizer-basic/src/test/org/apache/nutch/net/urlnormalizer/basic/TestBasicURLNormalizer.java
===================================================================
--- src/plugin/urlnormalizer-basic/src/test/org/apache/nutch/net/urlnormalizer/basic/TestBasicURLNormalizer.java (revision 1484186)
+++ src/plugin/urlnormalizer-basic/src/test/org/apache/nutch/net/urlnormalizer/basic/TestBasicURLNormalizer.java (working copy)
@@ -21,20 +21,21 @@
import org.apache.nutch.net.URLNormalizers;
import org.apache.nutch.util.NutchConfiguration;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/** Unit tests for BasicURLNormalizer. */
-public class TestBasicURLNormalizer extends TestCase {
+public class TestBasicURLNormalizer {
private BasicURLNormalizer normalizer;
private Configuration conf;
public TestBasicURLNormalizer(String name) {
- super(name);
normalizer = new BasicURLNormalizer();
conf = NutchConfiguration.create();
normalizer.setConf(conf);
}
+ @Test
public void testNormalizer() throws Exception {
// check that leading and trailing spaces are removed
normalizeTest(" http://foo.com/ ", "http://foo.com/");
Index: src/plugin/index-basic/src/test/org/apache/nutch/indexer/basic/TestBasicIndexingFilter.java
===================================================================
--- src/plugin/index-basic/src/test/org/apache/nutch/indexer/basic/TestBasicIndexingFilter.java (revision 1484186)
+++ src/plugin/index-basic/src/test/org/apache/nutch/indexer/basic/TestBasicIndexingFilter.java (working copy)
@@ -20,13 +20,12 @@
import org.apache.avro.util.Utf8;
import org.apache.hadoop.conf.Configuration;
-import org.apache.nutch.fetcher.FetcherJob;
import org.apache.nutch.indexer.NutchDocument;
import org.apache.nutch.metadata.Nutch;
import org.apache.nutch.storage.WebPage;
import org.apache.nutch.util.NutchConfiguration;
import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
/**
* JUnit test case which tests
@@ -39,7 +38,7 @@
* @author lewismc
*/
-public class TestBasicIndexingFilter extends TestCase {
+public class TestBasicIndexingFilter {
@Test
public void testBasicFields() throws Exception {
Index: src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestOOParser.java
===================================================================
--- src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestOOParser.java (revision 1484186)
+++ src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestOOParser.java (working copy)
@@ -24,7 +24,8 @@
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
import org.apache.avro.util.Utf8;
import org.apache.hadoop.conf.Configuration;
@@ -35,92 +36,83 @@
import org.apache.nutch.storage.WebPage;
import org.apache.nutch.util.MimeUtil;
import org.apache.nutch.util.NutchConfiguration;
-import org.apache.tika.mime.MimeType;
/**
* Unit tests for OOParser.
*
* @author Andrzej Bialecki
*/
-public class TestOOParser extends TestCase {
+public class TestOOParser {
- private String fileSeparator = System.getProperty("file.separator");
- // This system property is defined in ./src/plugin/build-plugin.xml
- private String sampleDir = System.getProperty("test.data", ".");
- // Make sure sample files are copied to "test.data" as specified in
- // ./src/plugin/parse-oo/build.xml during plugin compilation.
- private String[] sampleFiles = { "ootest.odt", "ootest.sxw" };
+ private String fileSeparator = System.getProperty("file.separator");
+ // This system property is defined in ./src/plugin/build-plugin.xml
+ private String sampleDir = System.getProperty("test.data", ".");
+ // Make sure sample files are copied to "test.data" as specified in
+ // ./src/plugin/parse-oo/build.xml during plugin compilation.
+ private String[] sampleFiles = { "ootest.odt", "ootest.sxw" };
- private String sampleText = "ootest.txt";
+ private String sampleText = "ootest.txt";
- private String expectedText;
+ private String expectedText;
- public TestOOParser(String name) {
- super(name);
- try {
- // read the test string
- FileInputStream fis = new FileInputStream(sampleDir + fileSeparator
- + sampleText);
- StringBuffer sb = new StringBuffer();
- int len = 0;
- InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
- char[] buf = new char[1024];
- while ((len = isr.read(buf)) > 0) {
- sb.append(buf, 0, len);
- }
- isr.close();
- expectedText = sb.toString();
- // normalize space
- expectedText = expectedText.replaceAll("[ \t\r\n]+", " ");
- } catch (Exception e) {
- e.printStackTrace();
- }
+ @Test
+ public void testIt() throws ProtocolException, ParseException, IOException {
+ String urlString;
+ Parse parse;
+ Configuration conf = NutchConfiguration.create();
+ MimeUtil mimeutil = new MimeUtil(conf);
+
+ try {
+ // read the test string
+ FileInputStream fis = new FileInputStream(sampleDir + fileSeparator
+ + sampleText);
+ StringBuffer sb = new StringBuffer();
+ int len = 0;
+ InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
+ char[] buf = new char[1024];
+ while ((len = isr.read(buf)) > 0) {
+ sb.append(buf, 0, len);
+ }
+ isr.close();
+ expectedText = sb.toString();
+ // normalize space
+ expectedText = expectedText.replaceAll("[ \t\r\n]+", " ");
+ } catch (Exception e) {
+ e.printStackTrace();
}
- protected void setUp() {
- }
+ System.out.println("Expected : " + expectedText);
- protected void tearDown() {
- }
+ for (int i = 0; i < sampleFiles.length; i++) {
+ urlString = "file:" + sampleDir + fileSeparator + sampleFiles[i];
- public void testIt() throws ProtocolException, ParseException, IOException {
- String urlString;
- Parse parse;
- Configuration conf = NutchConfiguration.create();
- MimeUtil mimeutil = new MimeUtil(conf);
+ if (sampleFiles[i].startsWith("ootest") == false)
+ continue;
- System.out.println("Expected : " + expectedText);
+ File file = new File(sampleDir + fileSeparator + sampleFiles[i]);
+ byte[] bytes = new byte[(int) file.length()];
+ DataInputStream in = new DataInputStream(new FileInputStream(file));
+ in.readFully(bytes);
+ in.close();
- for (int i = 0; i < sampleFiles.length; i++) {
- urlString = "file:" + sampleDir + fileSeparator + sampleFiles[i];
+ WebPage page = new WebPage();
+ page.setBaseUrl(new Utf8(urlString));
+ page.setContent(ByteBuffer.wrap(bytes));
+ String mtype = mimeutil.getMimeType(file);
+ page.setContentType(new Utf8(mtype));
- if (sampleFiles[i].startsWith("ootest") == false)
- continue;
+ parse = new ParseUtil(conf).parse(urlString, page);
- File file = new File(sampleDir + fileSeparator + sampleFiles[i]);
- byte[] bytes = new byte[(int) file.length()];
- DataInputStream in = new DataInputStream(new FileInputStream(file));
- in.readFully(bytes);
- in.close();
+ String text = parse.getText().replaceAll("[ \t\r\n]+", " ").trim();
- WebPage page = new WebPage();
- page.setBaseUrl(new Utf8(urlString));
- page.setContent(ByteBuffer.wrap(bytes));
- String mtype = mimeutil.getMimeType(file);
- page.setContentType(new Utf8(mtype));
+ // simply test for the presence of a text - the ordering of the
+ // elements
+ // may differ from what was expected
+ // in the previous tests
+ assertTrue(text != null && text.length() > 0);
- parse = new ParseUtil(conf).parse(urlString, page);
-
- String text = parse.getText().replaceAll("[ \t\r\n]+", " ").trim();
-
- // simply test for the presence of a text - the ordering of the
- // elements
- // may differ from what was expected
- // in the previous tests
- assertTrue(text != null && text.length() > 0);
-
- System.out.println("Found " + sampleFiles[i] + ": " + text);
- }
+ System.out.println("Found " + sampleFiles[i] + ": " + text);
}
+ }
}
Index: src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/DOMContentUtilsTest.java
===================================================================
--- src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/DOMContentUtilsTest.java (revision 1484186)
+++ src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/DOMContentUtilsTest.java (working copy)
@@ -17,7 +17,8 @@
package org.apache.nutch.parse.tika;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
import org.apache.nutch.parse.Outlink;
import org.apache.nutch.parse.tika.DOMBuilder;
@@ -43,7 +44,7 @@
/**
* Unit tests for DOMContentUtils.
*/
-public class DOMContentUtilsTest extends TestCase {
+public class DOMContentUtilsTest {
private static final String[] testPages = {
// 0.
@@ -200,7 +201,6 @@
public static final Logger Logger = LoggerFactory.getLogger(DOMContentUtilsTest.class);
public DOMContentUtilsTest(String name) {
- super(name);
}
private static void setup() throws Exception {
@@ -317,6 +317,7 @@
return true;
}
+ @Test
public void testGetText() throws Exception {
if (testDOMs[0] == null)
setup();
@@ -335,6 +336,7 @@
// won't work with Tika - the title is stored in the metadata but
// not put in the XHTML representation
+ @Test
public void testGetTitle() throws Exception {
if (testDOMs[0] == null)
setup();
@@ -351,6 +353,7 @@
}
}
+ @Test
public void testGetOutlinks() throws Exception {
if (testDOMs[0] == null)
setup();
Index: src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestRSSParser.java
===================================================================
--- src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestRSSParser.java (revision 1484186)
+++ src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestRSSParser.java (working copy)
@@ -23,9 +23,6 @@
import java.io.IOException;
import java.nio.ByteBuffer;
-import org.apache.nutch.protocol.ProtocolFactory;
-import org.apache.nutch.protocol.Protocol;
-import org.apache.nutch.protocol.Content;
import org.apache.nutch.protocol.ProtocolException;
import org.apache.nutch.parse.Parse;
@@ -38,17 +35,16 @@
import org.apache.nutch.util.MimeUtil;
import org.apache.nutch.util.NutchConfiguration;
-import org.apache.tika.mime.MimeType;
+import org.junit.Test;
+import static org.junit.Assert.*;
-import junit.framework.TestCase;
-
/**
* Unit tests for the RSS Parser based on John Xing's TestPdfParser class.
*
* @author mattmann
* @version 1.0
*/
-public class TestRSSParser extends TestCase {
+public class TestRSSParser {
private String fileSeparator = System.getProperty("file.separator");
@@ -62,18 +58,6 @@
/**
* - * Default constructor - *
- * - * @param name - * The name of the RSSParserTest - */ - public TestRSSParser(String name) { - super(name); - } - - /** - ** The test method: tests out the following 2 asserts: *
* @@ -83,9 +67,9 @@ * file * */ + @Test public void testIt()throws ProtocolException, ParseException, IOException { String urlString; - Protocol protocol; Parse parse; Configuration conf = NutchConfiguration.create(); Index: src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestPdfParser.java =================================================================== --- src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestPdfParser.java (revision 1484186) +++ src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestPdfParser.java (working copy) @@ -23,7 +23,8 @@ import java.io.IOException; import java.nio.ByteBuffer; -import junit.framework.TestCase; +import org.junit.Test; +import static org.junit.Assert.*; import org.apache.avro.util.Utf8; import org.apache.hadoop.conf.Configuration; @@ -34,14 +35,13 @@ import org.apache.nutch.storage.WebPage; import org.apache.nutch.util.MimeUtil; import org.apache.nutch.util.NutchConfiguration; -import org.apache.tika.mime.MimeType; /** * Unit tests for PdfParser. * * @author John Xing */ -public class TestPdfParser extends TestCase { +public class TestPdfParser { private String fileSeparator = System.getProperty("file.separator"); // This system property is defined in ./src/plugin/build-plugin.xml @@ -53,16 +53,7 @@ private String expectedText = "A VERY SMALL PDF FILE"; - public TestPdfParser(String name) { - super(name); - } - - protected void setUp() { - } - - protected void tearDown() { - } - + @Test public void testIt() throws ProtocolException, ParseException, IOException { String urlString; Parse parse; Index: src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestMSWordParser.java =================================================================== --- src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestMSWordParser.java (revision 1484186) +++ src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestMSWordParser.java (working copy) @@ -23,7 +23,9 @@ import java.io.IOException; import java.nio.ByteBuffer; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; import org.apache.avro.util.Utf8; import org.apache.hadoop.conf.Configuration; @@ -34,14 +36,13 @@ import org.apache.nutch.storage.WebPage; import org.apache.nutch.util.MimeUtil; import org.apache.nutch.util.NutchConfiguration; -import org.apache.tika.mime.MimeType; /** * Unit tests for MSWordParser. * * @author John Xing */ -public class TestMSWordParser extends TestCase { +public class TestMSWordParser { private String fileSeparator = System.getProperty("file.separator"); // This system property is defined in ./src/plugin/build-plugin.xml @@ -55,18 +56,12 @@ private Configuration conf; - public TestMSWordParser(String name) { - super(name); - } - - protected void setUp() { + @Before + public void setUp() { conf = NutchConfiguration.create(); conf.set("file.content.limit", "-1"); } - protected void tearDown() { - } - public String getTextContent(String fileName) throws ProtocolException, ParseException, IOException { String urlString = sampleDir + fileSeparator + fileName; @@ -89,6 +84,7 @@ return parse.getText(); } + @Test public void testIt() throws ProtocolException, ParseException, IOException { for (int i = 0; i < sampleFiles.length; i++) { String found = getTextContent(sampleFiles[i]); @@ -97,6 +93,7 @@ } } + @Test public void testOpeningDocs() throws ProtocolException, ParseException, IOException { String[] filenames = new File(sampleDir).list(); for (int i = 0; i < filenames.length; i++) { Index: src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestRTFParser.java =================================================================== --- src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestRTFParser.java (revision 1484186) +++ src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestRTFParser.java (working copy) @@ -23,7 +23,8 @@ import java.io.IOException; import java.nio.ByteBuffer; -import junit.framework.TestCase; +import org.junit.Test; +import static org.junit.Assert.*; import org.apache.avro.util.Utf8; import org.apache.hadoop.conf.Configuration; @@ -34,14 +35,13 @@ import org.apache.nutch.storage.WebPage; import org.apache.nutch.util.MimeUtil; import org.apache.nutch.util.NutchConfiguration; -import org.apache.tika.mime.MimeType; /** * Unit tests for TestRTFParser. (Adapted from John Xing msword unit tests). * * @author Andy Hedges */ -public class TestRTFParser extends TestCase { +public class TestRTFParser { private String fileSeparator = System.getProperty("file.separator"); // This system property is defined in ./src/plugin/build-plugin.xml @@ -51,16 +51,7 @@ // Check ./src/plugin/parse-rtf/sample/README.txt for what they are. private String rtfFile = "test.rtf"; - public TestRTFParser(String name) { - super(name); - } - - protected void setUp() { - } - - protected void tearDown() { - } - + @Test public void testIt() throws ProtocolException, ParseException, IOException { String urlString; Index: src/plugin/lib-regex-filter/src/test/org/apache/nutch/urlfilter/api/RegexURLFilterBaseTest.java =================================================================== --- src/plugin/lib-regex-filter/src/test/org/apache/nutch/urlfilter/api/RegexURLFilterBaseTest.java (revision 1484186) +++ src/plugin/lib-regex-filter/src/test/org/apache/nutch/urlfilter/api/RegexURLFilterBaseTest.java (working copy) @@ -24,23 +24,31 @@ import java.util.ArrayList; import java.util.List; -// JUnit imports -import junit.framework.TestCase; +import static org.junit.Assert.*; -// Commons Logging imports +// Logging imports import org.slf4j.Logger; import org.slf4j.LoggerFactory; // Nutch imports import org.apache.nutch.net.URLFilter; +import org.apache.nutch.urlfilter.automaton.TestAutomatonURLFilter; +import org.apache.nutch.urlfilter.domain.TestDomainURLFilter; +import org.apache.nutch.urlfilter.regex.TestRegexURLFilter; +import org.junit.runners.Suite; +import org.junit.runner.RunWith; /** * JUnit based test of classRegexURLFilterBase
.
*
* @author Jérôme Charron
*/
-public abstract class RegexURLFilterBaseTest extends TestCase {
+
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({TestAutomatonURLFilter.class, TestDomainURLFilter.class, TestRegexURLFilter.class})
+public abstract class RegexURLFilterBaseTest {
/** My logger */
protected static final Logger LOG = LoggerFactory.getLogger(RegexURLFilterBaseTest.class);
@@ -48,10 +56,6 @@
private final static String SEPARATOR = System.getProperty("file.separator");
private final static String SAMPLES = System.getProperty("test.data", ".");
- public RegexURLFilterBaseTest(String testName) {
- super(testName);
- }
-
protected abstract URLFilter getURLFilter(Reader rules);
protected void bench(int loops, String file) {