diff --git a/pmd-test-schema/pom.xml b/pmd-test-schema/pom.xml
index 015d10f8a1..044b0c5e2b 100644
--- a/pmd-test-schema/pom.xml
+++ b/pmd-test-schema/pom.xml
@@ -38,17 +38,14 @@
test
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
test
com.github.stefanbirkner
- system-rules
+ system-lambda
test
-
-
-
diff --git a/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java b/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java
index 6a08821766..50dde9dc41 100644
--- a/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java
+++ b/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java
@@ -4,17 +4,15 @@
package net.sourceforge.pmd.test.schema;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.io.StringReader;
-import org.hamcrest.MatcherAssert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.SystemErrRule;
+import org.junit.jupiter.api.Test;
import org.xml.sax.InputSource;
import net.sourceforge.pmd.RuleContext;
@@ -22,17 +20,15 @@ import net.sourceforge.pmd.lang.PlainTextLanguage;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.rule.AbstractRule;
+import com.github.stefanbirkner.systemlambda.SystemLambda;
+
/**
* @author Clément Fournier
*/
-public class TestSchemaParserTest {
-
- @Rule
- public final SystemErrRule errStreamCaptor = new SystemErrRule().muteForSuccessfulTests();
-
+class TestSchemaParserTest {
@Test
- public void testSchemaSimple() throws IOException {
+ void testSchemaSimple() throws IOException {
String file = "\n"
+ "\n"
+ "\n"
+ "\n";
- errStreamCaptor.enableLog();
- RuleTestCollection parsed = parseFile(file);
+ String log = SystemLambda.tapSystemErr(() -> {
+ RuleTestCollection parsed = parseFile(file);
+ assertEquals(1, parsed.getTests().size());
+ });
- assertEquals(1, parsed.getTests().size());
- MatcherAssert.assertThat(errStreamCaptor.getLog(), containsString(" 6| \n"
- + " ^^^^^^^^^^^^^^ Attribute 'regressionTest' is deprecated, use 'disabled' with inverted value\n"));
+ assertThat(log, containsString(" 6| \n"
+ + " ^^^^^^^^^^^^^^ Attribute 'regressionTest' is deprecated, use 'disabled' with inverted value\n"));
}
@Test
- public void testUnknownProperty() throws IOException {
+ void testUnknownProperty() throws Exception {
String file = "\n"
+ "\n"
+ "\n";
- errStreamCaptor.enableLog();
- assertThrows(IllegalStateException.class, () -> parseFile(file));
+ String log = SystemLambda.tapSystemErr(() -> {
+ assertThrows(IllegalStateException.class, () -> parseFile(file));
+ });
- MatcherAssert.assertThat(errStreamCaptor.getLog(), containsString(" 8| foo\n"
- + " ^^^^ Unknown property, known property names are violationSuppressRegex, violationSuppressXPath\n"));
+ assertThat(log, containsString(" 8| foo\n"
+ + " ^^^^ Unknown property, known property names are violationSuppressRegex, violationSuppressXPath\n"));
}
private RuleTestCollection parseFile(String file) throws IOException {