Skip to content
Merged
1 change: 1 addition & 0 deletions .github/workflows/master-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
java: ['11']
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4.2.2
- name: Set up JDK ${{ matrix.java }}
Expand Down
16 changes: 8 additions & 8 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,12 @@
<copy file="${test.src.dir}/crawl-tests.xml" todir="${test.build.classes}"/>
<copy file="${test.src.dir}/domain-urlfilter.txt" todir="${test.build.classes}"/>
<copy file="${test.src.dir}/filter-all.txt" todir="${test.build.classes}"/>

<junitlauncher printSummary="true" haltOnFailure="true" failureProperty="tests.failed">
<classpath refid="test.classpath"/>
<testclasses outputDir="${test.build.dir}" unless="testcase" includeEngines="junit-vintage">
<listener type="${test.junit.output.format}" sendSysOut="true" sendSysErr="true"/>
<fork dir="${basedir}">
<testclasses outputDir="${test.build.dir}" unless="testcase">
<listener type="legacy-plain" sendSysOut="true" sendSysErr="true"/>
<listener type="legacy-xml" sendSysOut="true" sendSysErr="true"/>
<fork>
<jvmarg value="-Xmx1000m"/>
<sysproperty key="test.build.data" value="${test.build.data}"/>
<sysproperty key="test.src.dir" value="${test.src.dir}"/>
Expand All @@ -502,9 +502,10 @@
<exclude name="**/${test.exclude}.class"/>
</fileset>
</testclasses>
<testclasses outputDir="${test.build.dir}" if="testcase" includeEngines="junit-vintage">
<listener type="${test.junit.output.format}" sendSysOut="true" sendSysErr="true"/>
<fork dir="${basedir}">
<testclasses outputDir="${test.build.dir}" if="testcase">
<listener type="legacy-plain" sendSysOut="true" sendSysErr="true"/>
<listener type="legacy-xml" sendSysOut="true" sendSysErr="true"/>
<fork>
<jvmarg value="-Xmx1000m"/>
<sysproperty key="test.build.data" value="${test.build.data}"/>
<sysproperty key="test.src.dir" value="${test.src.dir}"/>
Expand All @@ -516,7 +517,6 @@
</fileset>
</testclasses>
</junitlauncher>

<fail if="tests.failed">Tests failed!</fail>
</target>

Expand Down
1 change: 0 additions & 1 deletion default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ test.build.lib.dir = ${test.build.dir}/lib
test.build.data = ${test.build.dir}/data
test.build.classes = ${test.build.dir}/classes
test.build.javadoc = ${test.build.dir}/docs/api
test.junit.output.format = legacy-plain

# Proxy Host and Port to use for building JavaDoc
javadoc.proxy.host=-J-DproxyHost=
Expand Down
10 changes: 5 additions & 5 deletions ivy/ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@
<exclude org="org.gnu.inet" module="libidn" /><!-- LGPL 2.1 -->
</dependency>

<!-- Keep the JUnit 4 dependency for test compilation and runtime support. Remove once migration is complete -->
<dependency org="junit" name="junit" rev="4.13.2" conf="test->default" />
<!-- JUnit 5 Platform Launcher (required for <junitlauncher> task) -->
<dependency org="org.hamcrest" name="hamcrest" rev="3.0" conf="test->default"/>
<!-- Required for <junitlauncher> task -->
<dependency org="org.junit.platform" name="junit-platform-launcher" rev="1.13.4" conf="test->default"/>
<!-- JUnit Vintage Engine (to run existing JUnit 4 tests). Remove once migration is complete -->
<dependency org="org.junit.vintage" name="junit-vintage-engine" rev="5.13.4" conf="test->default"/>
<!-- Required for JUnit 5 (Jupiter) test execution -->
<dependency org="org.junit.jupiter" name="junit-jupiter-engine" rev="5.13.4" conf="test->default"/>
<dependency org="org.junit.jupiter" name="junit-jupiter-api" rev="5.13.4" conf="test->default"/>
<dependency org="org.apache.mrunit" name="mrunit" rev="1.1.0" conf="test->default">
<artifact name="mrunit" ns0:classifier="hadoop2" />
<exclude org="log4j" module="log4j" />
Expand Down
33 changes: 10 additions & 23 deletions src/plugin/build-plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
</fileset>
<!-- global test dependencies -->
<fileset dir="${nutch.root}/build/test/lib">
<include name="apiguardian*.jar" />
<include name="hamcrest*.jar" />
<include name="junit*.jar" />
<include name="opentest4j*.jar" />
Expand Down Expand Up @@ -208,28 +209,13 @@
<!-- ================================================================== -->
<target name="test" depends="compile-test, deploy" if="test.available">
<echo message="Testing plugin: ${name}"/>

<!--junit printsummary="yes" haltonfailure="no" fork="yes"
errorProperty="tests.failed" failureProperty="tests.failed">
<sysproperty key="test.data" value="${build.test}/data"/>
<sysproperty key="test.input" value="${root}/data"/>
<sysproperty key="javax.xml.parsers.DocumentBuilderFactory" value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
<classpath refid="test.classpath"/>
<formatter type="${test.junit.output.format}" />
<batchtest todir="${build.test}" unless="testcase">
<fileset dir="${src.test}"
includes="**/Test*.java" excludes="**/${test.exclude}.java" />
</batchtest>
<batchtest todir="${build.test}" if="testcase">
<fileset dir="${src.test}" includes="**/${testcase}.java"/>
</batchtest>
</junit-->

<junitlauncher printSummary="true" haltOnFailure="true" failureProperty="tests.failed">
<classpath refid="test.classpath"/>
<testclasses outputDir="${build.test}" unless="testcase">
<listener type="${test.junit.output.format}" sendSysOut="true" sendSysErr="true"/>
<fork dir="${basedir}">
<listener type="legacy-plain" sendSysOut="true" sendSysErr="true"/>
<listener type="legacy-xml" sendSysOut="true" sendSysErr="true"/>
<fork forkMode="perTestClass">
<jvmarg value="-Xmx1000m"/>
<sysproperty key="test.data" value="${build.test}/data"/>
<sysproperty key="test.input" value="${root}/data"/>
<sysproperty key="javax.xml.parsers.DocumentBuilderFactory" value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
Expand All @@ -240,18 +226,19 @@
</fileset>
</testclasses>
<testclasses outputDir="${build.test}" if="testcase">
<listener type="${test.junit.output.format}" sendSysOut="true" sendSysErr="true"/>
<fork dir="${basedir}">
<listener type="legacy-plain" sendSysOut="true" sendSysErr="true"/>
<listener type="legacy-xml" sendSysOut="true" sendSysErr="true"/>
<fork forkMode="perTestClass">
<jvmarg value="-Xmx1000m"/>
<sysproperty key="test.data" value="${build.test}/data"/>
<sysproperty key="test.input" value="${root}/data"/>
<sysproperty key="javax.xml.parsers.DocumentBuilderFactory" value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
</fork>
<fileset dir="${build.test}">
<fileset dir="${basedir}">
<include name="**/${testcase}.class"/>
</fileset>
</testclasses>
</junitlauncher>

<fail if="tests.failed">Tests failed!</fail>
</target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@
import org.apache.nutch.protocol.Content;
import org.apache.hadoop.conf.Configuration;
import org.apache.nutch.util.NutchConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.*;

public class TestCCParseFilter {
import static org.junit.jupiter.api.Assertions.assertEquals;

class TestCCParseFilter {

private static final File testDir = new File(System.getProperty("test.input"));

@Test
public void testPages() throws Exception {
void testPages() throws Exception {
pageTest(new File(testDir, "anchor.html"), "http://foo.com/",
"http://creativecommons.org/licenses/by-nc-sa/1.0", "a", null);
// Tika returns <a> whereas parse-html returns <rel>
Expand Down Expand Up @@ -65,8 +66,8 @@ public void pageTest(File file, String url, String license, String location,
Parse parse = new ParseUtil(conf).parse(content).get(content.getUrl());

Metadata metadata = parse.getData().getParseMeta();
Assert.assertEquals(license, metadata.get("License-Url"));
Assert.assertEquals(location, metadata.get("License-Location"));
Assert.assertEquals(type, metadata.get("Work-Type"));
assertEquals(license, metadata.get("License-Url"));
assertEquals(location, metadata.get("License-Location"));
assertEquals(type, metadata.get("Work-Type"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import java.util.Iterator;
import java.util.Map;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
Expand All @@ -35,6 +34,8 @@
import org.apache.nutch.protocol.ProtocolNotFound;
import org.apache.nutch.util.NutchConfiguration;

import static org.junit.jupiter.api.Assertions.*;

/**
*
* @author mattmann
Expand Down Expand Up @@ -86,7 +87,7 @@ public void testParseFetchChannel() throws ProtocolNotFound, ParseException {

parseResult = new ParseUtil(conf).parseByExtensionId("feed", content);

Assert.assertEquals(3, parseResult.size());
assertEquals(3, parseResult.size());

boolean hasLink1 = false, hasLink2 = false, hasLink3 = false;

Expand All @@ -102,12 +103,12 @@ public void testParseFetchChannel() throws ProtocolNotFound, ParseException {
hasLink3 = true;
}

Assert.assertNotNull(entry.getValue());
Assert.assertNotNull(entry.getValue().getData());
assertNotNull(entry.getValue());
assertNotNull(entry.getValue().getData());
}

if (!hasLink1 || !hasLink2 || !hasLink3) {
Assert.fail("Outlinks read from sample rss file are not correct!");
fail("Outlinks read from sample rss file are not correct!");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;

import org.junit.jupiter.api.Test;
import org.w3c.dom.DocumentFragment;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.cyberneko.html.parsers.DOMFragmentParser;
import org.junit.Assert;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class TestHeadingsParseFilter {
private static Configuration conf = NutchConfiguration.create();
Expand Down Expand Up @@ -59,9 +60,8 @@ public void testExtractHeadingFromNestedNodes()

parseResult = filter.filter(content, parseResult, metaTags, node);

Assert.assertEquals(
"The h1 tag must include the content of the inner span node",
"header with span element",
parseResult.get(content.getUrl()).getData().getParseMeta().get("h1"));
assertEquals("header with span element",
parseResult.get(content.getUrl()).getData().getParseMeta().get("h1"),
"The h1 tag must include the content of the inner span node");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
import org.apache.nutch.parse.ParseData;
import org.apache.nutch.parse.ParseImpl;
import org.apache.nutch.util.NutchConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
* JUnit test case which tests 1. that anchor text is obtained 2. that anchor
Expand All @@ -43,7 +44,7 @@ public void testDeduplicateAnchor() throws Exception {
conf.setBoolean("anchorIndexingFilter.deduplicate", true);
AnchorIndexingFilter filter = new AnchorIndexingFilter();
filter.setConf(conf);
Assert.assertNotNull(filter);
assertNotNull(filter);
NutchDocument doc = new NutchDocument();
ParseImpl parse = new ParseImpl("foo bar", new ParseData());
Inlinks inlinks = new Inlinks();
Expand All @@ -55,13 +56,12 @@ public void testDeduplicateAnchor() throws Exception {
new CrawlDatum(), inlinks);
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
fail(e.getMessage());
}
Assert.assertNotNull(doc);
Assert.assertTrue("test if there is an anchor at all", doc.getFieldNames()
.contains("anchor"));
Assert.assertEquals("test dedup, we expect 2", 2, doc.getField("anchor")
.getValues().size());
assertNotNull(doc);
assertTrue(doc.getFieldNames().contains("anchor"), "test if there is an anchor at all");
assertEquals(2, doc.getField("anchor").getValues().size(),
"test dedup, we expect 2");
}

}
Loading