diff --git a/pom.xml b/pom.xml index adc1949..54ada82 100644 --- a/pom.xml +++ b/pom.xml @@ -129,13 +129,11 @@ org.junit.jupiter junit-jupiter-engine - ${junit5.version} test - org.junit.vintage - junit-vintage-engine - ${junit5.version} + org.junit.jupiter + junit-jupiter-params test diff --git a/src/test/java/org/codehaus/mojo/tidy/task/PomTidyFixesTest.java b/src/test/java/org/codehaus/mojo/tidy/task/PomTidyFixesTest.java index dcd9dab..9551c01 100644 --- a/src/test/java/org/codehaus/mojo/tidy/task/PomTidyFixesTest.java +++ b/src/test/java/org/codehaus/mojo/tidy/task/PomTidyFixesTest.java @@ -19,33 +19,22 @@ * under the License. */ +import java.util.Objects; + import org.codehaus.plexus.util.IOUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; -import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.assertEquals; -@RunWith(Parameterized.class) public class PomTidyFixesTest { protected static final String PATH = "fixes/order-and-indent-start-element-of-scope/"; - @Parameters(name = "{0}") - public static Iterable tests() { - return asList("property-ending-with-plugin.pom.xml", "property-ending-with-dependency.pom.xml"); - } - - @SuppressWarnings("checkstyle:VisibilityModifier") - @Parameter(0) - public String name; - - @Test - public void shouldThrowNoError() throws Exception { - final String pom = IOUtil.toString(getClass().getResourceAsStream(PATH + name)); + @ValueSource(strings = {"property-ending-with-plugin.pom.xml", "property-ending-with-dependency.pom.xml"}) + @ParameterizedTest(name = "{0}") + void shouldThrowNoError(String name) throws Exception { + String pom = IOUtil.toString(Objects.requireNonNull(getClass().getResourceAsStream(PATH + name))); String tidyPom = new PomTidy().tidy(pom); assertEquals(pom, tidyPom, "nothing to tidy here"); } diff --git a/src/test/java/org/codehaus/mojo/tidy/task/PomTidyTest.java b/src/test/java/org/codehaus/mojo/tidy/task/PomTidyTest.java index caac710..72e4ea7 100644 --- a/src/test/java/org/codehaus/mojo/tidy/task/PomTidyTest.java +++ b/src/test/java/org/codehaus/mojo/tidy/task/PomTidyTest.java @@ -19,24 +19,22 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import java.io.IOException; import java.io.InputStream; import org.codehaus.plexus.util.IOUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; -import static java.util.Arrays.asList; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -@RunWith(Parameterized.class) public class PomTidyTest { - @Parameters(name = "{0}") - public static Iterable tests() { - return asList( + + @ParameterizedTest(name = "{0}") + @ValueSource( + strings = { "add-xml-declaration", "complete-pom", "do-not-mix-tab-and-spaces", @@ -49,22 +47,16 @@ public static Iterable tests() { "pom-with-line-without-indent", "pom-with-profiles", "pom-with-reporting", - "project-single-line"); - } - - @SuppressWarnings("checkstyle:VisibilityModifier") - @Parameter(0) - public String name; - - @Test - public void generatesTidyPom() throws Exception { - String pom = readPom("pom.xml"); + "project-single-line" + }) + void generatesTidyPom(String name) throws IOException, XMLStreamException { + String pom = readPom(name, "pom.xml"); String tidyPom = new PomTidy().tidy(pom); - assertEquals(readPom("pom-expected.xml"), tidyPom); + assertEquals(readPom(name, "pom-expected.xml"), tidyPom); } - private String readPom(String filename) throws IOException { - InputStream is = getClass().getResourceAsStream(name + "/" + filename); + private String readPom(String test, String filename) throws IOException { + InputStream is = getClass().getResourceAsStream(test + "/" + filename); return IOUtil.toString(is); } }