diff --git a/maven-jxr-plugin/pom.xml b/maven-jxr-plugin/pom.xml index a934ec90..de77483c 100644 --- a/maven-jxr-plugin/pom.xml +++ b/maven-jxr-plugin/pom.xml @@ -161,8 +161,19 @@ under the License. test - junit - junit + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.vintage + junit-vintage-engine + test + + + + org.slf4j + slf4j-simple test @@ -209,7 +220,7 @@ under the License. true - junit:junit:*,org.apache.maven:maven-compat:*,org.apache.maven.resolver:maven-resolver-connector-basic:*,org.apache.maven.resolver:maven-resolver-transport-wagon:*,org.apache.maven.wagon:wagon-http-lightweight:* + org.apache.maven:maven-compat:*,org.apache.maven.resolver:maven-resolver-connector-basic:*,org.apache.maven.resolver:maven-resolver-transport-wagon:*,org.apache.maven.wagon:wagon-http-lightweight:*,org.junit.vintage:*,org.slf4j:slf4j-simple diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/AbstractJxrTestCase.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/AbstractJxrTestCase.java index d249460c..c7a7c6a6 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/AbstractJxrTestCase.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/AbstractJxrTestCase.java @@ -39,6 +39,10 @@ import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Abstract class to test reports generation. @@ -51,8 +55,8 @@ public abstract class AbstractJxrTestCase extends AbstractMojoTestCase { */ private MavenProject testMavenProject; - @Override - protected void setUp() throws Exception { + @BeforeEach + public void setUp() throws Exception { // required for mojo lookups to work super.setUp(); @@ -60,8 +64,8 @@ protected void setUp() throws Exception { artifactStubFactory.getWorkingDir().mkdirs(); } - @Override - protected void tearDown() throws Exception { + @AfterEach + public void tearDown() throws Exception { super.tearDown(); } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrReportTest.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrReportTest.java index 268328d1..b7aa189d 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrReportTest.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrReportTest.java @@ -24,18 +24,23 @@ import java.util.Locale; import org.codehaus.plexus.util.FileUtils; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Maria Odea Ching * @author Dennis Lundberg */ -public class JxrReportTest extends AbstractJxrTestCase { +class JxrReportTest extends AbstractJxrTestCase { /** * Test the plugin with original configuration - * - * @throws Exception */ - public void testDefaultConfiguration() throws Exception { + @Test + void defaultConfiguration() throws Exception { File resourcesDir = new File(getBasedir(), "src/test/resources/unit/default-configuration"); File outputDir = new File(getBasedir(), "target/test/unit/default-configuration/target/site"); @@ -69,10 +74,9 @@ public void testDefaultConfiguration() throws Exception { /** * Test the plugin with jdk-4 configuration - * - * @throws Exception */ - public void testJdk4Configuration() throws Exception { + @Test + void jdk4Configuration() throws Exception { File resourcesDir = new File(getBasedir(), "src/test/resources/unit/default-configuration"); File outputDir = new File(getBasedir(), "target/test/unit/default-configuration/target/site/4"); @@ -106,10 +110,9 @@ public void testJdk4Configuration() throws Exception { /** * Test the plugin with jdk-6 configuration - * - * @throws Exception */ - public void testJdk6Configuration() throws Exception { + @Test + void jdk6Configuration() throws Exception { File resourcesDir = new File(getBasedir(), "src/test/resources/unit/default-configuration"); File outputDir = new File(getBasedir(), "target/test/unit/default-configuration/target/site/6"); @@ -143,10 +146,9 @@ public void testJdk6Configuration() throws Exception { /** * Test the plugin with jdk-7 configuration - * - * @throws Exception */ - public void testJdk7Configuration() throws Exception { + @Test + void jdk7Configuration() throws Exception { File resourcesDir = new File(getBasedir(), "src/test/resources/unit/default-configuration"); File outputDir = new File(getBasedir(), "target/test/unit/default-configuration/target/site/7"); @@ -184,10 +186,9 @@ public void testJdk7Configuration() throws Exception { /** * Test the plugin with jdk-8 configuration - * - * @throws Exception */ - public void testJdk8Configuration() throws Exception { + @Test + void jdk8Configuration() throws Exception { File resourcesDir = new File(getBasedir(), "src/test/resources/unit/default-configuration"); File outputDir = new File(getBasedir(), "target/test/unit/default-configuration/target/site/8"); @@ -221,10 +222,9 @@ public void testJdk8Configuration() throws Exception { /** * Test when javadocLink is disabled in the configuration - * - * @throws Exception */ - public void testNoJavadocLink() throws Exception { + @Test + void noJavadocLink() throws Exception { generateReport(getGoal(), "nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml"); File xrefDir = new File(getBasedir(), "target/test/unit/nojavadoclink-configuration/target/site/xref"); @@ -246,13 +246,13 @@ public void testNoJavadocLink() throws Exception { // check if there's a link to the javadoc files String str = readFile(xrefDir, "nojavadoclink/configuration/AppSample.html"); assertEquals( - str.toLowerCase(Locale.ENGLISH).indexOf("/apidocs/nojavadoclink/configuration/appsample.html\""), -1); + -1, str.toLowerCase(Locale.ENGLISH).indexOf("/apidocs/nojavadoclink/configuration/appsample.html\"")); str = readFile(xrefDir, "nojavadoclink/configuration/App.html"); - assertEquals(str.toLowerCase(Locale.ENGLISH).indexOf("/apidocs/nojavadoclink/configuration/app.html\""), -1); + assertEquals(-1, str.toLowerCase(Locale.ENGLISH).indexOf("/apidocs/nojavadoclink/configuration/app.html\"")); str = readFile(xrefDir, "nojavadoclink/configuration/sample/Sample.html"); - assertEquals(str.toLowerCase().indexOf("/apidocs/nojavadoclink/configuration/sample/sample.html\""), -1); + assertEquals(-1, str.toLowerCase().indexOf("/apidocs/nojavadoclink/configuration/sample/sample.html\"")); // check if encoding is ISO-8859-1, like specified in the plugin configuration assertTrue(str.contains("text/html; charset=ISO-8859-1")); @@ -260,10 +260,9 @@ public void testNoJavadocLink() throws Exception { /** * Method for testing plugin when aggregate parameter is set to true - * - * @throws Exception */ - public void testAggregate() throws Exception { + @Test + void aggregate() throws Exception { generateReport(getGoal(), "aggregate-test/aggregate-test-plugin-config.xml"); File xrefDir = new File(getBasedir(), "target/test/unit/aggregate-test/target/site/xref"); @@ -283,10 +282,9 @@ public void testAggregate() throws Exception { /** * Method for testing plugin when the specified javadocDir does not exist - * - * @throws Exception */ - public void testNoJavadocDir() throws Exception { + @Test + void noJavadocDir() throws Exception { generateReport(getGoal(), "nojavadocdir-test/nojavadocdir-test-plugin-config.xml"); File xrefDir = new File(getBasedir(), "target/test/unit/nojavadocdir-test/target/site/xref"); @@ -301,10 +299,9 @@ public void testNoJavadocDir() throws Exception { /** * Test the plugin with an exclude configuration. - * - * @throws Exception */ - public void testExclude() throws Exception { + @Test + void exclude() throws Exception { generateReport(getGoal(), "exclude-configuration/exclude-configuration-plugin-config.xml"); Path xrefDir = new File(getBasedir(), "target/test/unit/exclude-configuration/target/site/xref").toPath(); @@ -318,10 +315,9 @@ public void testExclude() throws Exception { /** * Test the plugin with an include configuration. - * - * @throws Exception */ - public void testInclude() throws Exception { + @Test + void include() throws Exception { generateReport(getGoal(), "include-configuration/include-configuration-plugin-config.xml"); Path xrefDir = new File(getBasedir(), "target/test/unit/include-configuration/target/site/xref").toPath(); @@ -333,7 +329,8 @@ public void testInclude() throws Exception { assertFalse(Files.exists(xrefDir.resolve("include/configuration/AppSample.html"))); } - public void testExceptions() { + @Test + void exceptions() { try { generateReport(getGoal(), "default-configuration/exception-test-plugin-config.xml"); @@ -345,10 +342,9 @@ public void testExceptions() { /** * Test the jxr for a POM project. - * - * @throws Exception */ - public void testPom() throws Exception { + @Test + void pom() throws Exception { generateReport(getGoal(), "pom-test/pom-test-plugin-config.xml"); assertFalse(new File(getBasedir(), "target/test/unit/pom-test").exists()); diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrTestReportTest.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrTestReportTest.java index 921c5823..350ab1c4 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrTestReportTest.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrTestReportTest.java @@ -20,16 +20,20 @@ import java.io.File; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * @author Maria Odea Ching */ -public class JxrTestReportTest extends AbstractJxrTestCase { +class JxrTestReportTest extends AbstractJxrTestCase { /** * Method to test when the source dir is the test source dir - * - * @throws Exception */ - public void testSourceDir() throws Exception { + @Test + void sourceDir() throws Exception { generateReport(getGoal(), "testsourcedir-test/testsourcedir-test-plugin-config.xml"); File xrefTestDir = new File(getBasedir(), "target/test/unit/testsourcedir-test/target/site/xref-test"); diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateTestMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateTestMavenProjectStub.java index 9c7e1fa5..e0bff73e 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateTestMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateTestMavenProjectStub.java @@ -19,8 +19,8 @@ package org.apache.maven.plugin.jxr.stubs; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -39,7 +39,7 @@ public AggregateTestMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) { + try (InputStream is = Files.newInputStream(new File(getBasedir() + "/" + getPOM()).toPath())) { model = pomReader.read(is); setModel(model); } catch (Exception ignored) { diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultConfigurationMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultConfigurationMavenProjectStub.java index eab947e4..894a0620 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultConfigurationMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultConfigurationMavenProjectStub.java @@ -19,8 +19,8 @@ package org.apache.maven.plugin.jxr.stubs; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -39,7 +39,7 @@ public DefaultConfigurationMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) { + try (InputStream is = Files.newInputStream(new File(getBasedir() + "/" + getPOM()).toPath())) { model = pomReader.read(is); setModel(model); } catch (Exception ignored) { diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/ExcludeConfigurationMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/ExcludeConfigurationMavenProjectStub.java index 4ce55f77..2572ee69 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/ExcludeConfigurationMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/ExcludeConfigurationMavenProjectStub.java @@ -19,8 +19,8 @@ package org.apache.maven.plugin.jxr.stubs; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -39,7 +39,7 @@ public ExcludeConfigurationMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) { + try (InputStream is = Files.newInputStream(new File(getBasedir() + "/" + getPOM()).toPath())) { model = pomReader.read(is); setModel(model); } catch (Exception ignored) { diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/IncludeConfigurationMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/IncludeConfigurationMavenProjectStub.java index 617f6fa0..4c0019b3 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/IncludeConfigurationMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/IncludeConfigurationMavenProjectStub.java @@ -19,8 +19,8 @@ package org.apache.maven.plugin.jxr.stubs; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -39,7 +39,7 @@ public IncludeConfigurationMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) { + try (InputStream is = Files.newInputStream(new File(getBasedir() + "/" + getPOM()).toPath())) { model = pomReader.read(is); setModel(model); } catch (Exception ignored) { diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocDirMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocDirMavenProjectStub.java index 8c75f11c..9d6685c1 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocDirMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocDirMavenProjectStub.java @@ -19,8 +19,8 @@ package org.apache.maven.plugin.jxr.stubs; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -33,13 +33,13 @@ * @author Maria Odea Ching */ public class NoJavadocDirMavenProjectStub extends JxrProjectStub { - private List reportPlugins; + private final List reportPlugins; public NoJavadocDirMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) { + try (InputStream is = Files.newInputStream(new File(getBasedir() + "/" + getPOM()).toPath())) { model = pomReader.read(is); setModel(model); } catch (Exception ignored) { diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocLinkConfigurationMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocLinkConfigurationMavenProjectStub.java index 8f89038b..a72cb899 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocLinkConfigurationMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocLinkConfigurationMavenProjectStub.java @@ -19,8 +19,8 @@ package org.apache.maven.plugin.jxr.stubs; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -39,7 +39,7 @@ public NoJavadocLinkConfigurationMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) { + try (InputStream is = Files.newInputStream(new File(getBasedir() + "/" + getPOM()).toPath())) { model = pomReader.read(is); setModel(model); } catch (Exception ignored) { diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/PomMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/PomMavenProjectStub.java index 6682ba30..e672b891 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/PomMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/PomMavenProjectStub.java @@ -19,8 +19,8 @@ package org.apache.maven.plugin.jxr.stubs; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -38,7 +38,7 @@ public PomMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) { + try (InputStream is = Files.newInputStream(new File(getBasedir() + "/" + getPOM()).toPath())) { model = pomReader.read(is); setModel(model); } catch (Exception ignored) { diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/TestSourceDirMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/TestSourceDirMavenProjectStub.java index 3214cafc..0517f98e 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/TestSourceDirMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/TestSourceDirMavenProjectStub.java @@ -19,8 +19,8 @@ package org.apache.maven.plugin.jxr.stubs; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -37,7 +37,7 @@ public TestSourceDirMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) { + try (InputStream is = Files.newInputStream(new File(getBasedir() + "/" + getPOM()).toPath())) { model = pomReader.read(is); setModel(model); } catch (Exception ignored) { diff --git a/maven-jxr/pom.xml b/maven-jxr/pom.xml index 5d120345..89d8187b 100644 --- a/maven-jxr/pom.xml +++ b/maven-jxr/pom.xml @@ -47,8 +47,8 @@ under the License. - junit - junit + org.junit.jupiter + junit-jupiter-api test @@ -64,7 +64,7 @@ under the License. org.apache.maven.plugins maven-checkstyle-plugin -