Make test classes and methods package-private

This commit is contained in:
Andreas Dangel 2023-01-17 15:41:31 +01:00
parent d5b3478c8a
commit c23ecab2c6
No known key found for this signature in database
GPG Key ID: 25FE002491A5E1FE
16 changed files with 52 additions and 58 deletions

View File

@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test;
class ApexCommentTest extends ApexParserTestBase {
@Test
public void testContainsComment1() {
void testContainsComment1() {
ASTApexFile file = apex.parse("class Foo {void foo(){try {\n"
+ "} catch (Exception e) {\n"
+ " /* OK: block comment inside of empty catch block; should not be reported */\n"

View File

@ -94,7 +94,7 @@ class ApexQualifiedNameTest extends ApexParserTestBase {
@Test
public void testUnqualifiedEnum() {
void testUnqualifiedEnum() {
ASTUserEnum root = (ASTUserEnum) parse("public enum primaryColor { RED, YELLOW, BLUE }");
ApexQualifiedName enumQName = root.getQualifiedName();
@ -107,7 +107,7 @@ class ApexQualifiedNameTest extends ApexParserTestBase {
}
@Test
public void testQualifiedEnum() {
void testQualifiedEnum() {
ASTUserClass root = (ASTUserClass) parse("public class Outer { public enum Inner { OK } }");
ASTUserEnum enumNode = root.descendants(ASTUserEnum.class).firstOrThrow();

View File

@ -15,7 +15,7 @@ import net.sourceforge.pmd.RuleSetLoader;
class PMD5RulesetTest {
@Test
public void loadRuleset() {
void loadRuleset() {
RuleSet ruleset = new RuleSetLoader().loadFromResource("net/sourceforge/pmd/lang/java/pmd5ruleset.xml");
assertNotNull(ruleset);
assertNull(ruleset.getRuleByName("GuardLogStatementJavaUtil"));

View File

@ -33,7 +33,7 @@ class JDKVersionTest extends BaseJavaTreeDumpTest {
// enum keyword/identifier
@Test
public void testEnumAsKeywordShouldFailWith14() {
void testEnumAsKeywordShouldFailWith14() {
assertThrows(ParseException.class, () -> java5.parseResource("jdk14_enum.java"));
}
@ -89,17 +89,17 @@ class JDKVersionTest extends BaseJavaTreeDumpTest {
}
@Test
public void testGenericCtorCalls() {
void testGenericCtorCalls() {
java5.parseResource("java5/generic_ctors.java");
}
@Test
public void testGenericSuperCtorCalls() {
void testGenericSuperCtorCalls() {
java5.parseResource("java5/generic_super_ctor.java");
}
@Test
public void testAnnotArrayInitializer() {
void testAnnotArrayInitializer() {
java5.parseResource("java5/annotation_array_init.java");
}
@ -237,7 +237,7 @@ class JDKVersionTest extends BaseJavaTreeDumpTest {
}
@Test
public final void testTypeAnnotations() {
void testTypeAnnotations() {
java8.parseResource("java8/type_annotations.java");
}

View File

@ -21,10 +21,10 @@ import net.sourceforge.pmd.lang.java.BaseParserTest;
/**
* @author Clément Fournier
*/
public class JavaCommentTest extends BaseParserTest {
class JavaCommentTest extends BaseParserTest {
@Test
public void testFilteredLines() {
void testFilteredLines() {
JavaComment comment = parseComment(
"/**\n"
+ " * @author Clément Fournier\n"
@ -37,7 +37,7 @@ public class JavaCommentTest extends BaseParserTest {
}
@Test
public void testFilteredLinesKeepBlankLines() {
void testFilteredLinesKeepBlankLines() {
JavaComment comment = parseComment(
"/**\n"
+ " * @author Clément Fournier\n"
@ -56,7 +56,7 @@ public class JavaCommentTest extends BaseParserTest {
@Test
public void getLeadingComments() {
void getLeadingComments() {
ASTCompilationUnit parsed = java.parse("/** a */ class Fooo { /** b */ int field; }");
List<JavadocCommentOwner> docCommentOwners = parsed.descendants(JavadocCommentOwner.class).toList();

View File

@ -44,15 +44,11 @@ import net.sourceforge.pmd.lang.java.symbols.testdata.MethodAnnotation;
import net.sourceforge.pmd.lang.java.symbols.testdata.ParameterAnnotation;
import net.sourceforge.pmd.lang.java.symbols.testdata.SomeClass;
public class AnnotationReflectionTest {
public AnnotationReflectionTest() {
}
class AnnotationReflectionTest {
@ParameterizedTest
@EnumSource
public void testReflectionOfClassMethods(SymImplementation impl) {
void testReflectionOfClassMethods(SymImplementation impl) {
Class<SomeClass> actualClass = SomeClass.class;
JClassSymbol sym = impl.getSymbol(actualClass);
@ -62,7 +58,7 @@ public class AnnotationReflectionTest {
@ParameterizedTest
@EnumSource
public void testReflectionOfAnnotDefaults(SymImplementation impl) {
void testReflectionOfAnnotDefaults(SymImplementation impl) {
Class<AnnotWithDefaults> actualClass = AnnotWithDefaults.class;
JClassSymbol sym = impl.getSymbol(actualClass);
@ -72,7 +68,7 @@ public class AnnotationReflectionTest {
@ParameterizedTest
@EnumSource
public void testAnnotUseThatUsesDefaults(SymImplementation impl) {
void testAnnotUseThatUsesDefaults(SymImplementation impl) {
// note that as the annotation has retention class, we can't use reflection to check
/*
@ -100,7 +96,7 @@ public class AnnotationReflectionTest {
@ParameterizedTest
@EnumSource
public void testAnnotOnAnnot(SymImplementation impl) {
void testAnnotOnAnnot(SymImplementation impl) {
// This only checks for Target.ANNOTATION_TYPE annotations
Class<AnnotWithDefaults> actualClass = AnnotWithDefaults.class;
JClassSymbol sym = impl.getSymbol(actualClass);
@ -111,7 +107,7 @@ public class AnnotationReflectionTest {
@ParameterizedTest
@EnumSource
public void testAnnotOnParameter(SymImplementation impl) {
void testAnnotOnParameter(SymImplementation impl) {
// This only checks Target.PARAMETER annotations, do not confuse with TYPE_PARAMETER / TYPE_USE
Class<SomeClass> actualClass = SomeClass.class;
JClassSymbol sym = impl.getSymbol(actualClass);
@ -125,7 +121,7 @@ public class AnnotationReflectionTest {
@ParameterizedTest
@EnumSource
public void testAnnotOnField(SymImplementation impl) {
void testAnnotOnField(SymImplementation impl) {
// This only checks Target.FIELD annotations, do not confuse with TYPE_USE annotations
Class<SomeClass> actualClass = SomeClass.class;
JClassSymbol sym = impl.getSymbol(actualClass);
@ -136,7 +132,7 @@ public class AnnotationReflectionTest {
@ParameterizedTest
@EnumSource
public void testAnnotOnMethod(SymImplementation impl) {
void testAnnotOnMethod(SymImplementation impl) {
// This only checks Target.METHOD annotations, do not confuse with TYPE_USE on return types
Class<SomeClass> actualClass = SomeClass.class;
JClassSymbol sym = impl.getSymbol(actualClass);
@ -148,7 +144,7 @@ public class AnnotationReflectionTest {
@ParameterizedTest
@EnumSource
public void testAnnotOnConstructor(SymImplementation impl) {
void testAnnotOnConstructor(SymImplementation impl) {
// This only checks Target.CONSTRUCTOR annotations, do not confuse with TYPE_USE on return types
Class<SomeClass> actualClass = SomeClass.class;
JClassSymbol sym = impl.getSymbol(actualClass);
@ -158,7 +154,7 @@ public class AnnotationReflectionTest {
}
@Test
public void testAnnotOnLocalVar() {
void testAnnotOnLocalVar() {
// This only checks Target.LOCAL_VAR annotations, do not confuse with TYPE_USE on return types
JClassSymbol sym = SymImplementation.AST.getSymbol(SomeClass.class);
@ -172,7 +168,7 @@ public class AnnotationReflectionTest {
}
@Test
public void testAnnotWithInvalidType() {
void testAnnotWithInvalidType() {
@NonNull ASTVariableDeclaratorId field =
JavaParsingHelper.DEFAULT.parse(
"@interface A {}\n"

View File

@ -25,12 +25,12 @@ import net.sourceforge.pmd.lang.java.types.JMethodSig;
/**
*
*/
public class TypeAnnotReflectionOnMethodsTest {
class TypeAnnotReflectionOnMethodsTest {
@ParameterizedTest
@EnumSource
public void testTypeAnnotOnParameter(SymImplementation impl) {
void testTypeAnnotOnParameter(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsOnMethods.class);
/*
@ -54,7 +54,7 @@ public class TypeAnnotReflectionOnMethodsTest {
@ParameterizedTest
@EnumSource
public void testTypeAnnotOnReturn(SymImplementation impl) {
void testTypeAnnotOnReturn(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsOnMethods.class);
/*
@ -76,7 +76,7 @@ public class TypeAnnotReflectionOnMethodsTest {
@ParameterizedTest
@EnumSource
public void testTypeAnnotOnThrows(SymImplementation impl) {
void testTypeAnnotOnThrows(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsOnMethods.class);
/*
@ -92,7 +92,7 @@ public class TypeAnnotReflectionOnMethodsTest {
@ParameterizedTest
@EnumSource
public void testTypeAnnotOnTParam(SymImplementation impl) {
void testTypeAnnotOnTParam(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsOnMethods.class);
/*
@ -121,7 +121,7 @@ public class TypeAnnotReflectionOnMethodsTest {
@ParameterizedTest
@EnumSource
public void testTypeAnnotOnTParamBound(SymImplementation impl) {
void testTypeAnnotOnTParamBound(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsOnMethods.class);
/*
@ -157,7 +157,7 @@ public class TypeAnnotReflectionOnMethodsTest {
@ParameterizedTest
@EnumSource
public void testTypeAnnotOnReceiver(SymImplementation impl) {
void testTypeAnnotOnReceiver(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsOnMethods.class);
/*

View File

@ -28,12 +28,12 @@ import net.sourceforge.pmd.lang.java.types.JWildcardType;
/**
*
*/
public class TypeAnnotReflectionTest {
class TypeAnnotReflectionTest {
@ParameterizedTest
@EnumSource
public void testTypeAnnotsOnFields(SymImplementation impl) {
void testTypeAnnotsOnFields(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsInside.class);
@ -55,7 +55,7 @@ public class TypeAnnotReflectionTest {
@ParameterizedTest
@EnumSource
public void testArrayTypeAnnotsOnFields(SymImplementation impl) {
void testArrayTypeAnnotsOnFields(SymImplementation impl) {
/*
@ -105,7 +105,7 @@ public class TypeAnnotReflectionTest {
@ParameterizedTest
@EnumSource
public void testInnerTypeAnnotsOnFields(SymImplementation impl) {
void testInnerTypeAnnotsOnFields(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsInside.class);
@ -152,7 +152,7 @@ public class TypeAnnotReflectionTest {
@ParameterizedTest
@EnumSource
public void testInnerTypeAnnotsWithGenerics(SymImplementation impl) {
void testInnerTypeAnnotsWithGenerics(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsInside.class);
@ -205,7 +205,7 @@ public class TypeAnnotReflectionTest {
@ParameterizedTest
@EnumSource
public void testTypeAnnotOnMultipleGenericsAndInner(SymImplementation impl) {
void testTypeAnnotOnMultipleGenericsAndInner(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsInside.class);
@ -228,7 +228,7 @@ public class TypeAnnotReflectionTest {
@ParameterizedTest
@EnumSource
public void testTypeAnnotOnWildcards(SymImplementation impl) {
void testTypeAnnotOnWildcards(SymImplementation impl) {
JClassType sym = impl.getDeclaration(ClassWithTypeAnnotationsInside.class);

View File

@ -86,7 +86,7 @@ class AbruptCompletionTests extends BaseParserTest {
@Test
public void testWhileStmt() {
void testWhileStmt() {
assertAll(
canCompleteNormally("while(foo) { return; }"),
canCompleteNormally("while(foo) { break; }"),

View File

@ -8,10 +8,8 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.List;
import net.sourceforge.pmd.lang.java.symbols.internal.TypeAnnotReflectionTest;
/**
* See {@link TypeAnnotReflectionTest}.
* See {@link net.sourceforge.pmd.lang.java.symbols.internal.TypeAnnotReflectionTest}.
*
* @author Clément Fournier
*/

View File

@ -21,7 +21,7 @@ import net.sourceforge.pmd.lang.java.symbols.testdata.TypeAnnotation;
*
* @author Clément Fournier
*/
public class JClassSymbolTest {
class JClassSymbolTest {
@EnumSource
@ParameterizedTest

View File

@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test;
class ASTFunctionNodeTest extends EcmascriptParserTestBase {
@Test
public void testGetBody() {
void testGetBody() {
ASTAstRoot node = js.parse("function foo() { var a = 'a'; }");
ASTFunctionNode fn = node.getFirstDescendantOfType(ASTFunctionNode.class);
assertFalse(fn.isClosure());

View File

@ -41,12 +41,12 @@ class LuaTokenizerTest extends CpdTextComparisonTest {
}
@Test
public void testLuauTypes() {
void testLuauTypes() {
doTest("luauTypes");
}
@Test
public void testComment() {
void testComment() {
doTest("comment");
}
}

View File

@ -53,12 +53,12 @@ class MatlabTokenizerTest extends CpdTextComparisonTest {
}
@Test
public void testDoubleQuotedStrings() {
void testDoubleQuotedStrings() {
doTest("doubleQuotedStrings");
}
@Test
public void testTabWidth() {
void testTabWidth() {
doTest("tabWidth");
}
}

View File

@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class ASTExtractExpressionTest extends AbstractPLSQLParserTst {
class ASTExtractExpressionTest extends AbstractPLSQLParserTst {
@Test
void testXml() {

View File

@ -39,7 +39,7 @@ import net.sourceforge.pmd.lang.LanguageVersion;
* <p>For the parameters, see the constructor
* {@link TestDescriptor#TestDescriptor(String, String, String, LanguageVersion)}.</p>
*/
public class AbstractLanguageVersionTest {
public abstract class AbstractLanguageVersionTest {
public static class TestDescriptor {
private final String name;
@ -94,7 +94,7 @@ public class AbstractLanguageVersionTest {
*/
@ParameterizedTest
@MethodSource("data")
public void testFindVersionsForLanguageNameAndVersion(TestDescriptor testDescriptor) {
void testFindVersionsForLanguageNameAndVersion(TestDescriptor testDescriptor) {
SourceLanguage sourceLanguage = new SourceLanguage();
sourceLanguage.setName(testDescriptor.getName());
sourceLanguage.setVersion(testDescriptor.getVersion());
@ -116,7 +116,7 @@ public class AbstractLanguageVersionTest {
*/
@ParameterizedTest
@MethodSource("data")
public void testRegisteredRulesets(TestDescriptor testDescriptor) throws Exception {
void testRegisteredRulesets(TestDescriptor testDescriptor) throws Exception {
if (testDescriptor.getExpected() == null) {
return;
}
@ -140,7 +140,7 @@ public class AbstractLanguageVersionTest {
*/
@ParameterizedTest
@MethodSource("data")
public void testOldRegisteredRulesets(TestDescriptor testDescriptor) throws Exception {
void testOldRegisteredRulesets(TestDescriptor testDescriptor) throws Exception {
// only check for languages, that support rules
if (testDescriptor.getExpected() == null) {
return;
@ -160,7 +160,7 @@ public class AbstractLanguageVersionTest {
@ParameterizedTest
@MethodSource("data")
public void testVersionsAreDistinct(TestDescriptor testDescriptor) {
void testVersionsAreDistinct(TestDescriptor testDescriptor) {
LanguageVersion expected = testDescriptor.getExpected();
if (expected == null) {
return;