Skip to content
Permalink
Browse files

Issue checkstyle#6916: migrate tests to junit5 for naming package

  • Loading branch information
pbludov committed Dec 4, 2019
1 parent 3c8c50d commit 05b58ce2d1f17b3d112c08cff602b3685f601d50
Showing with 79 additions and 81 deletions.
  1. +1 −1 config/import-control-test.xml
  2. +1 −1 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java
  3. +4 −4 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java
  4. +6 −6 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheckTest.java
  5. +5 −5 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheckTest.java
  6. +11 −12 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheckTest.java
  7. +6 −6 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheckTest.java
  8. +4 −4 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheckTest.java
  9. +5 −6 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java
  10. +4 −4 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheckTest.java
  11. +5 −5 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckTest.java
  12. +5 −5 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java
  13. +6 −6 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodTypeParameterNameCheckTest.java
  14. +5 −5 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java
  15. +5 −5 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java
  16. +5 −5 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheckTest.java
  17. +1 −1 src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java
@@ -23,7 +23,7 @@
<subpackage name="(coding|design|header|imports|indentation|javadoc)" regex="true">
<allow pkg="org.junit"/>
</subpackage>
<subpackage name="(naming|regexp|sizes|whitespace)" regex="true">
<subpackage name="(regexp|sizes|whitespace)" regex="true">
<allow pkg="org.junit"/>
</subpackage>
</subpackage>
@@ -21,7 +21,7 @@

import static com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck.MSG_KEY;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -21,9 +21,9 @@

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractClassNameCheck.MSG_ILLEGAL_ABSTRACT_CLASS_NAME;
import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractClassNameCheck.MSG_NO_ABSTRACT_CLASS_MODIFIER;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -131,7 +131,7 @@ public void testGetAcceptableTokens() {
final int[] expected = {
TokenTypes.CLASS_DEF,
};
Assert.assertArrayEquals("Invalid acceptable tokens", expected, actual);
assertArrayEquals(expected, actual, "Invalid acceptable tokens");
}

@Test
@@ -141,7 +141,7 @@ public void testGetRequiredTokens() {
final int[] expected = {
TokenTypes.CLASS_DEF,
};
Assert.assertArrayEquals("Invalid required tokens", expected, actual);
assertArrayEquals(expected, actual, "Invalid required tokens");
}

}
@@ -20,9 +20,9 @@
package com.puppycrawl.tools.checkstyle.checks.naming;

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -42,10 +42,10 @@ public void testTokens() {
final CatchParameterNameCheck catchParameterNameCheck = new CatchParameterNameCheck();
final int[] expected = {TokenTypes.PARAMETER_DEF};

assertArrayEquals("Default required tokens are invalid",
expected, catchParameterNameCheck.getRequiredTokens());
assertArrayEquals("Default acceptable tokens are invalid",
expected, catchParameterNameCheck.getAcceptableTokens());
assertArrayEquals(expected, catchParameterNameCheck.getRequiredTokens(),
"Default required tokens are invalid");
assertArrayEquals(expected, catchParameterNameCheck.getAcceptableTokens(),
"Default acceptable tokens are invalid");
}

@Test
@@ -20,9 +20,9 @@
package com.puppycrawl.tools.checkstyle.checks.naming;

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -41,8 +41,8 @@ public void testGetClassRequiredTokens() {
final ClassTypeParameterNameCheck checkObj =
new ClassTypeParameterNameCheck();
final int[] expected = {TokenTypes.TYPE_PARAMETER};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
assertArrayEquals(expected, checkObj.getRequiredTokens(),
"Default required tokens are invalid");
}

@Test
@@ -85,7 +85,7 @@ public void testGetAcceptableTokens() {
final int[] expected = {
TokenTypes.TYPE_PARAMETER,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
assertArrayEquals(expected, actual, "Default acceptable tokens are invalid");
}

}
@@ -20,12 +20,12 @@
package com.puppycrawl.tools.checkstyle.checks.naming;

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -45,8 +45,8 @@ protected String getPackageLocation() {
public void testGetRequiredTokens() {
final ConstantNameCheck checkObj = new ConstantNameCheck();
final int[] expected = {TokenTypes.VARIABLE_DEF};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
assertArrayEquals(expected, checkObj.getRequiredTokens(),
"Default required tokens are invalid");
}

@Test
@@ -60,12 +60,11 @@ public void testIllegalRegexp()
fail("CheckstyleException is expected");
}
catch (CheckstyleException ex) {
assertEquals("Invalid exception message",
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
assertEquals("cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "cannot initialize module com.puppycrawl.tools.checkstyle.checks."
+ "naming.ConstantNameCheck - "
+ "illegal value '\\' for property 'format'",
ex.getMessage());
ex.getMessage(), "Invalid exception message");
}
}

@@ -161,8 +160,8 @@ public void testGetAcceptableTokens() {
final int[] expected = {
TokenTypes.VARIABLE_DEF,
};
Assert.assertNotNull("Default acceptable should not be null", actual);
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
assertNotNull(actual, "Default acceptable should not be null");
assertArrayEquals(expected, actual, "Default acceptable tokens are invalid");
}

}
@@ -20,9 +20,9 @@
package com.puppycrawl.tools.checkstyle.checks.naming;

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -42,17 +42,17 @@ public void testGetAcceptableTokens() {
new InterfaceTypeParameterNameCheck();
final int[] expected = {TokenTypes.TYPE_PARAMETER};

assertArrayEquals("Default acceptable tokens are invalid",
expected, interfaceTypeParameterNameCheck.getAcceptableTokens());
assertArrayEquals(expected, interfaceTypeParameterNameCheck.getAcceptableTokens(),
"Default acceptable tokens are invalid");
}

@Test
public void testGetRequiredTokens() {
final InterfaceTypeParameterNameCheck checkObj =
new InterfaceTypeParameterNameCheck();
final int[] expected = {TokenTypes.TYPE_PARAMETER};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
assertArrayEquals(expected, checkObj.getRequiredTokens(),
"Default required tokens are invalid");
}

@Test
@@ -20,9 +20,9 @@
package com.puppycrawl.tools.checkstyle.checks.naming;

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -43,7 +43,7 @@ public void testGetRequiredTokens() {

final LambdaParameterNameCheck check = new LambdaParameterNameCheck();
final int[] requiredTokens = check.getRequiredTokens();
Assert.assertArrayEquals("Invalid required tokens", expected, requiredTokens);
assertArrayEquals(expected, requiredTokens, "Invalid required tokens");
}

@Test
@@ -54,7 +54,7 @@ public void testAcceptableTokens() {

final LambdaParameterNameCheck check = new LambdaParameterNameCheck();
final int[] acceptableTokens = check.getAcceptableTokens();
Assert.assertArrayEquals("Invalid acceptable tokens", expected, acceptableTokens);
assertArrayEquals(expected, acceptableTokens, "Invalid acceptable tokens");
}

@Test
@@ -20,9 +20,9 @@
package com.puppycrawl.tools.checkstyle.checks.naming;

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -41,9 +41,8 @@ protected String getPackageLocation() {
public void testGetRequiredTokens() {
final LocalFinalVariableNameCheck checkObj =
new LocalFinalVariableNameCheck();
assertArrayEquals(
"LocalFinalVariableNameCheck#getRequiredTokens should return empty array by default",
CommonUtil.EMPTY_INT_ARRAY, checkObj.getRequiredTokens());
assertArrayEquals(CommonUtil.EMPTY_INT_ARRAY, checkObj.getRequiredTokens(),
"LocalFinalVariableNameCheck#getRequiredTokens should return empty array by default");
}

@Test
@@ -94,7 +93,7 @@ public void testGetAcceptableTokens() {
TokenTypes.PARAMETER_DEF,
TokenTypes.RESOURCE,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
assertArrayEquals(expected, actual, "Default acceptable tokens are invalid");
}

@Test
@@ -20,9 +20,9 @@
package com.puppycrawl.tools.checkstyle.checks.naming;

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -42,8 +42,8 @@ public void testGetAcceptableTokens() {
final LocalVariableNameCheck localVariableNameCheck = new LocalVariableNameCheck();
final int[] expected = {TokenTypes.VARIABLE_DEF};

assertArrayEquals("Default acceptable tokens are invalid",
expected, localVariableNameCheck.getAcceptableTokens());
assertArrayEquals(expected, localVariableNameCheck.getAcceptableTokens(),
"Default acceptable tokens are invalid");
}

@Test
@@ -20,9 +20,9 @@
package com.puppycrawl.tools.checkstyle.checks.naming;

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -40,8 +40,8 @@ protected String getPackageLocation() {
public void testGetRequiredTokens() {
final MemberNameCheck checkObj = new MemberNameCheck();
final int[] expected = {TokenTypes.VARIABLE_DEF};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
assertArrayEquals(expected, checkObj.getRequiredTokens(),
"Default required tokens are invalid");
}

@Test
@@ -243,7 +243,7 @@ public void testGetAcceptableTokens() {
final int[] expected = {
TokenTypes.VARIABLE_DEF,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
assertArrayEquals(expected, actual, "Default acceptable tokens are invalid");
}

}
@@ -21,9 +21,9 @@

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import static com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck.MSG_KEY;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -42,8 +42,8 @@ protected String getPackageLocation() {
public void testGetRequiredTokens() {
final MethodNameCheck checkObj = new MethodNameCheck();
final int[] expected = {TokenTypes.METHOD_DEF};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
assertArrayEquals(expected, checkObj.getRequiredTokens(),
"Default required tokens are invalid");
}

@Test
@@ -176,7 +176,7 @@ public void testGetAcceptableTokens() {
final int[] expected = {
TokenTypes.METHOD_DEF,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
assertArrayEquals(expected, actual, "Default acceptable tokens are invalid");
}

}
@@ -20,9 +20,9 @@
package com.puppycrawl.tools.checkstyle.checks.naming;

import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
@@ -42,17 +42,17 @@ public void testGetAcceptableTokens() {
new MethodTypeParameterNameCheck();
final int[] expected = {TokenTypes.TYPE_PARAMETER};

assertArrayEquals("Default acceptable tokens are invalid",
expected, methodTypeParameterNameCheck.getAcceptableTokens());
assertArrayEquals(expected, methodTypeParameterNameCheck.getAcceptableTokens(),
"Default acceptable tokens are invalid");
}

@Test
public void testGetRequiredTokens() {
final MethodTypeParameterNameCheck checkObj =
new MethodTypeParameterNameCheck();
final int[] expected = {TokenTypes.TYPE_PARAMETER};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
assertArrayEquals(expected, checkObj.getRequiredTokens(),
"Default required tokens are invalid");
}

@Test

0 comments on commit 05b58ce

Please sign in to comment.
You can’t perform that action at this time.