diff --git a/docs/pages/7_0_0_release_notes.md b/docs/pages/7_0_0_release_notes.md index ba6d3a91fe..2827008896 100644 --- a/docs/pages/7_0_0_release_notes.md +++ b/docs/pages/7_0_0_release_notes.md @@ -243,9 +243,11 @@ The following previously deprecated rules have been finally removed: * ant * [#4080](https://github.com/pmd/pmd/issues/4080): \[ant] Split off Ant integration into a new submodule * core + * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command * [#4035](https://github.com/pmd/pmd/issues/4035): \[core] ConcurrentModificationException in DefaultRuleViolationFactory * cli * [#3828](https://github.com/pmd/pmd/issues/3828): \[core] Progress reporting + * [#4079](https://github.com/pmd/pmd/issues/4079): \[cli] Split off CLI implementation into a pmd-cli submodule * apex-design * [#2667](https://github.com/pmd/pmd/issues/2667): \[apex] Integrate nawforce/ApexLink to build robust Unused rule * java-bestpractices diff --git a/pmd-apex/pom.xml b/pmd-apex/pom.xml index 08f0ea8b2a..9e1d37e0be 100644 --- a/pmd-apex/pom.xml +++ b/pmd-apex/pom.xml @@ -72,11 +72,6 @@ hamcrest test - - junit - junit - test - org.junit.jupiter junit-jupiter @@ -84,7 +79,7 @@ com.github.stefanbirkner - system-rules + system-lambda test diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java index 412c4ea024..7ce83fcfcb 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java @@ -4,30 +4,30 @@ package net.sourceforge.pmd.cpd; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.IOException; import java.util.Iterator; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.apex.ApexLanguageModule; import net.sourceforge.pmd.util.IOUtil; -public class ApexCpdTest { +class ApexCpdTest { private File testdir; - @Before - public void setUp() { + @BeforeEach + void setUp() { String path = IOUtil.normalizePath("src/test/resources/net/sourceforge/pmd/cpd/issue427"); testdir = new File(path); } @Test - public void testIssue427() throws IOException { + void testIssue427() throws IOException { CPDConfiguration configuration = new CPDConfiguration(); configuration.setMinimumTileSize(10); configuration.setLanguage(LanguageFactory.createLanguage(ApexLanguageModule.TERSE_NAME)); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexTokenizerTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexTokenizerTest.java index 5e64f0082d..aeb4a51252 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexTokenizerTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexTokenizerTest.java @@ -6,13 +6,13 @@ package net.sourceforge.pmd.cpd; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest; -public class ApexTokenizerTest extends CpdTextComparisonTest { +class ApexTokenizerTest extends CpdTextComparisonTest { - public ApexTokenizerTest() { + ApexTokenizerTest() { super(".cls"); } @@ -30,12 +30,12 @@ public class ApexTokenizerTest extends CpdTextComparisonTest { @Test - public void testTokenize() { + void testTokenize() { doTest("Simple"); } @Test - public void testTokenizeCaseSensitive() { + void testTokenizeCaseSensitive() { doTest("Simple", "_caseSensitive", caseSensitive()); } @@ -43,12 +43,12 @@ public class ApexTokenizerTest extends CpdTextComparisonTest { * Comments are ignored since using ApexLexer. */ @Test - public void testTokenizeWithComments() { + void testTokenizeWithComments() { doTest("comments"); } @Test - public void testTabWidth() { + void testTabWidth() { doTest("tabWidth"); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java index d59ebf19b8..9f8dd289b3 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java @@ -4,29 +4,31 @@ package net.sourceforge.pmd.lang.apex; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.contrib.java.lang.system.SystemErrRule; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoader; -public class DefaultRulesetTest { - @Rule - public final SystemErrRule systemErrRule = new SystemErrRule().enableLog().muteForSuccessfulTests(); +import com.github.stefanbirkner.systemlambda.SystemLambda; + +class DefaultRulesetTest { @Test - public void loadDefaultRuleset() { + void loadDefaultRuleset() { RuleSet ruleset = rulesetLoader().loadFromResource("rulesets/apex/ruleset.xml"); - Assert.assertNotNull(ruleset); + assertNotNull(ruleset); } @Test - public void loadQuickstartRuleset() { - RuleSet ruleset = rulesetLoader().loadFromResource("rulesets/apex/quickstart.xml"); - Assert.assertNotNull(ruleset); - Assert.assertTrue("No Logging expected", systemErrRule.getLog().isEmpty()); + void loadQuickstartRuleset() throws Exception { + String log = SystemLambda.tapSystemErr(() -> { + RuleSet ruleset = rulesetLoader().loadFromResource("rulesets/apex/quickstart.xml"); + assertNotNull(ruleset); + }); + assertTrue(log.isEmpty(), "No Logging expected"); } private RuleSetLoader rulesetLoader() { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java index abe3d1cad0..17c5eebf7d 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java @@ -6,11 +6,11 @@ package net.sourceforge.pmd.lang.apex; import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertSize; import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertSuppressed; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.Report; @@ -19,7 +19,7 @@ import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; import net.sourceforge.pmd.lang.apex.ast.ApexParserTestBase; import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; -public class SuppressWarningsTest extends ApexParserTestBase { +class SuppressWarningsTest extends ApexParserTestBase { // This could be a regular xml test @@ -45,7 +45,7 @@ public class SuppressWarningsTest extends ApexParserTestBase { } @Test - public void testClassLevelSuppression() { + void testClassLevelSuppression() { Report rpt = apex.executeRule(new FooRule(), TEST1); assertSize(rpt, 0); rpt = apex.executeRule(new FooRule(), TEST2); @@ -53,86 +53,86 @@ public class SuppressWarningsTest extends ApexParserTestBase { } @Test - public void testInheritedSuppression() { + void testInheritedSuppression() { Report rpt = apex.executeRule(new FooRule(), TEST3); assertSize(rpt, 0); } @Test - public void testMethodLevelSuppression() { + void testMethodLevelSuppression() { Report rpt = apex.executeRule(new FooRule(), TEST4); assertSize(rpt, 1); } @Test - public void testConstructorLevelSuppression() { + void testConstructorLevelSuppression() { Report rpt = apex.executeRule(new FooRule(), TEST5); assertSize(rpt, 0); } @Test - public void testFieldLevelSuppression() { + void testFieldLevelSuppression() { Report rpt = apex.executeRule(new FooRule(), TEST6); assertSize(rpt, 1); } @Test - public void testParameterLevelSuppression() { + void testParameterLevelSuppression() { Report rpt = apex.executeRule(new FooRule(), TEST7); assertSize(rpt, 1); } @Test - public void testLocalVariableLevelSuppression() { + void testLocalVariableLevelSuppression() { Report rpt = apex.executeRule(new FooRule(), TEST8); assertSize(rpt, 1); } @Test - public void testSpecificSuppression() { + void testSpecificSuppression() { Report rpt = apex.executeRule(new FooRule(), TEST9); assertSize(rpt, 1); } @Test - public void testSpecificSuppressionMulitpleValues() { + void testSpecificSuppressionMulitpleValues() { Report rpt = apex.executeRule(new FooRule(), TEST9_MULTIPLE_VALUES); assertSize(rpt, 0); } @Test - public void testNoSuppressionBlank() { + void testNoSuppressionBlank() { Report rpt = apex.executeRule(new FooRule(), TEST10); assertSize(rpt, 2); } @Test - public void testNoSuppressionSomethingElseS() { + void testNoSuppressionSomethingElseS() { Report rpt = apex.executeRule(new FooRule(), TEST11); assertSize(rpt, 2); } @Test - public void testSuppressAll() { + void testSuppressAll() { Report rpt = apex.executeRule(new FooRule(), TEST12); assertSize(rpt, 0); } @Test - public void testSpecificSuppressionAtTopLevel() { + void testSpecificSuppressionAtTopLevel() { Report rpt = apex.executeRule(new BarRule(), TEST13); assertSize(rpt, 0); } @Test - public void testCommentSuppression() { + void testCommentSuppression() { Report rpt = apex.executeRule(new FooRule(), TEST14); assertSize(rpt, 0); assertSuppressed(rpt, 1); } @Test - public void testMessageWithCommentSuppression() { + void testMessageWithCommentSuppression() { Report rpt = apex.executeRule(new FooRule(), TEST15); assertSize(rpt, 0); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java index 4b9e418590..6c4797a7b6 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java @@ -4,34 +4,36 @@ package net.sourceforge.pmd.lang.apex.ast; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; -public class ASTFieldTest extends ApexParserTestBase { +import org.junit.jupiter.api.Test; + +class ASTFieldTest extends ApexParserTestBase { @Test - public void testGetType() { + void testGetType() { ASTField field = parse("public class Foo { private String myField = 'a'; }") .descendants(ASTField.class).firstOrThrow(); - Assert.assertEquals("myField", field.getImage()); - Assert.assertEquals("String", field.getType()); - Assert.assertEquals("a", field.getValue()); + assertEquals("myField", field.getImage()); + assertEquals("String", field.getType()); + assertEquals("a", field.getValue()); } @Test - public void testGetValue() { + void testGetValue() { ASTField field = parse("public class Foo { private String myField = 'a'; }") .descendants(ASTField.class).firstOrThrow(); - Assert.assertEquals("a", field.getValue()); + assertEquals("a", field.getValue()); } @Test - public void testGetNoValue() { + void testGetNoValue() { ASTField field = parse("public class Foo { private String myField; }") .descendants(ASTField.class).firstOrThrow(); - Assert.assertNull(field.getValue()); + assertNull(field.getValue()); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java index 7ef6efbe66..0cd0033383 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java @@ -4,19 +4,20 @@ package net.sourceforge.pmd.lang.apex.ast; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ASTMethodTest extends ApexParserTestBase { +class ASTMethodTest extends ApexParserTestBase { @Test - public void testConstructorName() { + void testConstructorName() { ASTUserClass node = (ASTUserClass) parse("public class Foo { public Foo() {} public void bar() {} }"); List methods = node.children(ASTMethod.class).toList(); - Assert.assertEquals("Foo", methods.get(0).getImage()); // constructor - Assert.assertEquals("", methods.get(0).getCanonicalName()); - Assert.assertEquals("bar", methods.get(1).getImage()); // normal method + assertEquals("Foo", methods.get(0).getImage()); // constructor + assertEquals("", methods.get(0).getCanonicalName()); + assertEquals("bar", methods.get(1).getImage()); // normal method } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java index 691372eaab..bd5e58553b 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java @@ -4,15 +4,16 @@ package net.sourceforge.pmd.lang.apex.ast; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ASTNewKeyValueObjectExpressionTest extends ApexParserTestBase { +class ASTNewKeyValueObjectExpressionTest extends ApexParserTestBase { @Test - public void testParameterName() { + void testParameterName() { ASTUserClassOrInterface node = parse("public class Foo { \n" + " public void foo(String newName, String tempID) { \n" + " if (Contact.sObjectType.getDescribe().isCreateable() && Contact.sObjectType.getDescribe().isUpdateable()) {\n" @@ -20,13 +21,13 @@ public class ASTNewKeyValueObjectExpressionTest extends ApexParserTestBase { + " }\n" + " } \n" + "}"); ASTNewKeyValueObjectExpression keyValueExpr = node.getFirstDescendantOfType(ASTNewKeyValueObjectExpression.class); - Assert.assertEquals(3, keyValueExpr.getParameterCount()); + assertEquals(3, keyValueExpr.getParameterCount()); List literals = keyValueExpr.findDescendantsOfType(ASTLiteralExpression.class); - Assert.assertEquals(3, literals.size()); - Assert.assertEquals("FirstName", literals.get(0).getName()); - Assert.assertEquals("LastName", literals.get(1).getName()); - Assert.assertEquals("Phone", literals.get(2).getName()); + assertEquals(3, literals.size()); + assertEquals("FirstName", literals.get(0).getName()); + assertEquals("LastName", literals.get(1).getName()); + assertEquals("Phone", literals.get(2).getName()); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java index 22ef9278b9..d8673390a3 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java @@ -4,15 +4,16 @@ package net.sourceforge.pmd.lang.apex.ast; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class ASTSoqlExpressionTest extends ApexParserTestBase { +import org.junit.jupiter.api.Test; + +class ASTSoqlExpressionTest extends ApexParserTestBase { @Test - public void testQuery() { + void testQuery() { ApexNode root = parse("class Foo { void test1() { Account acc = [SELECT col FROM Account]; } }"); ASTSoqlExpression soqlExpression = root.descendants(ASTSoqlExpression.class).firstOrThrow(); - Assert.assertEquals("SELECT col FROM Account", soqlExpression.getQuery()); + assertEquals("SELECT col FROM Account", soqlExpression.getQuery()); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatementTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatementTest.java index f5dddb17c0..28feed0833 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatementTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatementTest.java @@ -4,41 +4,43 @@ package net.sourceforge.pmd.lang.apex.ast; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ASTSwitchStatementTest extends ApexParserTestBase { +class ASTSwitchStatementTest extends ApexParserTestBase { @Test - public void testExamples() { + void testExamples() { ApexNode node = parseResource("SwitchStatements.cls"); List switchStatements = node.findDescendantsOfType(ASTSwitchStatement.class); - Assert.assertEquals(4, switchStatements.size()); + assertEquals(4, switchStatements.size()); - Assert.assertTrue(switchStatements.get(0).getChild(0) instanceof ASTVariableExpression); - Assert.assertEquals(5, switchStatements.get(0).findChildrenOfType(ASTValueWhenBlock.class).size()); - Assert.assertEquals(3, switchStatements.get(0).findChildrenOfType(ASTValueWhenBlock.class) - .get(1).findChildrenOfType(ASTLiteralCase.class).size()); - Assert.assertEquals(1, switchStatements.get(0).findChildrenOfType(ASTElseWhenBlock.class).size()); + assertTrue(switchStatements.get(0).getChild(0) instanceof ASTVariableExpression); + assertEquals(5, switchStatements.get(0).findChildrenOfType(ASTValueWhenBlock.class).size()); + assertEquals(3, switchStatements.get(0).findChildrenOfType(ASTValueWhenBlock.class) + .get(1).findChildrenOfType(ASTLiteralCase.class).size()); + assertEquals(1, switchStatements.get(0).findChildrenOfType(ASTElseWhenBlock.class).size()); - Assert.assertTrue(switchStatements.get(1).getChild(0) instanceof ASTMethodCallExpression); - Assert.assertEquals(2, switchStatements.get(1).findChildrenOfType(ASTValueWhenBlock.class).size()); - Assert.assertEquals(1, switchStatements.get(1).findChildrenOfType(ASTElseWhenBlock.class).size()); + assertTrue(switchStatements.get(1).getChild(0) instanceof ASTMethodCallExpression); + assertEquals(2, switchStatements.get(1).findChildrenOfType(ASTValueWhenBlock.class).size()); + assertEquals(1, switchStatements.get(1).findChildrenOfType(ASTElseWhenBlock.class).size()); - Assert.assertTrue(switchStatements.get(2).getChild(0) instanceof ASTVariableExpression); - Assert.assertEquals(2, switchStatements.get(2).findChildrenOfType(ASTTypeWhenBlock.class).size()); - Assert.assertEquals("Account", switchStatements.get(2).findChildrenOfType(ASTTypeWhenBlock.class) - .get(0).getType()); - Assert.assertEquals("a", switchStatements.get(2).findChildrenOfType(ASTTypeWhenBlock.class) - .get(0).getName()); - Assert.assertEquals(1, switchStatements.get(2).findChildrenOfType(ASTValueWhenBlock.class).size()); - Assert.assertEquals(1, switchStatements.get(2).findChildrenOfType(ASTElseWhenBlock.class).size()); + assertTrue(switchStatements.get(2).getChild(0) instanceof ASTVariableExpression); + assertEquals(2, switchStatements.get(2).findChildrenOfType(ASTTypeWhenBlock.class).size()); + assertEquals("Account", switchStatements.get(2).findChildrenOfType(ASTTypeWhenBlock.class) + .get(0).getType()); + assertEquals("a", switchStatements.get(2).findChildrenOfType(ASTTypeWhenBlock.class) + .get(0).getName()); + assertEquals(1, switchStatements.get(2).findChildrenOfType(ASTValueWhenBlock.class).size()); + assertEquals(1, switchStatements.get(2).findChildrenOfType(ASTElseWhenBlock.class).size()); - Assert.assertTrue(switchStatements.get(3).getChild(0) instanceof ASTVariableExpression); - Assert.assertEquals(2, switchStatements.get(3).findChildrenOfType(ASTValueWhenBlock.class).size()); - Assert.assertEquals(1, switchStatements.get(3).findChildrenOfType(ASTElseWhenBlock.class).size()); + assertTrue(switchStatements.get(3).getChild(0) instanceof ASTVariableExpression); + assertEquals(2, switchStatements.get(3).findChildrenOfType(ASTValueWhenBlock.class).size()); + assertEquals(1, switchStatements.get(3).findChildrenOfType(ASTElseWhenBlock.class).size()); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java index a6cd4df9b9..d71a59f6df 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java @@ -4,44 +4,47 @@ package net.sourceforge.pmd.lang.apex.ast; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; -public class ASTTryCatchFinallyBlockStatementTest extends ApexParserTestBase { +import org.junit.jupiter.api.Test; + +class ASTTryCatchFinallyBlockStatementTest extends ApexParserTestBase { @Test - public void testTryFinally() { + void testTryFinally() { ApexNode node = parse("class Foo { void bar() { try { methodCall(); } finally { methodCall(); } } }"); ASTTryCatchFinallyBlockStatement statement = node.getFirstDescendantOfType(ASTTryCatchFinallyBlockStatement.class); - Assert.assertNotNull(statement.getTryBlock()); - Assert.assertEquals(0, statement.getTryBlock().getIndexInParent()); - Assert.assertNotNull(statement.getFinallyBlock()); - Assert.assertEquals(1, statement.getFinallyBlock().getIndexInParent()); - Assert.assertEquals(0, statement.getCatchClauses().size()); + assertNotNull(statement.getTryBlock()); + assertEquals(0, statement.getTryBlock().getIndexInParent()); + assertNotNull(statement.getFinallyBlock()); + assertEquals(1, statement.getFinallyBlock().getIndexInParent()); + assertEquals(0, statement.getCatchClauses().size()); } @Test - public void testTryCatch() { + void testTryCatch() { ApexNode node = parse("class Foo { void bar() { try { methodCall(); } catch (Exception e) { methodCall(); } } }"); ASTTryCatchFinallyBlockStatement statement = node.getFirstDescendantOfType(ASTTryCatchFinallyBlockStatement.class); - Assert.assertNotNull(statement.getTryBlock()); - Assert.assertEquals(0, statement.getTryBlock().getIndexInParent()); - Assert.assertNull(statement.getFinallyBlock()); - Assert.assertEquals(1, statement.getCatchClauses().size()); - Assert.assertNotNull(statement.getCatchClauses().get(0).getBody()); - Assert.assertEquals(1, statement.getCatchClauses().get(0).getIndexInParent()); + assertNotNull(statement.getTryBlock()); + assertEquals(0, statement.getTryBlock().getIndexInParent()); + assertNull(statement.getFinallyBlock()); + assertEquals(1, statement.getCatchClauses().size()); + assertNotNull(statement.getCatchClauses().get(0).getBody()); + assertEquals(1, statement.getCatchClauses().get(0).getIndexInParent()); } @Test - public void testTryCatchFinally() { + void testTryCatchFinally() { ApexNode node = parse("class Foo { void bar() { try { methodCall(); } catch (Exception e) { methodCall(); } finally { } } }"); ASTTryCatchFinallyBlockStatement statement = node.getFirstDescendantOfType(ASTTryCatchFinallyBlockStatement.class); - Assert.assertNotNull(statement.getTryBlock()); - Assert.assertEquals(0, statement.getTryBlock().getIndexInParent()); - Assert.assertNotNull(statement.getFinallyBlock()); - Assert.assertEquals(2, statement.getFinallyBlock().getIndexInParent()); - Assert.assertEquals(1, statement.getCatchClauses().size()); - Assert.assertNotNull(statement.getCatchClauses().get(0).getBody()); - Assert.assertEquals(1, statement.getCatchClauses().get(0).getIndexInParent()); + assertNotNull(statement.getTryBlock()); + assertEquals(0, statement.getTryBlock().getIndexInParent()); + assertNotNull(statement.getFinallyBlock()); + assertEquals(2, statement.getFinallyBlock().getIndexInParent()); + assertEquals(1, statement.getCatchClauses().size()); + assertNotNull(statement.getCatchClauses().get(0).getBody()); + assertEquals(1, statement.getCatchClauses().get(0).getIndexInParent()); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java index ffa83ee1fa..97120ce364 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java @@ -4,41 +4,42 @@ package net.sourceforge.pmd.lang.apex.ast; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.Arrays; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ASTUserClassTest extends ApexParserTestBase { +class ASTUserClassTest extends ApexParserTestBase { @Test - public void testClassName() { + void testClassName() { ASTUserClass node = (ASTUserClass) parse("class Foo { }"); - Assert.assertEquals("Foo", node.getSimpleName()); + assertEquals("Foo", node.getSimpleName()); } @Test - public void testInnerClassName() { + void testInnerClassName() { ASTUserClass foo = (ASTUserClass) parse("class Foo { class Bar { } }"); ASTUserClass innerNode = foo.descendants(ASTUserClass.class).firstOrThrow(); - Assert.assertEquals("Bar", innerNode.getSimpleName()); + assertEquals("Bar", innerNode.getSimpleName()); } @Test - public void testSuperClassName() { + void testSuperClassName() { ASTUserClass toplevel = (ASTUserClass) parse("public class AccountTriggerHandler extends TriggerHandler {}"); - Assert.assertEquals("TriggerHandler", toplevel.getSuperClassName()); + assertEquals("TriggerHandler", toplevel.getSuperClassName()); } @Test - public void testSuperClassName2() { + void testSuperClassName2() { ASTUserClass toplevel = (ASTUserClass) parse("public class AccountTriggerHandler extends Other.TriggerHandler {}"); - Assert.assertEquals("Other.TriggerHandler", toplevel.getSuperClassName()); + assertEquals("Other.TriggerHandler", toplevel.getSuperClassName()); } @Test - public void testInterfaces() { + void testInterfaces() { ASTUserClass toplevel = (ASTUserClass) parse("public class AccountTriggerHandler implements TriggerHandler, Other.Interface2 {}"); - Assert.assertEquals(Arrays.asList("TriggerHandler", "Other.Interface2"), toplevel.getInterfaceNames()); + assertEquals(Arrays.asList("TriggerHandler", "Other.Interface2"), toplevel.getInterfaceNames()); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java index 9284c78e43..406177cc70 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java @@ -4,15 +4,16 @@ package net.sourceforge.pmd.lang.apex.ast; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class ASTUserEnumTest extends ApexParserTestBase { +import org.junit.jupiter.api.Test; + +class ASTUserEnumTest extends ApexParserTestBase { @Test - public void testEnumName() { + void testEnumName() { ASTUserClass node = (ASTUserClass) parse("class Foo { enum Bar { } }"); ASTUserEnum enumNode = node.descendants(ASTUserEnum.class).firstOrThrow(); - Assert.assertEquals("Bar", enumNode.getSimpleName()); + assertEquals("Bar", enumNode.getSimpleName()); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java index 3d6eace318..1786022e8a 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java @@ -4,33 +4,34 @@ package net.sourceforge.pmd.lang.apex.ast; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class ASTUserInterfaceTest extends ApexParserTestBase { +import org.junit.jupiter.api.Test; + +class ASTUserInterfaceTest extends ApexParserTestBase { @Test - public void testInterfaceName() { + void testInterfaceName() { ASTUserInterface node = (ASTUserInterface) parse("interface Foo { }"); - Assert.assertEquals("Foo", node.getSimpleName()); + assertEquals("Foo", node.getSimpleName()); } @Test - public void testInnerInterfaceName() { + void testInnerInterfaceName() { ASTUserClass node = (ASTUserClass) parse("class Foo { interface Bar { } }"); ASTUserInterface innerNode = node.descendants(ASTUserInterface.class).firstOrThrow(); - Assert.assertEquals("Bar", innerNode.getSimpleName()); + assertEquals("Bar", innerNode.getSimpleName()); } @Test - public void testSuperInterface() { + void testSuperInterface() { ASTUserInterface toplevel = (ASTUserInterface) parse("public interface CustomInterface extends A {}"); - Assert.assertEquals("A", toplevel.getSuperInterfaceName()); + assertEquals("A", toplevel.getSuperInterfaceName()); } @Test - public void testSuperInterface2() { + void testSuperInterface2() { ASTUserInterface toplevel = (ASTUserInterface) parse("public interface CustomInterface extends Other.A {}"); - Assert.assertEquals("Other.A", toplevel.getSuperInterfaceName()); + assertEquals("Other.A", toplevel.getSuperInterfaceName()); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTriggerTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTriggerTest.java index 728588cd61..0195fcb0d9 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTriggerTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTriggerTest.java @@ -4,21 +4,23 @@ package net.sourceforge.pmd.lang.apex.ast; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; + import java.util.Arrays; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ASTUserTriggerTest extends ApexParserTestBase { +class ASTUserTriggerTest extends ApexParserTestBase { @Test - public void testTriggerName() { + void testTriggerName() { ApexNode node = parse("trigger HelloWorldTrigger on Book__c (before insert, after update) {\n" + " Book__c[] books = Trigger.new;\n" + " MyHelloWorld.applyDiscount(books);\n" + "}\n"); - Assert.assertSame(ASTUserTrigger.class, node.getClass()); - Assert.assertEquals("HelloWorldTrigger", node.getImage()); + assertSame(ASTUserTrigger.class, node.getClass()); + assertEquals("HelloWorldTrigger", node.getImage()); ASTUserTrigger trigger = (ASTUserTrigger) node; - Assert.assertEquals("Book__c", trigger.getTargetName()); - Assert.assertEquals(Arrays.asList(TriggerUsage.AFTER_UPDATE, TriggerUsage.BEFORE_INSERT), trigger.getUsages()); + assertEquals("Book__c", trigger.getTargetName()); + assertEquals(Arrays.asList(TriggerUsage.AFTER_UPDATE, TriggerUsage.BEFORE_INSERT), trigger.getUsages()); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java index 9652528256..d0f5c75c4e 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java @@ -4,11 +4,11 @@ package net.sourceforge.pmd.lang.apex.ast; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class ApexCommentTest extends ApexParserTestBase { +import org.junit.jupiter.api.Test; +class ApexCommentTest extends ApexParserTestBase { @Test public void testContainsComment1() { @@ -18,6 +18,6 @@ public class ApexCommentTest extends ApexParserTestBase { + "}}}"); ASTCatchBlockStatement catchBlock = file.descendants(ASTCatchBlockStatement.class).crossFindBoundaries().firstOrThrow(); - Assert.assertTrue(catchBlock.getContainsComment()); + assertTrue(catchBlock.getContainsComment()); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerSoqlTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerSoqlTest.java index 32a4914fef..e585078d7f 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerSoqlTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerSoqlTest.java @@ -4,9 +4,9 @@ package net.sourceforge.pmd.lang.apex.ast; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ApexCompilerSoqlTest extends ApexParserTestBase { +class ApexCompilerSoqlTest extends ApexParserTestBase { private static final String CODE = "public class Foo {\n" + " public List test1() {\n" @@ -15,7 +15,7 @@ public class ApexCompilerSoqlTest extends ApexParserTestBase { + "}\n"; @Test - public void testSoqlCompilation() { + void testSoqlCompilation() { apex.parse(CODE); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerTest.java index 320e82b234..107da7d444 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerTest.java @@ -4,14 +4,16 @@ package net.sourceforge.pmd.lang.apex.ast; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.ast.ParseException; -public class ApexCompilerTest extends ApexParserTestBase { +class ApexCompilerTest extends ApexParserTestBase { - @Test(expected = ParseException.class) - public void compileShouldFail() { - apex.parse("public class Foo { private String myField = \"a\"; }"); + @Test + void compileShouldFail() { + assertThrows(ParseException.class, () -> apex.parse("public class Foo { private String myField = \"a\"; }")); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java index df56adb9d5..79d6b0e17a 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java @@ -4,18 +4,20 @@ package net.sourceforge.pmd.lang.apex.ast; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import org.antlr.runtime.ANTLRStringStream; import org.antlr.runtime.CharStream; import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.Token; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import apex.jorje.data.ast.CompilationUnit; import apex.jorje.parser.impl.ApexLexer; import apex.jorje.parser.impl.ApexParser; -public class ApexLexerTest { +class ApexLexerTest { private static final String CODE = "public class Foo {\n" + " public List test1() {\n" @@ -24,7 +26,7 @@ public class ApexLexerTest { + "}\n"; @Test - public void testLexer() throws Exception { + void testLexer() throws Exception { CharStream in = new ANTLRStringStream(CODE); ApexLexer lexer = new ApexLexer(in); @@ -34,15 +36,15 @@ public class ApexLexerTest { tokenCount++; token = lexer.nextToken(); } - Assert.assertEquals(43, tokenCount); + assertEquals(43, tokenCount); } @Test - public void testParser() throws Exception { + void testParser() throws Exception { CharStream in = new ANTLRStringStream(CODE); ApexLexer lexer = new ApexLexer(in); ApexParser parser = new ApexParser(new CommonTokenStream(lexer)); CompilationUnit compilationUnit = parser.compilationUnit(); - Assert.assertNotNull(compilationUnit); + assertNotNull(compilationUnit); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java index a0180a78c5..935f362cf3 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java @@ -8,26 +8,26 @@ import static net.sourceforge.pmd.lang.ast.test.NodeExtensionsKt.textOfReportLoc import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertPosition; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.util.IOUtil; -public class ApexParserTest extends ApexParserTestBase { +class ApexParserTest extends ApexParserTestBase { @Test - public void understandsSimpleFile() { + void understandsSimpleFile() { // Setup String code = "@isTest\n" @@ -46,7 +46,7 @@ public class ApexParserTest extends ApexParserTestBase { } @Test - public void fileName() { + void fileName() { String code = "class Outer { class Inner {}}"; ASTUserClass rootNode = (ASTUserClass) parse(code, "src/filename.cls"); @@ -63,13 +63,13 @@ public class ApexParserTest extends ApexParserTestBase { + "}"; // line 6 @Test - public void verifyLineColumnNumbers() { + void verifyLineColumnNumbers() { ASTUserClassOrInterface rootNode = parse(testCodeForLineNumbers); assertLineNumbersForTestCode(rootNode); } @Test - public void verifyLineColumnNumbersWithWindowsLineEndings() { + void verifyLineColumnNumbersWithWindowsLineEndings() { String windowsLineEndings = testCodeForLineNumbers.replaceAll(" \n", "\r\n"); ASTUserClassOrInterface rootNode = parse(windowsLineEndings); assertLineNumbersForTestCode(rootNode); @@ -94,7 +94,7 @@ public class ApexParserTest extends ApexParserTestBase { // BlockStatement - the whole method body Node blockStatement = method1.getChild(1); - assertTrue("should detect curly brace", ((ASTBlockStatement) blockStatement).hasCurlyBrace()); + assertTrue(((ASTBlockStatement) blockStatement).hasCurlyBrace(), "should detect curly brace"); assertPosition(blockStatement, 2, 27, 5, 6); // the expression ("System.out...") @@ -104,7 +104,7 @@ public class ApexParserTest extends ApexParserTestBase { } @Test - public void verifyEndLine() { + void verifyEndLine() { String code = "public class SimpleClass {\n" // line 1 + " public void method1() {\n" // line 2 @@ -123,7 +123,7 @@ public class ApexParserTest extends ApexParserTestBase { } @Test - public void checkComments() { + void checkComments() { String code = "public /** Comment on Class */ class SimpleClass {\n" // line 1 + " /** Comment on m1 */" @@ -151,14 +151,14 @@ public class ApexParserTest extends ApexParserTestBase { } @Test - public void parsesRealWorldClasses() throws Exception { + void parsesRealWorldClasses() throws Exception { File directory = new File("src/test/resources"); File[] fList = directory.listFiles(); for (File file : fList) { if (file.isFile() && file.getName().endsWith(".cls")) { String sourceCode = IOUtil.readFileToString(file, StandardCharsets.UTF_8); - Assert.assertNotNull(parse(sourceCode)); + assertNotNull(parse(sourceCode)); } } } @@ -168,10 +168,10 @@ public class ApexParserTest extends ApexParserTestBase { * @see [apex] PMD parsing exception for Apex classes using 'inherited sharing' keyword */ @Test - public void parseInheritedSharingClass() throws IOException { + void parseInheritedSharingClass() throws IOException { String source = IOUtil.readToString(ApexParserTest.class.getResourceAsStream("InheritedSharing.cls"), StandardCharsets.UTF_8); - Assert.assertNotNull(parse(source)); + assertNotNull(parse(source)); } /** @@ -180,25 +180,25 @@ public class ApexParserTest extends ApexParserTestBase { * @see #1485 [apex] Analysis of some apex classes cause a stackoverflow error */ @Test - public void stackOverflowDuringClassParsing() throws Exception { + void stackOverflowDuringClassParsing() throws Exception { String source = IOUtil.readToString(ApexParserTest.class.getResourceAsStream("StackOverflowClass.cls"), StandardCharsets.UTF_8); ASTUserClassOrInterface rootNode = parse(source); - Assert.assertNotNull(rootNode); + assertNotNull(rootNode); int count = visitPosition(rootNode, 0); - Assert.assertEquals(487, count); + assertEquals(487, count); } @Test - public void verifyLineColumnNumbersInnerClasses() { + void verifyLineColumnNumbersInnerClasses() { ASTApexFile rootNode = apex.parseResource("InnerClassLocations.cls"); - Assert.assertNotNull(rootNode); + assertNotNull(rootNode); visitPosition(rootNode, 0); ASTUserClassOrInterface classNode = rootNode.getMainNode(); - Assert.assertEquals("InnerClassLocations", classNode.getSimpleName()); + assertEquals("InnerClassLocations", classNode.getSimpleName()); assertTextEquals("InnerClassLocations", classNode); // Note: Apex parser doesn't provide positions for "public class" keywords. The // position of the UserClass node is just the identifier. So, the node starts @@ -206,20 +206,20 @@ public class ApexParserTest extends ApexParserTestBase { assertPosition(classNode, 1, 14, 1, 33); List classes = classNode.descendants(ASTUserClass.class).toList(); - Assert.assertEquals(2, classes.size()); - Assert.assertEquals("bar1", classes.get(0).getSimpleName()); + assertEquals(2, classes.size()); + assertEquals("bar1", classes.get(0).getSimpleName()); List methods = classes.get(0).children(ASTMethod.class).toList(); - Assert.assertEquals(2, methods.size()); // m() and synthetic clone() - Assert.assertEquals("m", methods.get(0).getImage()); + assertEquals(2, methods.size()); // m() and synthetic clone() + assertEquals("m", methods.get(0).getImage()); assertPosition(methods.get(0), 4, 21, 4, 22); - Assert.assertEquals("clone", methods.get(1).getImage()); + assertEquals("clone", methods.get(1).getImage()); assertFalse(methods.get(1).hasRealLoc()); assertPosition(methods.get(1), 3, 18, 3, 22); // Position of the first inner class is its identifier assertPosition(classes.get(0), 3, 18, 3, 22); - Assert.assertEquals("bar2", classes.get(1).getSimpleName()); + assertEquals("bar2", classes.get(1).getSimpleName()); assertPosition(classes.get(1), 10, 18, 10, 22); } @@ -228,10 +228,10 @@ public class ApexParserTest extends ApexParserTestBase { private int visitPosition(Node node, int count) { int result = count + 1; FileLocation loc = node.getReportLocation(); - Assert.assertTrue(loc.getStartLine() > 0); - Assert.assertTrue(loc.getStartColumn() > 0); - Assert.assertTrue(loc.getEndLine() > 0); - Assert.assertTrue(loc.getEndColumn() > 0); + assertTrue(loc.getStartLine() > 0); + assertTrue(loc.getStartColumn() > 0); + assertTrue(loc.getEndLine() > 0); + assertTrue(loc.getEndColumn() > 0); for (int i = 0; i < node.getNumChildren(); i++) { result = visitPosition(node.getChild(i), result); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java index f95cc4dd69..a39a40ed23 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java @@ -4,23 +4,23 @@ package net.sourceforge.pmd.lang.apex.ast; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Clément Fournier */ -public class ApexQualifiedNameTest extends ApexParserTestBase { +class ApexQualifiedNameTest extends ApexParserTestBase { @Test - public void testClass() { + void testClass() { ASTUserClass root = (ASTUserClass) parse("public class Foo {}"); ApexQualifiedName qname = root.getQualifiedName(); @@ -32,7 +32,7 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test - public void testNestedClass() { + void testNestedClass() { ASTUserClass root = (ASTUserClass) parse("public class Foo { class Bar {}}"); ASTUserClass inner = root.descendants(ASTUserClass.class).firstOrThrow(); @@ -45,7 +45,7 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test - public void testSimpleMethod() { + void testSimpleMethod() { ASTUserClass root = (ASTUserClass) parse("public class Foo { String foo() {}}"); ApexQualifiedName qname = root.descendants(ASTMethod.class).firstOrThrow().getQualifiedName(); assertEquals("c__Foo#foo()", qname.toString()); @@ -56,7 +56,7 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test - public void testMethodWithArguments() { + void testMethodWithArguments() { ASTUserClass root = (ASTUserClass) parse("public class Foo { String foo(String h, Foo g) {}}"); ApexQualifiedName qname = root.descendants(ASTMethod.class).firstOrThrow().getQualifiedName(); assertEquals("c__Foo#foo(String, Foo)", qname.toString()); @@ -67,7 +67,7 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test - public void testOverLoads() { + void testOverLoads() { ASTUserClass root = (ASTUserClass) parse("public class Foo { " + "String foo(String h) {} " + "String foo(int c) {}" @@ -84,7 +84,7 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test - public void testTrigger() { + void testTrigger() { ASTUserTrigger root = (ASTUserTrigger) parse("trigger myAccountTrigger on Account (before insert, before update) {}"); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeDumpTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeDumpTest.java index 6ce49d352e..13f8b60c68 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeDumpTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeDumpTest.java @@ -5,15 +5,15 @@ package net.sourceforge.pmd.lang.apex.ast; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper; import net.sourceforge.pmd.lang.ast.test.BaseTreeDumpTest; import net.sourceforge.pmd.lang.ast.test.RelevantAttributePrinter; -public class ApexTreeDumpTest extends BaseTreeDumpTest { +class ApexTreeDumpTest extends BaseTreeDumpTest { - public ApexTreeDumpTest() { + ApexTreeDumpTest() { super(new RelevantAttributePrinter(), ".cls"); } @@ -23,7 +23,7 @@ public class ApexTreeDumpTest extends BaseTreeDumpTest { } @Test - public void safeNavigationOperator() { + void safeNavigationOperator() { doTest("SafeNavigationOperator"); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/AllMetricsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/AllMetricsTest.java index f0b8d664cc..2936a9d81a 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/AllMetricsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/impl/AllMetricsTest.java @@ -13,7 +13,7 @@ import net.sourceforge.pmd.testframework.SimpleAggregatorTst; * * @author Clément Fournier */ -public class AllMetricsTest extends SimpleAggregatorTst { +class AllMetricsTest extends SimpleAggregatorTst { private static final String RULESET = "rulesets/apex/metrics_test.xml"; diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java index 39c124efed..86236d8adf 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java @@ -6,73 +6,76 @@ package net.sourceforge.pmd.lang.apex.multifile; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsStringIgnoringCase; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.nio.file.Path; import java.util.Arrays; import org.checkerframework.checker.nullness.qual.NonNull; -import org.junit.Rule; -import org.junit.Test; -import org.junit.contrib.java.lang.system.SystemErrRule; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.lang.apex.ApexLanguageProperties; import net.sourceforge.pmd.util.IOUtil; -public class ApexMultifileAnalysisTest { +import com.github.stefanbirkner.systemlambda.SystemLambda; - @Rule - public final SystemErrRule systemErrRule = new SystemErrRule().muteForSuccessfulTests().enableLog(); +class ApexMultifileAnalysisTest { - @Rule - public final TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + private Path tempFolder; @Test - public void testNoSfdxProjectJsonProducesFailedAnalysis() { - ApexMultifileAnalysis analysisInstance = getAnalysisForTempFolder(); + void testNoSfdxProjectJsonProducesFailedAnalysis() throws Exception { + String log = SystemLambda.tapSystemErr(() -> { + ApexMultifileAnalysis analysisInstance = getAnalysisForTempFolder(); - assertTrue(analysisInstance.isFailed()); - assertTrue(analysisInstance.getFileIssues("any file").isEmpty()); - assertThat(systemErrRule.getLog(), containsStringIgnoringCase("Missing project file")); + assertTrue(analysisInstance.isFailed()); + assertTrue(analysisInstance.getFileIssues("any file").isEmpty()); + }); + assertThat(log, containsStringIgnoringCase("Missing project file")); } @Test - public void testMalformedSfdxProjectJsonProducesFailedAnalysis() throws IOException { + void testMalformedSfdxProjectJsonProducesFailedAnalysis() throws Exception { copyResource("malformedSfdxFile.json", "sfdx-project.json"); - ApexMultifileAnalysis analysisInstance = getAnalysisForTempFolder(); + String log = SystemLambda.tapSystemErr(() -> { + ApexMultifileAnalysis analysisInstance = getAnalysisForTempFolder(); - assertTrue(analysisInstance.isFailed()); - assertTrue(analysisInstance.getFileIssues("any file").isEmpty()); - assertThat(systemErrRule.getLog(), + assertTrue(analysisInstance.isFailed()); + assertTrue(analysisInstance.getFileIssues("any file").isEmpty()); + }); + assertThat(log, containsStringIgnoringCase("error: 'path' is required for all 'packageDirectories' elements")); } @Test - public void testWellFormedSfdxProjectJsonProducesFunctionalAnalysis() throws IOException { + void testWellFormedSfdxProjectJsonProducesFunctionalAnalysis() throws Exception { copyResource("correctSfdxFile.json", "sfdx-project.json"); - ApexMultifileAnalysis analysisInstance = getAnalysisForTempFolder(); + String log = SystemLambda.tapSystemErr(() -> { + ApexMultifileAnalysis analysisInstance = getAnalysisForTempFolder(); - assertFalse(analysisInstance.isFailed()); - assertTrue(systemErrRule.getLog().isEmpty()); + assertFalse(analysisInstance.isFailed()); + }); + assertTrue(log.isEmpty()); } private @NonNull ApexMultifileAnalysis getAnalysisForTempFolder() { ApexLanguageProperties props = new ApexLanguageProperties(); - props.setProperty(ApexLanguageProperties.MULTIFILE_DIRECTORY, tempFolder.getRoot().getAbsolutePath()); + props.setProperty(ApexLanguageProperties.MULTIFILE_DIRECTORY, tempFolder.toAbsolutePath().toString()); return new ApexMultifileAnalysis(props); } private void copyResource(String resourcePath, String relativePathInTempDir) throws IOException { - File file = tempFolder.newFile(relativePathInTempDir); + Path file = tempFolder.resolve(relativePathInTempDir); String fileContents = IOUtil.readToString(getClass().getResourceAsStream(resourcePath), StandardCharsets.UTF_8); - Files.write(file.toPath(), Arrays.asList(fileContents.split("\\R").clone())); + Files.write(file, Arrays.asList(fileContents.split("\\R").clone())); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java index bbc3a29a1a..cf2f2c3d6b 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.apex.rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.apex.ast.ASTAnonymousClass; @@ -15,25 +15,25 @@ import net.sourceforge.pmd.lang.apex.ast.ASTUserTrigger; import net.sourceforge.pmd.lang.apex.ast.ApexParserTestBase; import net.sourceforge.pmd.lang.ast.test.TestUtilsKt; -public class AbstractApexRuleTest extends ApexParserTestBase { +class AbstractApexRuleTest extends ApexParserTestBase { @Test - public void shouldVisitTopLevelClass() { + void shouldVisitTopLevelClass() { run("class Foo { }"); } @Test - public void shouldVisitTopLevelInterface() { + void shouldVisitTopLevelInterface() { run("interface Foo { }"); } @Test - public void shouldVisitTopLevelTrigger() { + void shouldVisitTopLevelTrigger() { run("trigger Foo on Account (before insert, before update) { }"); } @Test - public void shouldVisitTopLevelEnum() { + void shouldVisitTopLevelEnum() { run("enum Foo { }"); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java index b907a9b9a1..b13d5aa921 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.apex.rule; import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertSize; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.apex.ast.ApexParserTestBase; @@ -15,7 +15,7 @@ import net.sourceforge.pmd.lang.rule.XPathRule; /** * @author daniels */ -public class ApexXPathRuleTest extends ApexParserTestBase { +class ApexXPathRuleTest extends ApexParserTestBase { private XPathRule makeXPath(String expression) { return apex.newXpathRule(expression); @@ -23,7 +23,7 @@ public class ApexXPathRuleTest extends ApexParserTestBase { @Test - public void testFileNameInXpath() { + void testFileNameInXpath() { Report report = apex.executeRule(makeXPath("/UserClass[pmd:fileName() = 'Foo.cls']"), "class Foo {}", "src/Foo.cls"); @@ -32,7 +32,7 @@ public class ApexXPathRuleTest extends ApexParserTestBase { } @Test - public void testBooleanExpressions() { + void testBooleanExpressions() { Report report = apex.executeRuleOnResource(makeXPath("//BooleanExpression[@Operator='&&']"), "BooleanExpressions.cls"); assertSize(report, 1); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageTest.java index 8b9464e9e9..46ab3aff19 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.bestpractices; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexAssertionsShouldIncludeMessageTest extends PmdRuleTst { +class ApexAssertionsShouldIncludeMessageTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsTest.java index 5c3d68226e..8da6170cb0 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.bestpractices; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexUnitTestClassShouldHaveAssertsTest extends PmdRuleTst { +class ApexUnitTestClassShouldHaveAssertsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestMethodShouldHaveIsTestAnnotationTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestMethodShouldHaveIsTestAnnotationTest.java index b753e8fb8a..983448dce7 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestMethodShouldHaveIsTestAnnotationTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestMethodShouldHaveIsTestAnnotationTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.bestpractices; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexUnitTestMethodShouldHaveIsTestAnnotationTest extends PmdRuleTst { +class ApexUnitTestMethodShouldHaveIsTestAnnotationTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestShouldNotUseSeeAllDataTrueTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestShouldNotUseSeeAllDataTrueTest.java index 00084bc52e..150bcfecd6 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestShouldNotUseSeeAllDataTrueTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestShouldNotUseSeeAllDataTrueTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.bestpractices; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexUnitTestShouldNotUseSeeAllDataTrueTest extends PmdRuleTst { +class ApexUnitTestShouldNotUseSeeAllDataTrueTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidGlobalModifierTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidGlobalModifierTest.java index 6a1780bfc9..eff39e8739 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidGlobalModifierTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidGlobalModifierTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.bestpractices; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class AvoidGlobalModifierTest extends PmdRuleTst { +class AvoidGlobalModifierTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidLogicInTriggerTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidLogicInTriggerTest.java index 08cfa53ada..21cd2021d9 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidLogicInTriggerTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidLogicInTriggerTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.bestpractices; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class AvoidLogicInTriggerTest extends PmdRuleTst { +class AvoidLogicInTriggerTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/DebugsShouldUseLoggingLevelTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/DebugsShouldUseLoggingLevelTest.java index 4632c9a051..939ad1b510 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/DebugsShouldUseLoggingLevelTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/DebugsShouldUseLoggingLevelTest.java @@ -7,6 +7,6 @@ package net.sourceforge.pmd.lang.apex.rule.bestpractices; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class DebugsShouldUseLoggingLevelTest extends PmdRuleTst { +class DebugsShouldUseLoggingLevelTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/UnusedLocalVariableTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/UnusedLocalVariableTest.java index cef1960afc..fe40d55ecc 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/UnusedLocalVariableTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/UnusedLocalVariableTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.bestpractices; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class UnusedLocalVariableTest extends PmdRuleTst { +class UnusedLocalVariableTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsTest.java index 6e44c82f66..0ebe54c2a2 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ClassNamingConventionsTest extends PmdRuleTst { +class ClassNamingConventionsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldDeclarationsShouldBeAtStartTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldDeclarationsShouldBeAtStartTest.java index c22140d52d..3a3224f1dc 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldDeclarationsShouldBeAtStartTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldDeclarationsShouldBeAtStartTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class FieldDeclarationsShouldBeAtStartTest extends PmdRuleTst { +class FieldDeclarationsShouldBeAtStartTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldNamingConventionsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldNamingConventionsTest.java index 823a7f32fc..cc04dbc5ca 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldNamingConventionsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldNamingConventionsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class FieldNamingConventionsTest extends PmdRuleTst { +class FieldNamingConventionsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ForLoopsMustUseBracesTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ForLoopsMustUseBracesTest.java index 32e64fa7c8..22891df41c 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ForLoopsMustUseBracesTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ForLoopsMustUseBracesTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ForLoopsMustUseBracesTest extends PmdRuleTst { +class ForLoopsMustUseBracesTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterNamingConventionsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterNamingConventionsTest.java index 45dba2964e..79561ea4a8 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterNamingConventionsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterNamingConventionsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class FormalParameterNamingConventionsTest extends PmdRuleTst { +class FormalParameterNamingConventionsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/IfElseStmtsMustUseBracesTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/IfElseStmtsMustUseBracesTest.java index 8c118c38d7..a5b04aaf90 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/IfElseStmtsMustUseBracesTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/IfElseStmtsMustUseBracesTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class IfElseStmtsMustUseBracesTest extends PmdRuleTst { +class IfElseStmtsMustUseBracesTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/IfStmtsMustUseBracesTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/IfStmtsMustUseBracesTest.java index 049d251fbd..8d91dd649b 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/IfStmtsMustUseBracesTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/IfStmtsMustUseBracesTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class IfStmtsMustUseBracesTest extends PmdRuleTst { +class IfStmtsMustUseBracesTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/LocalVariableNamingConventionsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/LocalVariableNamingConventionsTest.java index 6ddf91a354..0915626fce 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/LocalVariableNamingConventionsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/LocalVariableNamingConventionsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class LocalVariableNamingConventionsTest extends PmdRuleTst { +class LocalVariableNamingConventionsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsTest.java index 2be02e5acb..291fa815fc 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class MethodNamingConventionsTest extends PmdRuleTst { +class MethodNamingConventionsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/OneDeclarationPerLineTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/OneDeclarationPerLineTest.java index fa97125829..37fbf81509 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/OneDeclarationPerLineTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/OneDeclarationPerLineTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class OneDeclarationPerLineTest extends PmdRuleTst { +class OneDeclarationPerLineTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/PropertyNamingConventionsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/PropertyNamingConventionsTest.java index 413e80ed09..6e78c8d37f 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/PropertyNamingConventionsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/PropertyNamingConventionsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class PropertyNamingConventionsTest extends PmdRuleTst { +class PropertyNamingConventionsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/WhileLoopsMustUseBracesTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/WhileLoopsMustUseBracesTest.java index e5a005e726..03b7109932 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/WhileLoopsMustUseBracesTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/WhileLoopsMustUseBracesTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class WhileLoopsMustUseBracesTest extends PmdRuleTst { +class WhileLoopsMustUseBracesTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidDeeplyNestedIfStmtsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidDeeplyNestedIfStmtsTest.java index abf3e78e0c..5002fe75d2 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidDeeplyNestedIfStmtsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidDeeplyNestedIfStmtsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.design; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class AvoidDeeplyNestedIfStmtsTest extends PmdRuleTst { +class AvoidDeeplyNestedIfStmtsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityTest.java index 3258d92160..07ece5a9a3 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityTest.java @@ -6,5 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.design; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class CognitiveComplexityTest extends PmdRuleTst { +class CognitiveComplexityTest extends PmdRuleTst { + // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityTest.java index 50ffb556ea..e0c5c3696d 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityTest.java @@ -6,5 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.design; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class CyclomaticComplexityTest extends PmdRuleTst { +class CyclomaticComplexityTest extends PmdRuleTst { + // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveClassLengthTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveClassLengthTest.java index 5cde5c180c..99b4becd66 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveClassLengthTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveClassLengthTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.design; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ExcessiveClassLengthTest extends PmdRuleTst { +class ExcessiveClassLengthTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveParameterListTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveParameterListTest.java index d2263e88b6..78bb4a0c43 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveParameterListTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveParameterListTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.design; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ExcessiveParameterListTest extends PmdRuleTst { +class ExcessiveParameterListTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessivePublicCountTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessivePublicCountTest.java index 20a52344b1..256d0f3847 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessivePublicCountTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessivePublicCountTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.design; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ExcessivePublicCountTest extends PmdRuleTst { +class ExcessivePublicCountTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountTest.java index ec837f8518..100985cb5c 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.design; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class NcssConstructorCountTest extends PmdRuleTst { +class NcssConstructorCountTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountTest.java index 8f9b35c018..af10fcdbfd 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.design; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class NcssMethodCountTest extends PmdRuleTst { +class NcssMethodCountTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountTest.java index 3416a142c9..92ec3a77be 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.design; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class NcssTypeCountTest extends PmdRuleTst { +class NcssTypeCountTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/TooManyFieldsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/TooManyFieldsTest.java index 71becae7c6..cdd02ad007 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/TooManyFieldsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/TooManyFieldsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.design; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class TooManyFieldsTest extends PmdRuleTst { +class TooManyFieldsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/documentation/ApexDocTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/documentation/ApexDocTest.java index 93273a11ad..080b396560 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/documentation/ApexDocTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/documentation/ApexDocTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.documentation; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexDocTest extends PmdRuleTst { +class ApexDocTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/ApexCSRFTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/ApexCSRFTest.java index 5549abc726..85f7f104e0 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/ApexCSRFTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/ApexCSRFTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexCSRFTest extends PmdRuleTst { +class ApexCSRFTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidDirectAccessTriggerMapTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidDirectAccessTriggerMapTest.java index fbe6cd530e..09f59fac05 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidDirectAccessTriggerMapTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidDirectAccessTriggerMapTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class AvoidDirectAccessTriggerMapTest extends PmdRuleTst { +class AvoidDirectAccessTriggerMapTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdTest.java index 51f261aec0..2a88bb417b 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class AvoidHardcodingIdTest extends PmdRuleTst { +class AvoidHardcodingIdTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidNonExistentAnnotationsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidNonExistentAnnotationsTest.java index 45139b9d0a..b6519db2cd 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidNonExistentAnnotationsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidNonExistentAnnotationsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class AvoidNonExistentAnnotationsTest extends PmdRuleTst { +class AvoidNonExistentAnnotationsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyCatchBlockTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyCatchBlockTest.java index a6c0dc0cea..1bc971edbc 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyCatchBlockTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyCatchBlockTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class EmptyCatchBlockTest extends PmdRuleTst { +class EmptyCatchBlockTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyIfStmtTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyIfStmtTest.java index cc8f0a982e..4c131f7cd4 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyIfStmtTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyIfStmtTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class EmptyIfStmtTest extends PmdRuleTst { +class EmptyIfStmtTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyStatementBlockTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyStatementBlockTest.java index 7a39e1aba5..44cad0042f 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyStatementBlockTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyStatementBlockTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class EmptyStatementBlockTest extends PmdRuleTst { +class EmptyStatementBlockTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyTryOrFinallyBlockTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyTryOrFinallyBlockTest.java index d2d24d91af..1e68857b57 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyTryOrFinallyBlockTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyTryOrFinallyBlockTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class EmptyTryOrFinallyBlockTest extends PmdRuleTst { +class EmptyTryOrFinallyBlockTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyWhileStmtTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyWhileStmtTest.java index 3a98d7a9cd..a7a297124d 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyWhileStmtTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/EmptyWhileStmtTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class EmptyWhileStmtTest extends PmdRuleTst { +class EmptyWhileStmtTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/InaccessibleAuraEnabledGetterTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/InaccessibleAuraEnabledGetterTest.java index 61ee79a54f..31e1ebd383 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/InaccessibleAuraEnabledGetterTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/InaccessibleAuraEnabledGetterTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class InaccessibleAuraEnabledGetterTest extends PmdRuleTst { +class InaccessibleAuraEnabledGetterTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/MethodWithSameNameAsEnclosingClassTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/MethodWithSameNameAsEnclosingClassTest.java index 87e1ce6431..3a15b5dae8 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/MethodWithSameNameAsEnclosingClassTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/MethodWithSameNameAsEnclosingClassTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class MethodWithSameNameAsEnclosingClassTest extends PmdRuleTst { +class MethodWithSameNameAsEnclosingClassTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/OverrideBothEqualsAndHashcodeTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/OverrideBothEqualsAndHashcodeTest.java index 0b334a5f9f..29ab1310c3 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/OverrideBothEqualsAndHashcodeTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/OverrideBothEqualsAndHashcodeTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class OverrideBothEqualsAndHashcodeTest extends PmdRuleTst { +class OverrideBothEqualsAndHashcodeTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/TestMethodsMustBeInTestClassesTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/TestMethodsMustBeInTestClassesTest.java index 6557797677..1d4f6539a5 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/TestMethodsMustBeInTestClassesTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/errorprone/TestMethodsMustBeInTestClassesTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.errorprone; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class TestMethodsMustBeInTestClassesTest extends PmdRuleTst { +class TestMethodsMustBeInTestClassesTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDebugStatementsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDebugStatementsTest.java index 53aa68ae84..38e591773e 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDebugStatementsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDebugStatementsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.performance; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class AvoidDebugStatementsTest extends PmdRuleTst { +class AvoidDebugStatementsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDmlStatementsInLoopsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDmlStatementsInLoopsTest.java index e63930e585..9ceb16e5d1 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDmlStatementsInLoopsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidDmlStatementsInLoopsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.performance; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class AvoidDmlStatementsInLoopsTest extends PmdRuleTst { +class AvoidDmlStatementsInLoopsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoqlInLoopsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoqlInLoopsTest.java index cec9d93bf4..af15d9ce39 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoqlInLoopsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoqlInLoopsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.performance; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class AvoidSoqlInLoopsTest extends PmdRuleTst { +class AvoidSoqlInLoopsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoslInLoopsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoslInLoopsTest.java index ce3a33a7c8..c0657a5904 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoslInLoopsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidSoslInLoopsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.performance; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class AvoidSoslInLoopsTest extends PmdRuleTst { +class AvoidSoslInLoopsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/EagerlyLoadedDescribeSObjectResultTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/EagerlyLoadedDescribeSObjectResultTest.java index 3a50ee847e..ddc191c0a6 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/EagerlyLoadedDescribeSObjectResultTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/EagerlyLoadedDescribeSObjectResultTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.performance; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class EagerlyLoadedDescribeSObjectResultTest extends PmdRuleTst { +class EagerlyLoadedDescribeSObjectResultTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithLimitsInLoopTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithLimitsInLoopTest.java index 56a609bad8..e80764adbc 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithLimitsInLoopTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithLimitsInLoopTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.performance; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class OperationWithLimitsInLoopTest extends PmdRuleTst { +class OperationWithLimitsInLoopTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoTest.java index 05134ff78c..280a1c8cb2 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexBadCryptoTest extends PmdRuleTst { +class ApexBadCryptoTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationTest.java index 4d4e8a6e22..c6310ba371 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationTest.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.apex.rule.security; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexCRUDViolationTest extends PmdRuleTst { +class ApexCRUDViolationTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsTest.java index 74fe589b3d..8796b360a4 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexDangerousMethodsTest extends PmdRuleTst { +class ApexDangerousMethodsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointTest.java index c118cbb916..000e2544c3 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexInsecureEndpointTest extends PmdRuleTst { +class ApexInsecureEndpointTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectTest.java index 5cf72744fa..4108b3b9a0 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexOpenRedirectTest extends PmdRuleTst { +class ApexOpenRedirectTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionTest.java index a9a619d356..cde095f6e4 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexSOQLInjectionTest extends PmdRuleTst { +class ApexSOQLInjectionTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java index 4d87add0c5..dd2ae6531b 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java @@ -4,16 +4,15 @@ package net.sourceforge.pmd.lang.apex.rule.security; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleViolation; @@ -27,8 +26,7 @@ import net.sourceforge.pmd.lang.apex.ast.ApexParserTestBase; * based on the boolean permutations. Any classes that includes data access cod, but doesn't declare a sharing setting * should trigger a violation.

*/ -@RunWith(Parameterized.class) -public class ApexSharingViolationsNestedClassTest extends ApexParserTestBase { +class ApexSharingViolationsNestedClassTest extends ApexParserTestBase { /** * Type of operation that may require a sharing declaration. */ @@ -56,45 +54,25 @@ public class ApexSharingViolationsNestedClassTest extends ApexParserTestBase { /** * The permutations used for class generation. See {@link #generateClass(boolean, Operation, boolean, Operation)} */ - private final boolean outerSharingDeclared; - private final Operation outerOperation; - private final boolean innerSharingDeclared; - private final Operation innerOperation; - - /** - * Track the expected violations based on the permutations. - */ - private final int expectedViolations; - private final List expectedLineNumbers; - - public ApexSharingViolationsNestedClassTest(boolean outerSharingDeclared, Operation outerOperation, - boolean innerSharingDeclared, Operation innerOperation, - int expectedViolations, List expectedLineNumbers) { - this.outerSharingDeclared = outerSharingDeclared; - this.outerOperation = outerOperation; - this.innerSharingDeclared = innerSharingDeclared; - this.innerOperation = innerOperation; - this.expectedViolations = expectedViolations; - this.expectedLineNumbers = expectedLineNumbers; - } - - @Test - public void testSharingPermutation() { + @ParameterizedTest + @MethodSource("data") + void testSharingPermutation(boolean outerSharingDeclared, Operation outerOperation, + boolean innerSharingDeclared, Operation innerOperation, + int expectedViolations, List expectedLineNumbers) { String apexClass = generateClass(outerSharingDeclared, outerOperation, innerSharingDeclared, innerOperation); ApexSharingViolationsRule rule = new ApexSharingViolationsRule(); rule.setMessage("a message"); Report rpt = apex.executeRule(rule, apexClass); List violations = rpt.getViolations(); - assertEquals("Unexpected Violation Size\n" + apexClass, expectedViolations, violations.size()); + assertEquals(expectedViolations, violations.size(), "Unexpected Violation Size\n" + apexClass); List lineNumbers = violations.stream().map(v -> v.getBeginLine()).collect(Collectors.toList()); - assertEquals("Unexpected Line Numbers\n" + apexClass, expectedLineNumbers, lineNumbers); + assertEquals(expectedLineNumbers, lineNumbers, "Unexpected Line Numbers\n" + apexClass); } /** * Parameter provider that covers are all permutations */ - @Parameterized.Parameters - public static Collection data() { + static Collection data() { List data = new ArrayList<>(); boolean[] boolPermutations = {false, true}; diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsTest.java index e083382550..2e918f1e56 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexSharingViolationsTest extends PmdRuleTst { +class ApexSharingViolationsTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredTest.java index 231f15313e..442ed24f96 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexSuggestUsingNamedCredTest extends PmdRuleTst { +class ApexSuggestUsingNamedCredTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseTest.java index 9acbd35642..6ede53430d 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexXSSFromEscapeFalseTest extends PmdRuleTst { +class ApexXSSFromEscapeFalseTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamTest.java index a0f8bdc72d..0286092d14 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule.security; import net.sourceforge.pmd.testframework.PmdRuleTst; -public class ApexXSSFromURLParamTest extends PmdRuleTst { +class ApexXSSFromURLParamTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java index b7c77650c2..06d3a64781 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java @@ -88,7 +88,7 @@ public class PmdAnalysisTest { } @Test - public void testParseException() { + void testParseException() { PMDConfiguration config = new PMDConfiguration(); config.setThreads(1); config.setForceLanguageVersion(DummyLanguageModule.getInstance().getVersionWhereParserThrows()); @@ -103,7 +103,7 @@ public class PmdAnalysisTest { } @Test - public void testRuleFailureDuringInitialization() { + void testRuleFailureDuringInitialization() { PMDConfiguration config = new PMDConfiguration(); config.setThreads(1); MessageReporter mockReporter = spy(NoopReporter.class); @@ -130,7 +130,7 @@ public class PmdAnalysisTest { } @Test - public void testFileWithSpecificLanguage() { + void testFileWithSpecificLanguage() { final Language language = Dummy2LanguageModule.getInstance(); PMDConfiguration config = new PMDConfiguration(); config.setIgnoreIncrementalAnalysis(true); @@ -149,7 +149,7 @@ public class PmdAnalysisTest { } @Test - public void testTextFileWithSpecificLanguage() { + void testTextFileWithSpecificLanguage() { final Language language = Dummy2LanguageModule.getInstance(); PMDConfiguration config = new PMDConfiguration(); config.setIgnoreIncrementalAnalysis(true); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java b/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java index 43bc6f0958..9396ad128f 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java @@ -5,7 +5,7 @@ package net.sourceforge.pmd; import static net.sourceforge.pmd.util.CollectionUtil.buildMap; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.any; import static org.mockito.Mockito.argThat; import static org.mockito.Mockito.eq; @@ -32,12 +32,12 @@ import net.sourceforge.pmd.util.internal.xml.SchemaConstants; import net.sourceforge.pmd.util.log.MessageReporter; import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; -public class RulesetFactoryTestBase { +class RulesetFactoryTestBase { protected MessageReporter mockReporter; @BeforeEach - public void setup() { + void setup() { SimpleMessageReporter reporter = new SimpleMessageReporter(LoggerFactory.getLogger(RulesetFactoryTestBase.class)); mockReporter = spy(reporter); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/CharStreamTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/CharStreamTest.java index 6e4662e5cd..ff730aec42 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/CharStreamTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/CharStreamTest.java @@ -4,26 +4,26 @@ package net.sourceforge.pmd.lang.ast.impl.javacc; -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.EOFException; import java.io.IOException; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccTokenDocument.TokenDocumentBehavior; import net.sourceforge.pmd.lang.document.TextDocument; -public class CharStreamTest { +class CharStreamTest { private LanguageVersion dummyVersion = DummyLanguageModule.getInstance().getDefaultVersion(); @Test - public void testReadZeroChars() throws IOException { + void testReadZeroChars() throws IOException { CharStream stream = simpleCharStream(""); @@ -34,7 +34,7 @@ public class CharStreamTest { } @Test - public void testMultipleEofReads() throws IOException { + void testMultipleEofReads() throws IOException { CharStream stream = simpleCharStream(""); @@ -45,7 +45,7 @@ public class CharStreamTest { } @Test - public void testReadStuff() throws IOException { + void testReadStuff() throws IOException { CharStream stream = simpleCharStream("abcd"); @@ -58,7 +58,7 @@ public class CharStreamTest { } @Test - public void testReadBacktrack() throws IOException { + void testReadBacktrack() throws IOException { CharStream stream = simpleCharStream("abcd"); @@ -78,7 +78,7 @@ public class CharStreamTest { } @Test - public void testReadBacktrackWithEscapes() throws IOException { + void testReadBacktrackWithEscapes() throws IOException { CharStream stream = javaCharStream("__\\u00a0_\\u00a0_"); @@ -106,7 +106,7 @@ public class CharStreamTest { } @Test - public void testBacktrackTooMuch() throws IOException { + void testBacktrackTooMuch() throws IOException { CharStream stream = simpleCharStream("abcd"); @@ -121,7 +121,7 @@ public class CharStreamTest { } @Test - public void testBacktrackTooMuch2() throws IOException { + void testBacktrackTooMuch2() throws IOException { CharStream stream = simpleCharStream("abcd"); @@ -134,11 +134,11 @@ public class CharStreamTest { } - public CharStream simpleCharStream(String abcd) { + CharStream simpleCharStream(String abcd) { return CharStream.create(TextDocument.readOnlyString(abcd, dummyVersion), TokenDocumentBehavior.DEFAULT); } - public CharStream javaCharStream(String abcd) { + CharStream javaCharStream(String abcd) { return CharStream.create( TextDocument.readOnlyString(abcd, dummyVersion), new TokenDocumentBehavior(Collections.emptyList()) { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeReaderTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeReaderTest.java index 6c0f5ec6e9..a1e8c8faec 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeReaderTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeReaderTest.java @@ -4,27 +4,27 @@ package net.sourceforge.pmd.lang.ast.impl.javacc; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.document.TextDocument; -public class JavaEscapeReaderTest { +class JavaEscapeReaderTest { - public TextDocument readString(String input) { + TextDocument readString(String input) { TextDocument intext = TextDocument.readOnlyString(Chars.wrap(input), DummyLanguageModule.getInstance().getDefaultVersion()); return new JavaEscapeTranslator(intext).translateDocument(); } @Test - public void testSimpleRead() throws IOException { + void testSimpleRead() throws IOException { String input = "abcdede"; try (TextDocument r = readString(input)) { @@ -33,7 +33,7 @@ public class JavaEscapeReaderTest { } @Test - public void testNotAnEscape1Read() throws IOException { + void testNotAnEscape1Read() throws IOException { String input = "abc\\dede"; try (TextDocument r = readString(input)) { @@ -42,7 +42,7 @@ public class JavaEscapeReaderTest { } @Test - public void testNotAnEscape1Read2() throws IOException { + void testNotAnEscape1Read2() throws IOException { String input = "abc\\\\\\dede"; try (TextDocument r = readString(input)) { @@ -51,7 +51,7 @@ public class JavaEscapeReaderTest { } @Test - public void testAnEscapeStopAtEnd() throws IOException { + void testAnEscapeStopAtEnd() throws IOException { String input = "abc\\\\\\u00a0dede"; try (TextDocument r = readString(input)) { @@ -60,7 +60,7 @@ public class JavaEscapeReaderTest { } @Test - public void testSeveralEscapes() throws IOException { + void testSeveralEscapes() throws IOException { String input = "abc\\\\\\u00a0d\\uu00a0ede"; try (TextDocument r = readString(input)) { @@ -69,7 +69,7 @@ public class JavaEscapeReaderTest { } @Test - public void testAnEscapeInsideBlock() throws IOException { + void testAnEscapeInsideBlock() throws IOException { String input = "abc\\\\\\u00a0dede\\u00a0"; try (TextDocument r = readString(input)) { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java index 67b7976579..3b896b97e7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java @@ -26,22 +26,22 @@ import net.sourceforge.pmd.util.CollectionUtil; /** * */ -public class CharsTest { +class CharsTest { @Test - public void wrapStringRoundTrip() { + void wrapStringRoundTrip() { String s = "ooo"; assertSame(s, Chars.wrap(s).toString()); } @Test - public void wrapCharsRoundTrip() { + void wrapCharsRoundTrip() { Chars s = Chars.wrap("ooo"); assertSame(s, Chars.wrap(s)); } @Test - public void appendChars() { + void appendChars() { StringBuilder sb = new StringBuilder(); Chars bc = Chars.wrap("abcd").slice(1, 2); assertEquals("bc", bc.toString()); @@ -51,7 +51,7 @@ public class CharsTest { } @Test - public void appendCharsWithOffsets() { + void appendCharsWithOffsets() { StringBuilder sb = new StringBuilder(); Chars bc = Chars.wrap("abcd").slice(1, 2); assertEquals("bc", bc.toString()); @@ -61,7 +61,7 @@ public class CharsTest { } @Test - public void toStringBuilder() { + void toStringBuilder() { Chars bc = Chars.wrap("abcd").slice(1, 2); assertEquals("bc", bc.toString()); @@ -69,7 +69,7 @@ public class CharsTest { } @Test - public void write() throws IOException { + void write() throws IOException { StringWriter writer = new StringWriter(); Chars bc = Chars.wrap("abcd").slice(1, 2); assertEquals("bc", bc.toString()); @@ -82,7 +82,7 @@ public class CharsTest { } @Test - public void getChars() { + void getChars() { char[] arr = new char[4]; Chars bc = Chars.wrap("abcd").slice(1, 2); @@ -97,7 +97,7 @@ public class CharsTest { } @Test - public void indexOf() { + void indexOf() { Chars bc = Chars.wrap("aaaaabcdb").slice(5, 2); // -- assertEquals(0, bc.indexOf('b', 0)); @@ -111,7 +111,7 @@ public class CharsTest { } @Test - public void indexOfString() { + void indexOfString() { Chars bc = Chars.wrap("aaaaabcdb").slice(5, 2); // -- assertEquals(0, bc.indexOf("b", 0)); @@ -136,7 +136,7 @@ public class CharsTest { } @Test - public void lastIndexOf() { + void lastIndexOf() { Chars bc = Chars.wrap("aaaaabcdb").slice(5, 2); // -- assertEquals(0, bc.lastIndexOf('b', 0)); @@ -153,7 +153,7 @@ public class CharsTest { } @Test - public void startsWith() { + void startsWith() { Chars bc = Chars.wrap("abcdb").slice(1, 2); assertTrue(bc.startsWith("bc")); @@ -179,7 +179,7 @@ public class CharsTest { } @Test - public void removeSuffix() { + void removeSuffix() { Chars bc = Chars.wrap("abcdb").slice(1, 2); // -- @@ -195,7 +195,7 @@ public class CharsTest { } @Test - public void removePrefix() { + void removePrefix() { Chars bc = Chars.wrap("abcdb").slice(1, 2); // -- @@ -213,7 +213,7 @@ public class CharsTest { } @Test - public void trimNoop() { + void trimNoop() { Chars bc = Chars.wrap("abcdb").slice(1, 2); assertEquals("bc", bc.toString()); assertEquals("bc", bc.trimStart().toString()); @@ -222,7 +222,7 @@ public class CharsTest { } @Test - public void trimStartAndEnd() { + void trimStartAndEnd() { Chars bc = Chars.wrap("a bc db").slice(1, 6); // ------ assertEquals(" bc ", bc.toString()); @@ -232,7 +232,7 @@ public class CharsTest { } @Test - public void charAt() { + void charAt() { Chars bc = Chars.wrap("a bc db").slice(1, 6); // ------ @@ -245,7 +245,7 @@ public class CharsTest { } @Test - public void linesTest() { + void linesTest() { Chars bc = Chars.wrap("a \n \r\nbc db").slice(1, 9); // ------------ @@ -254,28 +254,28 @@ public class CharsTest { } @Test - public void linesTest2() { + void linesTest2() { Chars bc = Chars.wrap("aa\n"); List lines = CollectionUtil.map(bc.lines(), Chars::toString); assertEquals(listOf("aa"), lines); } @Test - public void linesStreamTest() { + void linesStreamTest() { Chars bc = Chars.wrap("aa\nb\rded\r\nlff"); List lines = bc.lineStream().map(Chars::toString).collect(Collectors.toList()); assertEquals(listOf("aa", "b", "ded", "lff"), lines); } @Test - public void linesTest3WithCr() { + void linesTest3WithCr() { Chars bc = Chars.wrap("aa\rb"); List lines = CollectionUtil.map(bc.lines(), Chars::toString); assertEquals(listOf("aa", "b"), lines); } @Test - public void testEqualsHashCode() { + void testEqualsHashCode() { Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); @@ -292,7 +292,7 @@ public class CharsTest { } @Test - public void testContentEquals() { + void testContentEquals() { Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); @@ -308,7 +308,7 @@ public class CharsTest { } @Test - public void testSlice() { + void testSlice() { // slice is offset + length Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); // ----- @@ -318,7 +318,7 @@ public class CharsTest { } @Test - public void testSubsequence() { + void testSubsequence() { // subsequence is start + end Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); // ----- @@ -328,7 +328,7 @@ public class CharsTest { } @Test - public void testSubstring() { + void testSubstring() { // substring is start + end Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); // ----- @@ -339,7 +339,7 @@ public class CharsTest { @Test - public void testTrimBlankLines() { + void testTrimBlankLines() { assertTrimBlankLinesEquals(" \n \n abc \n \n de \n \n ", " abc \n \n de "); assertTrimBlankLinesEquals("", ""); @@ -352,7 +352,7 @@ public class CharsTest { @Test - public void testReaderSingleChars() throws IOException { + void testReaderSingleChars() throws IOException { Chars bc = Chars.wrap("a \n \r\nbc db").slice(1, 9); // ------------ @@ -371,7 +371,7 @@ public class CharsTest { } @Test - public void testReaderBuffer() throws IOException { + void testReaderBuffer() throws IOException { Chars bc = Chars.wrap("a \n \r\nbc db").slice(1, 9); // ------------ @@ -389,7 +389,7 @@ public class CharsTest { } @Test - public void testReaderSlicedBuffer() throws IOException { + void testReaderSlicedBuffer() throws IOException { Chars bc = Chars.wrap("a \n \r\nbc db").slice(1, 9); // ------------ @@ -408,7 +408,7 @@ public class CharsTest { } @Test - public void testReadClosed() throws IOException { + void testReadClosed() throws IOException { Chars bc = Chars.wrap("a \n \r\nbc db").slice(1, 9); // ------------ @@ -418,7 +418,7 @@ public class CharsTest { } @Test - public void testReaderMark() throws IOException { + void testReaderMark() throws IOException { Chars bc = Chars.wrap("abcdefghijklmnop").slice(1, 9); // ------------ @@ -448,7 +448,7 @@ public class CharsTest { } @Test - public void testReaderMissingMark() throws IOException { + void testReaderMissingMark() throws IOException { Chars bc = Chars.wrap("abcdefghijklmnop").slice(1, 9); // ------------ @@ -461,7 +461,7 @@ public class CharsTest { } @Test - public void testReaderSkip() throws IOException { + void testReaderSkip() throws IOException { Chars bc = Chars.wrap("abcdefghijklmnop").slice(1, 9); // ------------ @@ -485,7 +485,7 @@ public class CharsTest { } @Test - public void testReaderInvalidParams() throws IOException { + void testReaderInvalidParams() throws IOException { Chars bc = Chars.wrap("abcdefghijklmnop").slice(1, 9); // ------------ char[] cbuf = new char[4]; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileLocationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileLocationTest.java index a583a70adc..e3d90fb99b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileLocationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileLocationTest.java @@ -5,18 +5,18 @@ package net.sourceforge.pmd.lang.document; import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; -import org.hamcrest.MatcherAssert; import org.junit.jupiter.api.Test; /** * @author Clément Fournier */ -public class FileLocationTest { +class FileLocationTest { @Test - public void testSimple() { + void testSimple() { FileLocation loc = FileLocation.range("fname", TextRange2d.range2d(1, 1, 1, 2)); assertEquals("fname", loc.getFileName()); assertEquals(1, loc.getStartLine()); @@ -26,14 +26,14 @@ public class FileLocationTest { } @Test - public void testToRange() { + void testToRange() { TextRange2d range2d = TextRange2d.range2d(1, 1, 1, 2); FileLocation loc = FileLocation.range("fname", range2d); assertEquals(range2d, loc.toRange2d()); } @Test - public void testToString() { + void testToString() { FileLocation loc = FileLocation.range("fname", TextRange2d.range2d(1, 1, 1, 2)); assertEquals( @@ -45,7 +45,7 @@ public class FileLocationTest { loc.startPosToStringWithFile() ); - MatcherAssert.assertThat(loc.toString(), containsString("!debug only!")); + assertThat(loc.toString(), containsString("!debug only!")); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SourceCodePositionerTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SourceCodePositionerTest.java index 5b7c2dc7aa..7a48aced91 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SourceCodePositionerTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SourceCodePositionerTest.java @@ -12,10 +12,10 @@ import org.junit.jupiter.api.Test; /** * Unit test for {@link SourceCodePositioner}. */ -public class SourceCodePositionerTest { +class SourceCodePositionerTest { @Test - public void testLineNumberFromOffset() { + void testLineNumberFromOffset() { final String source = "abcd\ndefghi\n\rjklmn\ropq"; SourceCodePositioner positioner = SourceCodePositioner.create(source); @@ -48,7 +48,7 @@ public class SourceCodePositionerTest { } @Test - public void testOffsetFromLineColumn() { + void testOffsetFromLineColumn() { final String source = "abcd\ndefghi\r\njklmn\nopq"; SourceCodePositioner positioner = SourceCodePositioner.create(source); @@ -71,7 +71,7 @@ public class SourceCodePositionerTest { @Test - public void testWrongOffsets() { + void testWrongOffsets() { final String source = "abcd\ndefghi\r\njklmn\nopq"; SourceCodePositioner positioner = SourceCodePositioner.create(source); @@ -89,7 +89,7 @@ public class SourceCodePositionerTest { @Test - public void testEmptyDocument() { + void testEmptyDocument() { SourceCodePositioner positioner = SourceCodePositioner.create(""); @@ -105,7 +105,7 @@ public class SourceCodePositionerTest { } @Test - public void testDocumentStartingWithNl() { + void testDocumentStartingWithNl() { SourceCodePositioner positioner = SourceCodePositioner.create("\n"); @@ -121,7 +121,7 @@ public class SourceCodePositionerTest { @Test - public void lineToOffsetMappingWithLineFeedShouldSucceed() { + void lineToOffsetMappingWithLineFeedShouldSucceed() { final String code = "public static int main(String[] args) {\n" + "int var;\n" + "}"; @@ -132,7 +132,7 @@ public class SourceCodePositionerTest { } @Test - public void lineToOffsetMappingWithCarriageReturnFeedLineFeedShouldSucceed() { + void lineToOffsetMappingWithCarriageReturnFeedLineFeedShouldSucceed() { final String code = "public static int main(String[] args) {\r\n" + "int var;\r\n" + "}"; @@ -143,7 +143,7 @@ public class SourceCodePositionerTest { } @Test - public void lineToOffsetMappingWithMixedLineSeparatorsShouldSucceed() { + void lineToOffsetMappingWithMixedLineSeparatorsShouldSucceed() { final String code = "public static int main(String[] args) {\r\n" + "int var;\n" + "}"; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java index 78e85c4503..08e3edab7a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java @@ -6,26 +6,23 @@ package net.sourceforge.pmd.lang.document; import static net.sourceforge.pmd.PmdCoreTestUtils.dummyVersion; import static net.sourceforge.pmd.lang.document.TextPos2d.pos2d; -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 org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.util.IOUtil; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -@RunWith(JUnitParamsRunner.class) -public class TextDocumentTest { +class TextDocumentTest { @Test - public void testSingleLineRegion() { + void testSingleLineRegion() { TextDocument doc = TextDocument.readOnlyString("bonjour\ntristesse", dummyVersion()); TextRegion region = TextRegion.fromOffsetLength(0, "bonjour".length()); @@ -44,7 +41,7 @@ public class TextDocumentTest { } @Test - public void testRegionAtEol() { + void testRegionAtEol() { TextDocument doc = TextDocument.readOnlyString("bonjour\ntristesse", dummyVersion()); TextRegion region = TextRegion.fromOffsetLength(0, "bonjour\n".length()); @@ -59,7 +56,7 @@ public class TextDocumentTest { } @Test - public void testEmptyRegionAtEol() { + void testEmptyRegionAtEol() { TextDocument doc = TextDocument.readOnlyString("bonjour\ntristesse", dummyVersion()); // ^ The caret position right after the \n // We consider it's part of the next line @@ -76,7 +73,7 @@ public class TextDocumentTest { } @Test - public void testRegionForEol() { + void testRegionForEol() { TextDocument doc = TextDocument.readOnlyString("bonjour\ntristesse", dummyVersion()); // [ [ The region containing the \n // We consider it ends on the same line, not the next one @@ -94,7 +91,7 @@ public class TextDocumentTest { } @Test - public void testRegionAtEndOfFile() { + void testRegionAtEndOfFile() { TextDocument doc = TextDocument.readOnlyString("flemme", dummyVersion()); TextRegion region = TextRegion.fromOffsetLength(0, doc.getLength()); @@ -109,7 +106,7 @@ public class TextDocumentTest { } @Test - public void testMultiLineRegion() { + void testMultiLineRegion() { TextDocument doc = TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion()); TextRegion region = TextRegion.fromOffsetLength("bonjou".length(), "r\noha\ntri".length()); @@ -128,7 +125,7 @@ public class TextDocumentTest { @Test - public void testLineColumnFromOffset() { + void testLineColumnFromOffset() { TextDocument doc = TextDocument.readOnlyString("ab\ncd\n", dummyVersion()); assertPos2dEqualsAt(doc, 0, "a", pos2d(1, 1), true); @@ -151,7 +148,7 @@ public class TextDocumentTest { } @Test - public void testEmptyRegion() { + void testEmptyRegion() { TextDocument doc = TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion()); TextRegion region = TextRegion.fromOffsetLength("bonjour".length(), 0); @@ -170,7 +167,7 @@ public class TextDocumentTest { @Test - public void testLineRange() { + void testLineRange() { TextDocument doc = TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion()); assertEquals(Chars.wrap("bonjour\n"), doc.sliceTranslatedText(doc.createLineRange(1, 1))); @@ -182,46 +179,40 @@ public class TextDocumentTest { assertThrows(IndexOutOfBoundsException.class, () -> doc.createLineRange(0, 2)); } - @Test - @Parameters(source = DocumentsProvider.class) - public void testEntireRegion(TextDocument doc) { - assertEquals("getEntireRegion should return something based on length", - TextRegion.fromOffsetLength(0, doc.getLength()), - doc.getEntireRegion()); + @ParameterizedTest + @MethodSource("documentProvider") + void testEntireRegion(TextDocument doc) { + assertEquals(TextRegion.fromOffsetLength(0, doc.getLength()), + doc.getEntireRegion(), + "getEntireRegion should return something based on length"); } - @Test - @Parameters(source = DocumentsProvider.class) - public void testReader(TextDocument doc) throws IOException { + @ParameterizedTest + @MethodSource("documentProvider") + void testReader(TextDocument doc) throws IOException { - assertEquals("NewReader should read the text", - doc.getText().toString(), - IOUtil.readToString(doc.newReader()) - ); + assertEquals(doc.getText().toString(), + IOUtil.readToString(doc.newReader()), + "NewReader should read the text"); } @Test - public void testRegionOutOfBounds() { + void testRegionOutOfBounds() { TextDocument doc = TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion()); assertThrows(AssertionError.class, () -> TextRegion.isValidRegion(0, 40, doc)); } - // for junit params runner - public static final class DocumentsProvider { - - - @SuppressWarnings("resource") - public static Object[] provideParameters() { - LanguageVersion dummyVersion = DummyLanguageModule.getInstance().getDefaultVersion(); - return new TextDocument[] { - TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion), - TextDocument.readOnlyString("bonjour\n", dummyVersion), - TextDocument.readOnlyString("\n", dummyVersion), - TextDocument.readOnlyString("", dummyVersion), - }; - } + @SuppressWarnings("resource") + static Object[] documentProvider() { + LanguageVersion dummyVersion = DummyLanguageModule.getInstance().getDefaultVersion(); + return new TextDocument[] { + TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion), + TextDocument.readOnlyString("bonjour\n", dummyVersion), + TextDocument.readOnlyString("\n", dummyVersion), + TextDocument.readOnlyString("", dummyVersion), + }; } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFileContentTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFileContentTest.java index 136a9f4f5f..6773dbfd64 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFileContentTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFileContentTest.java @@ -4,137 +4,132 @@ package net.sourceforge.pmd.lang.document; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.StringReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -@RunWith(JUnitParamsRunner.class) -public class TextFileContentTest { +class TextFileContentTest { // in real life it's System.lineSeparator() // to make the class more testable (and avoid some test failures being hidden depending on the platform), // we use this dummy value private static final String LINESEP_SENTINEL = ":fallback:"; - @Rule - public ExpectedException expect = ExpectedException.none(); - - @Test - @Parameters(source = TextContentOrigin.class) - public void testMixedDelimiters(TextContentOrigin origin) throws IOException { + @ParameterizedTest + @EnumSource + void testMixedDelimiters(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("a\r\nb\n\rc"); - Assert.assertEquals(Chars.wrap("a\nb\n\nc"), content.getNormalizedText()); - Assert.assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); + assertEquals(Chars.wrap("a\nb\n\nc"), content.getNormalizedText()); + assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); } - @Test - @Parameters(source = TextContentOrigin.class) - public void testFormFeedIsNotNewline(TextContentOrigin origin) throws IOException { + @ParameterizedTest + @EnumSource + void testFormFeedIsNotNewline(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("a\f\nb\nc"); - Assert.assertEquals(Chars.wrap("a\f\nb\nc"), content.getNormalizedText()); - Assert.assertEquals("\n", content.getLineTerminator()); + assertEquals(Chars.wrap("a\f\nb\nc"), content.getNormalizedText()); + assertEquals("\n", content.getLineTerminator()); } @Test - public void testNormTextPreservation() { + void testNormTextPreservation() { Chars input = Chars.wrap("a\nb\nc"); TextFileContent content = TextFileContent.fromCharSeq(input); - Assert.assertSame(input, content.getNormalizedText()); - Assert.assertEquals("\n", content.getLineTerminator()); + assertSame(input, content.getNormalizedText()); + assertEquals("\n", content.getLineTerminator()); } - @Test - @Parameters(source = TextContentOrigin.class) - public void testBomElimination(TextContentOrigin origin) throws IOException { + @ParameterizedTest + @EnumSource + void testBomElimination(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("\ufeffabc"); Chars normalizedText = content.getNormalizedText(); - Assert.assertEquals(Chars.wrap("abc"), normalizedText); + assertEquals(Chars.wrap("abc"), normalizedText); // This means the string underlying the Chars does not start with the bom marker. // It's useful for performance to have `textDocument.getText().toString()` be O(1), // and not create a new string. - Assert.assertTrue("should be full string", normalizedText.isFullString()); - Assert.assertSame(normalizedText.toString(), normalizedText.toString()); + assertTrue(normalizedText.isFullString(), "should be full string"); + assertSame(normalizedText.toString(), normalizedText.toString()); } - @Test - @Parameters(source = TextContentOrigin.class) - public void testNoExplicitLineMarkers(TextContentOrigin origin) throws IOException { + @ParameterizedTest + @EnumSource + void testNoExplicitLineMarkers(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("a"); - Assert.assertEquals(Chars.wrap("a"), content.getNormalizedText()); - Assert.assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); + assertEquals(Chars.wrap("a"), content.getNormalizedText()); + assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); } - @Test - @Parameters(source = TextContentOrigin.class) - public void testEmptyFile(TextContentOrigin origin) throws IOException { + @ParameterizedTest + @EnumSource + void testEmptyFile(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize(""); - Assert.assertEquals(Chars.wrap(""), content.getNormalizedText()); - Assert.assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); + assertEquals(Chars.wrap(""), content.getNormalizedText()); + assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); } @Test - public void testCrlfSplitOnBuffer() throws IOException { + void testCrlfSplitOnBuffer() throws IOException { StringReader reader = new StringReader("a\r\nb"); // now the buffer is of size 2, so we read first [a\r] then [\nb] // but there is a single line TextFileContent content = TextFileContent.normalizingRead(reader, 2, System.lineSeparator()); - Assert.assertEquals(Chars.wrap("a\nb"), content.getNormalizedText()); - Assert.assertEquals("\r\n", content.getLineTerminator()); + assertEquals(Chars.wrap("a\nb"), content.getNormalizedText()); + assertEquals("\r\n", content.getLineTerminator()); } @Test - public void testCrSplitOnBufferFp() throws IOException { + void testCrSplitOnBufferFp() throws IOException { StringReader reader = new StringReader("a\rb\n"); // the buffer is of size 2, so we read first [a\r] then [b\n] // the \r is a line terminator on its own TextFileContent content = TextFileContent.normalizingRead(reader, 2, LINESEP_SENTINEL); - Assert.assertEquals(Chars.wrap("a\nb\n"), content.getNormalizedText()); - Assert.assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); + assertEquals(Chars.wrap("a\nb\n"), content.getNormalizedText()); + assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); } - @Test - @Parameters(source = TextContentOrigin.class) - public void testCrCr(TextContentOrigin origin) throws IOException { + @ParameterizedTest + @EnumSource + void testCrCr(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("a\r\rb"); - Assert.assertEquals(Chars.wrap("a\n\nb"), content.getNormalizedText()); - Assert.assertEquals("\r", content.getLineTerminator()); + assertEquals(Chars.wrap("a\n\nb"), content.getNormalizedText()); + assertEquals("\r", content.getLineTerminator()); } - @Test - @Parameters(source = TextContentOrigin.class) - public void testCrIsEol(TextContentOrigin origin) throws IOException { + @ParameterizedTest + @EnumSource + void testCrIsEol(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("a\rb\rdede"); - Assert.assertEquals(Chars.wrap("a\nb\ndede"), content.getNormalizedText()); - Assert.assertEquals("\r", content.getLineTerminator()); + assertEquals(Chars.wrap("a\nb\ndede"), content.getNormalizedText()); + assertEquals("\r", content.getLineTerminator()); } - @Test - @Parameters(source = TextContentOrigin.class) - public void testLfAtStartOfFile(TextContentOrigin origin) throws IOException { + @ParameterizedTest + @EnumSource + void testLfAtStartOfFile(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("\nohio"); - Assert.assertEquals(Chars.wrap("\nohio"), content.getNormalizedText()); - Assert.assertEquals("\n", content.getLineTerminator()); + assertEquals(Chars.wrap("\nohio"), content.getNormalizedText()); + assertEquals("\n", content.getLineTerminator()); } @Test - public void testCrCrSplitBuffer() throws IOException { + void testCrCrSplitBuffer() throws IOException { StringReader reader = new StringReader("a\r\r"); // the buffer is of size 2, so we read first [a\r] then [\ro] // the \r is not a line terminator though TextFileContent content = TextFileContent.normalizingRead(reader, 2, LINESEP_SENTINEL); - Assert.assertEquals(Chars.wrap("a\n\n"), content.getNormalizedText()); - Assert.assertEquals("\r", content.getLineTerminator()); + assertEquals(Chars.wrap("a\n\n"), content.getNormalizedText()); + assertEquals("\r", content.getLineTerminator()); } enum TextContentOrigin { @@ -164,10 +159,5 @@ public class TextFileContentTest { }; abstract TextFileContent normalize(String input) throws IOException; - - // for junitParams - public static Object[] provideParameters() { - return values(); - } } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFilesTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFilesTest.java index 0d0effe48b..e76b2870b9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFilesTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFilesTest.java @@ -5,12 +5,12 @@ package net.sourceforge.pmd.lang.document; import static net.sourceforge.pmd.PmdCoreTestUtils.dummyVersion; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.BufferedWriter; import java.io.IOException; @@ -20,22 +20,21 @@ import java.nio.file.Files; import java.nio.file.Path; import org.checkerframework.checker.nullness.qual.NonNull; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.util.datasource.DataSource; import net.sourceforge.pmd.util.datasource.FileDataSource; -public class TextFilesTest { +class TextFilesTest { - @Rule - public TemporaryFolder tempDir = TemporaryFolder.builder().build(); + @TempDir + Path tempDir; @Test - public void testNioFile() throws IOException { + void testNioFile() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); try (TextFile tf = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { assertEquals(file.toAbsolutePath().toString(), tf.getPathId()); @@ -46,7 +45,7 @@ public class TextFilesTest { } @Test - public void testEquals() throws IOException { + void testEquals() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content").toAbsolutePath(); try (TextFile tf = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { try (TextFile tfPrime = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { @@ -71,7 +70,7 @@ public class TextFilesTest { } @Test - public void testStringDataSourceCompat() throws IOException { + void testStringDataSourceCompat() throws IOException { DataSource ds = DataSource.forString("text", "filename.dummy"); PMDConfiguration config = new PMDConfiguration(); try (TextFile tf = TextFile.dataSourceCompat(ds, config)) { @@ -83,7 +82,7 @@ public class TextFilesTest { } @Test - public void testFileDataSourceCompat() throws IOException { + void testFileDataSourceCompat() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); DataSource ds = new FileDataSource(file.toFile()); @@ -97,7 +96,7 @@ public class TextFilesTest { } @Test - public void testFileDataSourceCompatWithEncoding() throws IOException { + void testFileDataSourceCompatWithEncoding() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_16BE, "some content"); DataSource ds = new FileDataSource(file.toFile()); @@ -116,11 +115,11 @@ public class TextFilesTest { } @Test - public void testNioFileWrite() throws IOException { + void testNioFileWrite() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); try (TextFile tf = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { assertEquals(Chars.wrap("some content"), tf.readContents().getNormalizedText()); - assertFalse("readonly", tf.isReadOnly()); + assertFalse(tf.isReadOnly(), "readonly"); // write with CRLF tf.writeContents( @@ -142,11 +141,11 @@ public class TextFilesTest { } @Test - public void testNioFileExplicitReadOnly() throws IOException { + void testNioFileExplicitReadOnly() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); try (TextFile tf = TextFile.builderForPath(file, StandardCharsets.UTF_8, dummyVersion()) .asReadOnly().build()) { - assertTrue("readonly", tf.isReadOnly()); + assertTrue(tf.isReadOnly(), "readonly"); assertThrows(ReadOnlyFileException.class, () -> tf.writeContents( TextFileContent.fromCharSeq("new content") @@ -155,7 +154,7 @@ public class TextFilesTest { } @Test - public void testNioFileCanBeReadMultipleTimes() throws IOException { + void testNioFileCanBeReadMultipleTimes() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); try (TextFile tf = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { assertEquals(Chars.wrap("some content"), tf.readContents().getNormalizedText()); @@ -164,7 +163,7 @@ public class TextFilesTest { } @Test - public void testNioFileBuilder() throws IOException { + void testNioFileBuilder() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); try (TextFile tf = TextFile.builderForPath(file, StandardCharsets.UTF_8, dummyVersion()) .withDisplayName("aname") @@ -177,7 +176,7 @@ public class TextFilesTest { } @Test - public void testNioFileEscape() throws IOException { + void testNioFileEscape() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some\r\ncontent"); try (TextFile tf = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { assertEquals(Chars.wrap("some\ncontent"), tf.readContents().getNormalizedText()); @@ -185,7 +184,7 @@ public class TextFilesTest { } @Test - public void testReaderFile() throws IOException { + void testReaderFile() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some\r\ncontent"); try (TextFile tf = TextFile.forReader(Files.newBufferedReader(file, StandardCharsets.UTF_8), "filename", dummyVersion())) { assertEquals("filename", tf.getPathId()); @@ -196,10 +195,10 @@ public class TextFilesTest { } @Test - public void testReaderFileIsReadOnly() throws IOException { + void testReaderFileIsReadOnly() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some\r\ncontent"); try (TextFile tf = TextFile.forReader(Files.newBufferedReader(file, StandardCharsets.UTF_8), "filename", dummyVersion())) { - assertTrue("readonly", tf.isReadOnly()); + assertTrue(tf.isReadOnly(), "readonly"); assertThrows(ReadOnlyFileException.class, () -> tf.writeContents( TextFileContent.fromCharSeq("new content") )); @@ -207,7 +206,7 @@ public class TextFilesTest { } @Test - public void testStringFileEscape() throws IOException { + void testStringFileEscape() throws IOException { try (TextFile tf = TextFile.forCharSeq("cont\r\nents", "filename", dummyVersion())) { assertEquals("filename", tf.getPathId()); assertEquals("filename", tf.getDisplayName()); @@ -220,7 +219,7 @@ public class TextFilesTest { } @Test - public void testStringFileCanBeReadMultipleTimes() throws IOException { + void testStringFileCanBeReadMultipleTimes() throws IOException { try (TextFile tf = TextFile.forCharSeq("contents", "filename", dummyVersion())) { assertEquals(Chars.wrap("contents"), tf.readContents().getNormalizedText()); assertEquals(Chars.wrap("contents"), tf.readContents().getNormalizedText()); @@ -229,9 +228,9 @@ public class TextFilesTest { } @Test - public void testStringFileIsReadonly() throws IOException { + void testStringFileIsReadonly() throws IOException { try (TextFile tf = TextFile.forCharSeq("contents", "filename", dummyVersion())) { - assertTrue("readonly", tf.isReadOnly()); + assertTrue(tf.isReadOnly(), "readonly"); assertThrows(ReadOnlyFileException.class, () -> tf.writeContents( TextFileContent.fromCharSeq("new content") )); @@ -239,7 +238,7 @@ public class TextFilesTest { } private @NonNull Path makeTmpFile(Charset charset, String content) throws IOException { - Path file = tempDir.newFile().toPath(); + Path file = Files.createTempFile(tempDir, null, null); try (BufferedWriter writer = Files.newBufferedWriter(file, charset)) { writer.write(content); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextPos2dTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextPos2dTest.java index 7b4e6165f9..fec89d5b21 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextPos2dTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextPos2dTest.java @@ -5,19 +5,19 @@ package net.sourceforge.pmd.lang.document; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; -import org.hamcrest.MatcherAssert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Clément Fournier */ -public class TextPos2dTest { +class TextPos2dTest { @Test - public void testToString() { + void testToString() { TextPos2d pos = TextPos2d.pos2d(1, 2); assertEquals( "line 1, column 2", @@ -31,11 +31,11 @@ public class TextPos2dTest { "(line=1, column=2)", pos.toTupleString() ); - MatcherAssert.assertThat(pos.toString(), containsString("!debug only!")); + assertThat(pos.toString(), containsString("!debug only!")); } @Test - public void testEquals() { + void testEquals() { TextPos2d pos = TextPos2d.pos2d(1, 1); TextPos2d pos2 = TextPos2d.pos2d(1, 2); assertNotEquals(pos, pos2); @@ -44,7 +44,7 @@ public class TextPos2dTest { } @Test - public void testCompareTo() { + void testCompareTo() { TextPos2d pos = TextPos2d.pos2d(1, 1); TextPos2d pos2 = TextPos2d.pos2d(1, 2); TextPos2d pos3 = TextPos2d.pos2d(2, 1); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRange2dTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRange2dTest.java index ed5f067fd8..4f9df557c2 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRange2dTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRange2dTest.java @@ -5,26 +5,26 @@ package net.sourceforge.pmd.lang.document; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; -import org.hamcrest.MatcherAssert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Clément Fournier */ -public class TextRange2dTest { +class TextRange2dTest { @Test - public void testCtors() { + void testCtors() { TextRange2d pos = TextRange2d.range2d(1, 2, 3, 4); TextRange2d pos2 = TextRange2d.range2d(TextPos2d.pos2d(1, 2), TextPos2d.pos2d(3, 4)); assertEquals(pos, pos2); } @Test - public void testEquals() { + void testEquals() { TextRange2d pos = TextRange2d.range2d(1, 1, 1, 1); TextRange2d pos2 = TextRange2d.range2d(1, 1, 1, 2); assertNotEquals(pos, pos2); @@ -33,7 +33,7 @@ public class TextRange2dTest { } @Test - public void testCompareTo() { + void testCompareTo() { TextRange2d pos = TextRange2d.range2d(1, 1, 1, 1); TextRange2d pos2 = TextRange2d.range2d(1, 1, 1, 2); @@ -43,13 +43,13 @@ public class TextRange2dTest { } @Test - public void testToString() { + void testToString() { TextRange2d range = TextRange2d.range2d(1, 2, 3, 4); assertEquals( "1:2-3:4", range.toDisplayStringWithColon() ); - MatcherAssert.assertThat(range.toString(), containsString("!debug only!")); + assertThat(range.toString(), containsString("!debug only!")); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRegionTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRegionTest.java index 33e4b56a29..3f989a9435 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRegionTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRegionTest.java @@ -4,37 +4,33 @@ package net.sourceforge.pmd.lang.document; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; -public class TextRegionTest { - - @Rule - public ExpectedException expect = ExpectedException.none(); +class TextRegionTest { @Test - public void testIsEmpty() { + void testIsEmpty() { TextRegion r = TextRegion.fromOffsetLength(0, 0); assertTrue(r.isEmpty()); } @Test - public void testEmptyContains() { + void testEmptyContains() { TextRegion r1 = TextRegion.fromOffsetLength(0, 0); assertFalse(r1.contains(0)); } @Test - public void testContains() { + void testContains() { TextRegion r1 = TextRegion.fromOffsetLength(1, 2); assertFalse(r1.contains(0)); @@ -44,7 +40,7 @@ public class TextRegionTest { } @Test - public void testIntersectZeroLen() { + void testIntersectZeroLen() { // r1: [[----- // r2: [ -----[ TextRegion r1 = TextRegion.fromOffsetLength(0, 0); @@ -56,7 +52,7 @@ public class TextRegionTest { } @Test - public void testIntersectZeroLen2() { + void testIntersectZeroLen2() { // r1: -----[[ // r2: [-----[ TextRegion r1 = TextRegion.fromOffsetLength(5, 0); @@ -68,7 +64,7 @@ public class TextRegionTest { } @Test - public void testIntersectZeroLen3() { + void testIntersectZeroLen3() { // r1: -- -[---[ // r2: --[-[--- TextRegion r1 = TextRegion.fromOffsetLength(3, 3); @@ -82,7 +78,7 @@ public class TextRegionTest { @Test - public void testIntersectZeroLen4() { + void testIntersectZeroLen4() { TextRegion r1 = TextRegion.fromOffsetLength(0, 0); TextRegion inter = doIntersect(r1, r1); @@ -91,7 +87,7 @@ public class TextRegionTest { } @Test - public void testNonEmptyIntersect() { + void testNonEmptyIntersect() { // r1: ---[-- --[ // r2: [--- --[-- // i: ---[--[-- @@ -104,7 +100,7 @@ public class TextRegionTest { } @Test - public void testIntersectContained() { + void testIntersectContained() { // r1: --[- - ---[ // r2: -- -[-[--- // i: -- -[-[--- @@ -117,7 +113,7 @@ public class TextRegionTest { } @Test - public void testIntersectDisjoint() { + void testIntersectDisjoint() { // r1: -- -[---[ // r2: --[-[--- TextRegion r1 = TextRegion.fromOffsetLength(4, 3); @@ -127,7 +123,7 @@ public class TextRegionTest { } @Test - public void testOverlapContained() { + void testOverlapContained() { // r1: --[- - ---[ // r2: -- -[-[--- // i: -- -[-[--- @@ -138,7 +134,7 @@ public class TextRegionTest { } @Test - public void testOverlapDisjoint() { + void testOverlapDisjoint() { // r1: -- -[---[ // r2: --[-[--- TextRegion r1 = TextRegion.fromOffsetLength(4, 3); @@ -149,7 +145,7 @@ public class TextRegionTest { @Test - public void testOverlapBoundary() { + void testOverlapBoundary() { // r1: -- -[---[ // r2: --[-[--- TextRegion r1 = TextRegion.fromOffsetLength(3, 3); @@ -159,7 +155,7 @@ public class TextRegionTest { } @Test - public void testCompare() { + void testCompare() { // r1: --[-[--- // r2: -- -[---[ TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -169,7 +165,7 @@ public class TextRegionTest { } @Test - public void testCompareSameOffset() { + void testCompareSameOffset() { // r1: [-[-- // r2: [- --[ TextRegion r1 = TextRegion.fromOffsetLength(0, 1); @@ -180,7 +176,7 @@ public class TextRegionTest { @Test - public void testUnion() { + void testUnion() { // r1: --[-[--- // r2: -- -[---[ TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -192,7 +188,7 @@ public class TextRegionTest { } @Test - public void testUnionDisjoint() { + void testUnionDisjoint() { // r1: --[-[- --- // r2: -- ---[---[ TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -204,7 +200,7 @@ public class TextRegionTest { } @Test - public void testGrowLeft() { + void testGrowLeft() { // r1: --[-[- // r2: [-- -[- TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -215,7 +211,7 @@ public class TextRegionTest { } @Test - public void testGrowLeftNegative() { + void testGrowLeftNegative() { // r1: --[- [- // r2: -- -[[- TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -226,16 +222,15 @@ public class TextRegionTest { } @Test - public void testGrowLeftOutOfBounds() { + void testGrowLeftOutOfBounds() { // r1: --[-[- TextRegion r1 = TextRegion.fromOffsetLength(2, 1); - expect.expect(AssertionError.class); - r1.growLeft(4); + assertThrows(AssertionError.class, () -> r1.growLeft(4)); } @Test - public void testGrowRight() { + void testGrowRight() { // r1: --[-[- // r2: --[- -[ TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -246,7 +241,7 @@ public class TextRegionTest { } @Test - public void testGrowRightNegative() { + void testGrowRightNegative() { // r1: --[ -[- // r2: --[[- - TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -257,39 +252,38 @@ public class TextRegionTest { } @Test - public void testGrowRightOutOfBounds() { + void testGrowRightOutOfBounds() { // r1: --[-[- TextRegion r1 = TextRegion.fromOffsetLength(2, 1); - expect.expect(AssertionError.class); - r1.growRight(-2); + assertThrows(AssertionError.class, () -> r1.growRight(-2)); } - public void assertRegionEquals(TextRegion region, int start, int len) { - assertEquals("Start offset", start, region.getStartOffset()); - assertEquals("Length", len, region.getLength()); + private static void assertRegionEquals(TextRegion region, int start, int len) { + assertEquals(start, region.getStartOffset(), "Start offset"); + assertEquals(len, region.getLength(), "Length"); } - public void assertIsBefore(TextRegion r1, TextRegion r2) { - assertTrue("Region " + r1 + " should be before " + r2, r1.compareTo(r2) < 0); - assertTrue("Region " + r2 + " should be after " + r1, r2.compareTo(r1) > 0); + private static void assertIsBefore(TextRegion r1, TextRegion r2) { + assertTrue(r1.compareTo(r2) < 0, "Region " + r1 + " should be before " + r2); + assertTrue(r2.compareTo(r1) > 0, "Region " + r2 + " should be after " + r1); } - private void assertNoOverlap(TextRegion r1, TextRegion r2) { - assertFalse("Regions " + r1 + " and " + r2 + " should not overlap", r1.overlaps(r2)); + private static void assertNoOverlap(TextRegion r1, TextRegion r2) { + assertFalse(r1.overlaps(r2), "Regions " + r1 + " and " + r2 + " should not overlap"); } - private void assertOverlap(TextRegion r1, TextRegion r2) { - assertTrue("Regions " + r1 + " and " + r2 + " should overlap", r1.overlaps(r2)); + private static void assertOverlap(TextRegion r1, TextRegion r2) { + assertTrue(r1.overlaps(r2), "Regions " + r1 + " and " + r2 + " should overlap"); } private TextRegion doIntersect(TextRegion r1, TextRegion r2) { TextRegion inter = TextRegion.intersect(r1, r2); - assertNotNull("Intersection of " + r1 + " and " + r2 + " must exist", inter); + assertNotNull(inter, "Intersection of " + r1 + " and " + r2 + " must exist"); TextRegion symmetric = TextRegion.intersect(r2, r1); - assertEquals("Intersection of " + r1 + " and " + r2 + " must be symmetric", inter, symmetric); + assertEquals(inter, symmetric, "Intersection of " + r1 + " and " + r2 + " must be symmetric"); return inter; } @@ -297,20 +291,20 @@ public class TextRegionTest { private TextRegion doUnion(TextRegion r1, TextRegion r2) { TextRegion union = TextRegion.union(r1, r2); - assertTrue("Union of " + r1 + " and " + r2 + " must contain first region", union.contains(r1)); - assertTrue("Union of " + r1 + " and " + r2 + " must contain second region", union.contains(r2)); + assertTrue(union.contains(r1), "Union of " + r1 + " and " + r2 + " must contain first region"); + assertTrue(union.contains(r2), "Union of " + r1 + " and " + r2 + " must contain second region"); TextRegion symmetric = TextRegion.union(r2, r1); - assertEquals("Union of " + r1 + " and " + r2 + " must be symmetric", union, symmetric); + assertEquals(union, symmetric, "Union of " + r1 + " and " + r2 + " must be symmetric"); return union; } private void noIntersect(TextRegion r1, TextRegion r2) { TextRegion inter = TextRegion.intersect(r1, r2); - assertNull("Intersection of " + r1 + " and " + r2 + " must not exist", inter); + assertNull(inter, "Intersection of " + r1 + " and " + r2 + " must not exist"); TextRegion symmetric = TextRegion.intersect(r2, r1); - assertEquals("Intersection of " + r1 + " and " + r2 + " must be symmetric", inter, symmetric); + assertEquals(inter, symmetric, "Intersection of " + r1 + " and " + r2 + " must be symmetric"); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/CollectionUtilTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/CollectionUtilTest.java index 08234fe50c..d64e633066 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/CollectionUtilTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/CollectionUtilTest.java @@ -5,22 +5,22 @@ package net.sourceforge.pmd.util; import static net.sourceforge.pmd.util.CollectionUtil.listOf; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.document.Chars; /** * @author Clément Fournier */ -public class CollectionUtilTest { +class CollectionUtilTest { @Test - public void testJoinOn() { + void testJoinOn() { testJoinOn(listOf("a", "b", "c"), ".", "a.b.c"); testJoinOn(Collections.emptyList(), ".", diff --git a/pmd-cpp/pom.xml b/pmd-cpp/pom.xml index 06093bc6d9..beb01403db 100644 --- a/pmd-cpp/pom.xml +++ b/pmd-cpp/pom.xml @@ -74,8 +74,8 @@
- junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/pmd-cpp/src/test/java/net/sourceforge/pmd/cpd/CPPTokenizerTest.java b/pmd-cpp/src/test/java/net/sourceforge/pmd/cpd/CPPTokenizerTest.java index 899f7f3af8..b4746b7f64 100644 --- a/pmd-cpp/src/test/java/net/sourceforge/pmd/cpd/CPPTokenizerTest.java +++ b/pmd-cpp/src/test/java/net/sourceforge/pmd/cpd/CPPTokenizerTest.java @@ -4,17 +4,17 @@ package net.sourceforge.pmd.cpd; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest; -public class CPPTokenizerTest extends CpdTextComparisonTest { +class CPPTokenizerTest extends CpdTextComparisonTest { - public CPPTokenizerTest() { + CPPTokenizerTest() { super(".cpp"); } @@ -36,106 +36,106 @@ public class CPPTokenizerTest extends CpdTextComparisonTest { } @Test - public void testUTFwithBOM() { + void testUTFwithBOM() { Tokenizer tokenizer = newTokenizer(dontSkipBlocks()); Tokens tokens = tokenize(tokenizer, "\ufeffint start()\n{ int ret = 1;\nreturn ret;\n}\n"); assertEquals(15, tokens.size()); } @Test - public void testContinuation() { + void testContinuation() { doTest("continuation"); } @Test - public void testContinuationInIdent() { + void testContinuationInIdent() { doTest("continuation_intra_token"); } @Test - public void testContinuationBetweenTokens() { + void testContinuationBetweenTokens() { doTest("continuation_inter_token"); } @Test - public void testUnicodeStringSupport() { + void testUnicodeStringSupport() { doTest("unicodeStrings"); } @Test - public void testIgnoreBetweenSpecialComments() { + void testIgnoreBetweenSpecialComments() { doTest("specialComments"); } @Test - public void testMultiLineMacros() { + void testMultiLineMacros() { doTest("multilineMacros"); } @Test - public void testIdentifierValidChars() { + void testIdentifierValidChars() { doTest("identifierChars"); } @Test - public void testWrongUnicodeInIdentifier() { + void testWrongUnicodeInIdentifier() { expectTokenMgrError(" void main() { int ⚜ = __; }"); } @Test - public void testTokenizerWithSkipBlocks() { + void testTokenizerWithSkipBlocks() { doTest("simpleSkipBlocks", "_skipDefault", skipBlocks()); } @Test - public void testTokenizerWithSkipBlocksPattern() { + void testTokenizerWithSkipBlocksPattern() { doTest("simpleSkipBlocks", "_skipDebug", skipBlocks("#if debug|#endif")); } @Test - public void testTokenizerWithoutSkipBlocks() { + void testTokenizerWithoutSkipBlocks() { doTest("simpleSkipBlocks", "_noSkip", dontSkipBlocks()); } @Test - public void testAsm() { + void testAsm() { // ASM code containing the '@' character doTest("asm", "", dontSkipBlocks()); } @Test - public void testPreprocessingDirectives() { + void testPreprocessingDirectives() { doTest("preprocessorDirectives"); } @Test - public void testLiterals() { + void testLiterals() { doTest("literals"); } @Test - public void testLexicalErrorFilename() { + void testLexicalErrorFilename() { expectTokenMgrError(sourceText("issue-1559"), dontSkipBlocks()); } @Test - public void testRawStringLiterals() { + void testRawStringLiterals() { doTest("issue-1784"); } @Test - public void testTabWidth() { + void testTabWidth() { doTest("tabWidth"); } @Test - public void testLongListsOfNumbersAreNotIgnored() { + void testLongListsOfNumbersAreNotIgnored() { doTest("listOfNumbers"); } @Test - public void testLongListsOfNumbersAreIgnored() { + void testLongListsOfNumbersAreIgnored() { doTest("listOfNumbers", "_ignored", skipLiteralSequences()); } diff --git a/pmd-cpp/src/test/java/net/sourceforge/pmd/cpd/CppCharStreamTest.java b/pmd-cpp/src/test/java/net/sourceforge/pmd/cpd/CppCharStreamTest.java index 64f4315fd7..3546db9e6c 100644 --- a/pmd-cpp/src/test/java/net/sourceforge/pmd/cpd/CppCharStreamTest.java +++ b/pmd-cpp/src/test/java/net/sourceforge/pmd/cpd/CppCharStreamTest.java @@ -4,19 +4,19 @@ package net.sourceforge.pmd.cpd; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import org.checkerframework.checker.nullness.qual.NonNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream; import net.sourceforge.pmd.lang.document.CpdCompat; import net.sourceforge.pmd.lang.document.TextDocument; import net.sourceforge.pmd.lang.document.TextFile; -public class CppCharStreamTest { +class CppCharStreamTest { @NonNull public CharStream charStreamFor(String source) throws IOException { @@ -25,20 +25,20 @@ public class CppCharStreamTest { } @Test - public void testContinuationUnix() throws IOException { + void testContinuationUnix() throws IOException { CharStream stream = charStreamFor("a\\\nb"); assertStream(stream, "ab"); } @Test - public void testContinuationWindows() throws IOException { + void testContinuationWindows() throws IOException { // note that the \r is normalized to a \n by the TextFile CharStream stream = charStreamFor("a\\\r\nb"); assertStream(stream, "ab"); } @Test - public void testBackup() throws IOException { + void testBackup() throws IOException { // note that the \r is normalized to a \n by the TextFile CharStream stream = charStreamFor("a\\b\\qc"); assertStream(stream, "a\\b\\qc"); @@ -49,7 +49,7 @@ public class CppCharStreamTest { assertEquals(token.charAt(0), c); for (int i = 1; i < token.length(); i++) { c = stream.readChar(); - assertEquals(token + " char at " + i + ": " + token.charAt(i) + " != " + c, token.charAt(i), c); + assertEquals(token.charAt(i), c, token + " char at " + i + ": " + token.charAt(i) + " != " + c); } assertEquals(token, stream.getTokenImage()); // StringBuilder sb = new StringBuilder(); diff --git a/pmd-cs/pom.xml b/pmd-cs/pom.xml index d003846560..4af69e4c3c 100644 --- a/pmd-cs/pom.xml +++ b/pmd-cs/pom.xml @@ -63,8 +63,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/pmd-cs/src/test/java/net/sourceforge/pmd/cpd/CsTokenizerTest.java b/pmd-cs/src/test/java/net/sourceforge/pmd/cpd/CsTokenizerTest.java index d05797d726..0901187e79 100644 --- a/pmd-cs/src/test/java/net/sourceforge/pmd/cpd/CsTokenizerTest.java +++ b/pmd-cs/src/test/java/net/sourceforge/pmd/cpd/CsTokenizerTest.java @@ -4,20 +4,18 @@ package net.sourceforge.pmd.cpd; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.Properties; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest; import net.sourceforge.pmd.lang.ast.TokenMgrError; -public class CsTokenizerTest extends CpdTextComparisonTest { +class CsTokenizerTest extends CpdTextComparisonTest { - @org.junit.Rule - public ExpectedException ex = ExpectedException.none(); - - public CsTokenizerTest() { + CsTokenizerTest() { super(".cs"); } @@ -34,84 +32,83 @@ public class CsTokenizerTest extends CpdTextComparisonTest { } @Test - public void testSimpleClass() { + void testSimpleClass() { doTest("simpleClass"); } @Test - public void testSimpleClassMethodMultipleLines() { + void testSimpleClassMethodMultipleLines() { doTest("simpleClassMethodMultipleLines"); } @Test - public void testStrings() { + void testStrings() { doTest("strings"); } @Test - public void testOpenString() { - ex.expect(TokenMgrError.class); - doTest("unlexable_string"); + void testOpenString() { + assertThrows(TokenMgrError.class, () -> doTest("unlexable_string")); } @Test - public void testCommentsIgnored1() { + void testCommentsIgnored1() { doTest("comments"); } @Test - public void testIgnoreBetweenSpecialComments() { + void testIgnoreBetweenSpecialComments() { doTest("specialComments"); } @Test - public void testOperators() { + void testOperators() { doTest("operatorsAndStuff"); } @Test - public void testLineNumberAfterMultilineString() { + void testLineNumberAfterMultilineString() { doTest("strings"); } @Test - public void testDoNotIgnoreUsingDirectives() { + void testDoNotIgnoreUsingDirectives() { doTest("usingDirectives"); } @Test - public void testIgnoreUsingDirectives() { + void testIgnoreUsingDirectives() { doTest("usingDirectives", "_ignored", ignoreUsings()); } @Test - public void testTabWidth() { + void testTabWidth() { doTest("tabWidth"); } @Test - public void testLongListsOfNumbersAreNotIgnored() { + void testLongListsOfNumbersAreNotIgnored() { doTest("listOfNumbers"); } @Test - public void testLongListsOfNumbersAreIgnored() { + void testLongListsOfNumbersAreIgnored() { doTest("listOfNumbers", "_ignored", skipLiteralSequences()); } @Test - public void testCSharp7And8Additions() { + void testCSharp7And8Additions() { doTest("csharp7And8Additions"); } @Test - public void testAttributesAreNotIgnored() { + void testAttributesAreNotIgnored() { doTest("attributes"); } @Test - public void testAttributesAreIgnored() { + void testAttributesAreIgnored() { doTest("attributes", "_ignored", skipAttributes()); } diff --git a/pmd-dart/pom.xml b/pmd-dart/pom.xml index 0c8af18fe3..dede831b74 100644 --- a/pmd-dart/pom.xml +++ b/pmd-dart/pom.xml @@ -62,8 +62,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java b/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java index 93231d4b26..5d08b1b849 100644 --- a/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java +++ b/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java @@ -6,13 +6,13 @@ package net.sourceforge.pmd.cpd; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest; -public class DartTokenizerTest extends CpdTextComparisonTest { +class DartTokenizerTest extends CpdTextComparisonTest { - public DartTokenizerTest() { + DartTokenizerTest() { super(".dart"); } @@ -23,75 +23,75 @@ public class DartTokenizerTest extends CpdTextComparisonTest { @Test - public void testComment() { + void testComment() { doTest("comment"); } @Test - public void testEscapeSequences() { + void testEscapeSequences() { doTest("escape_sequences"); } @Test - public void testEscapedBackslash() { + void testEscapedBackslash() { doTest("escaped_backslash"); } @Test - public void testEscapedString() { + void testEscapedString() { doTest("escaped_string"); } @Test - public void testIncrement() { + void testIncrement() { doTest("increment"); } @Test - public void testImports() { + void testImports() { doTest("imports"); } @Test - public void testStringInterpolation() { + void testStringInterpolation() { doTest("string_interpolation"); } @Test - public void testEscapedDollar() { + void testEscapedDollar() { doTest("escaped_dollar"); } @Test - public void testRegex() { + void testRegex() { doTest("regex"); } @Test - public void testRegex2() { + void testRegex2() { doTest("regex2"); } @Test - public void testRegex3() { + void testRegex3() { doTest("regex3"); } @Test - public void testStringWithBackslashes() { + void testStringWithBackslashes() { doTest("string_with_backslashes"); } @Test - public void testMultiline() { + void testMultiline() { doTest("string_multiline"); } @Test - public void testTabWidth() { + void testTabWidth() { doTest("tabWidth"); } diff --git a/pmd-dist/pom.xml b/pmd-dist/pom.xml index 8bd93b1d3d..ed647fd309 100644 --- a/pmd-dist/pom.xml +++ b/pmd-dist/pom.xml @@ -299,6 +299,11 @@ commons-lang3 + + org.junit.jupiter + junit-jupiter + test + junit junit diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/AbstractBinaryDistributionTest.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/AbstractBinaryDistributionTest.java index d45bcd7cd6..5162c6f7dc 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/AbstractBinaryDistributionTest.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/AbstractBinaryDistributionTest.java @@ -5,23 +5,24 @@ package net.sourceforge.pmd.it; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.PMDVersion; -public abstract class AbstractBinaryDistributionTest { +abstract class AbstractBinaryDistributionTest { public static final String PMD_BIN_PREFIX = "pmd-bin-"; protected static File getBinaryDistribution() { return new File(".", "target/" + PMD_BIN_PREFIX + PMDVersion.VERSION + ".zip"); } - @ClassRule - public static TemporaryFolder folder = new TemporaryFolder(); + @TempDir + static Path folder; /** * The temporary directory, to which the binary distribution will be extracted. @@ -29,9 +30,13 @@ public abstract class AbstractBinaryDistributionTest { */ protected static Path tempDir; - @BeforeClass - public static void setupTempDirectory() throws Exception { - tempDir = folder.newFolder().toPath(); + protected Path createTemporaryReportFile() throws IOException { + return Files.createTempFile(folder, null, null); + } + + @BeforeAll + static void setupTempDirectory() throws Exception { + tempDir = Files.createTempDirectory(folder, null); if (getBinaryDistribution().exists()) { ZipFileExtractor.extractZipFile(getBinaryDistribution().toPath(), tempDir); } diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/AllRulesIT.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/AllRulesIT.java index bc1ab661b8..74faa00fbc 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/AllRulesIT.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/AllRulesIT.java @@ -7,30 +7,24 @@ package net.sourceforge.pmd.it; import java.io.File; import java.util.Arrays; -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.MethodSource; -@RunWith(Parameterized.class) -public class AllRulesIT extends AbstractBinaryDistributionTest { +class AllRulesIT extends AbstractBinaryDistributionTest { - @Parameter - public String language; - @Parameters - public static Iterable languagesToTest() { + static Iterable languagesToTest() { // note: scala and wsdl have no rules return Arrays.asList("java", "apex", "html", "javascript", "jsp", "modelica", "plsql", "pom", "visualforce", "velocitytemplate", "xml", "xsl"); } - @Test - public void runRuleTests() throws Exception { + @ParameterizedTest + @MethodSource("languagesToTest") + void runRuleTests(String language) throws Exception { String srcDir = new File(".", "src/test/resources/sample-source/" + language + "/").getAbsolutePath(); - ExecutionResult result = PMDExecutor.runPMDRules(folder.newFile().toPath(), tempDir, srcDir, + ExecutionResult result = PMDExecutor.runPMDRules(createTemporaryReportFile(), tempDir, srcDir, "src/test/resources/rulesets/all-" + language + ".xml"); assertDefaultExecutionResult(result); } diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java index 2c840d2487..78114cb84e 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java @@ -15,9 +15,9 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.concurrent.TimeUnit; -import org.apache.commons.lang3.SystemUtils; -import org.junit.Assume; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; import net.sourceforge.pmd.PMDVersion; import net.sourceforge.pmd.util.IOUtil; @@ -28,12 +28,11 @@ import net.sourceforge.pmd.util.IOUtil; *

* See How to trick an application into thinking its stdout is a terminal, not a pipe. */ -public class AntIT extends AbstractBinaryDistributionTest { +class AntIT extends AbstractBinaryDistributionTest { @Test - public void runAnt() throws IOException, InterruptedException { - Assume.assumeTrue(SystemUtils.IS_OS_LINUX); - + @EnabledOnOs(OS.LINUX) + void runAnt() throws IOException, InterruptedException { String antBasepath = new File("target/ant").getAbsolutePath(); String pmdHome = tempDir.resolve(PMD_BIN_PREFIX + PMDVersion.VERSION).toAbsolutePath().toString(); File antTestProjectFolder = prepareAntTestProjectFolder(); @@ -46,7 +45,7 @@ public class AntIT extends AbstractBinaryDistributionTest { private File prepareAntTestProjectFolder() throws IOException { final Path sourceProjectFolder = new File("src/test/resources/ant-it").toPath(); - final Path projectFolder = folder.newFolder().toPath(); + final Path projectFolder = Files.createTempDirectory(folder, null); Files.walkFileTree(sourceProjectFolder, new SimpleFileVisitor() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java index 6397e56050..44fbb3fbce 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java @@ -4,8 +4,8 @@ package net.sourceforge.pmd.it; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.File; import java.io.IOException; @@ -15,11 +15,11 @@ import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import org.junit.Test; +import org.junit.jupiter.api.Test; import net.sourceforge.pmd.PMDVersion; -public class BinaryDistributionIT extends AbstractBinaryDistributionTest { +class BinaryDistributionIT extends AbstractBinaryDistributionTest { private static final String SUPPORTED_LANGUAGES_CPD; private static final String SUPPORTED_LANGUAGES_PMD; @@ -44,7 +44,7 @@ public class BinaryDistributionIT extends AbstractBinaryDistributionTest { private final String srcDir = new File(".", "src/test/resources/sample-source/java/").getAbsolutePath(); @Test - public void testFileExistence() { + void testFileExistence() { assertTrue(getBinaryDistribution().exists()); } @@ -63,7 +63,7 @@ public class BinaryDistributionIT extends AbstractBinaryDistributionTest { } @Test - public void testZipFileContent() throws IOException { + void testZipFileContent() throws IOException { Set expectedFileNames = getExpectedFileNames(); ZipFile zip = new ZipFile(getBinaryDistribution()); @@ -82,65 +82,65 @@ public class BinaryDistributionIT extends AbstractBinaryDistributionTest { } @Test - public void testPmdJavaQuickstart() throws Exception { - ExecutionResult result = PMDExecutor.runPMDRules(folder.newFile().toPath(), tempDir, srcDir, "rulesets/java/quickstart.xml"); + void testPmdJavaQuickstart() throws Exception { + ExecutionResult result = PMDExecutor.runPMDRules(createTemporaryReportFile(), tempDir, srcDir, "rulesets/java/quickstart.xml"); result.assertExecutionResult(4, ""); } @Test - public void testPmdXmlFormat() throws Exception { - ExecutionResult result = PMDExecutor.runPMDRules(folder.newFile().toPath(), tempDir, srcDir, "src/test/resources/rulesets/sample-ruleset.xml", "xml"); + void testPmdXmlFormat() throws Exception { + ExecutionResult result = PMDExecutor.runPMDRules(createTemporaryReportFile(), tempDir, srcDir, "src/test/resources/rulesets/sample-ruleset.xml", "xml"); result.assertExecutionResult(4, "", "JumbledIncrementer.java\">"); result.assertExecutionResult(4, "", " exclusions = new HashSet<>(); exclusions.add(BASE_PATH + "/.ci/files/id_rsa"); exclusions.add(BASE_PATH + "/.ci/files/private-env"); @@ -38,7 +38,7 @@ public class SourceDistributionIT { List files = ZipFileExtractor.readZipFile(getSourceDistribution().toPath()); for (String file : files) { - Assert.assertFalse("File " + file + " must not be included", exclusions.contains(file)); + assertFalse(exclusions.contains(file), "File " + file + " must not be included"); } } } diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java index dbfe2d13a5..609dde0e44 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.it; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.FileOutputStream; diff --git a/pmd-doc/pom.xml b/pmd-doc/pom.xml index 132c2cd552..45b7773695 100644 --- a/pmd-doc/pom.xml +++ b/pmd-doc/pom.xml @@ -96,6 +96,11 @@ snakeyaml + + org.junit.jupiter + junit-jupiter + test + junit junit diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/EscapeUtilsTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/EscapeUtilsTest.java index 7e06c58574..439a9f41bc 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/EscapeUtilsTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/EscapeUtilsTest.java @@ -4,17 +4,17 @@ package net.sourceforge.pmd.docs; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class EscapeUtilsTest { +class EscapeUtilsTest { @Test - public void testEscapeMarkdown() { + void testEscapeMarkdown() { assertEquals("This is a \\\\backslash", EscapeUtils.escapeMarkdown("This is a \\backslash")); assertEquals("This \"\\*\" is not a emphasis", EscapeUtils.escapeMarkdown("This \"*\" is not a emphasis")); assertEquals("This \"\\*\\*\" is not a strong style", EscapeUtils.escapeMarkdown("This \"**\" is not a strong style")); @@ -25,7 +25,7 @@ public class EscapeUtilsTest { } @Test - public void testEscapeHtmlWithinMarkdownSingleLine() { + void testEscapeHtmlWithinMarkdownSingleLine() { assertEquals("a <script> tag outside of `