diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java index 26ab3683685..33aa0e844be 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java @@ -36,7 +36,10 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport { @Override protected String getPath(String filename) throws IOException { - return super.getPath("checks" + File.separator + filename); + return super.getPath("checks" + File.separator + + "misc" + File.separator + + "descendanttoken" + File.separator + + filename); } @Test @@ -45,7 +48,7 @@ public void testDefault() final DefaultConfiguration checkConfig = createCheckConfig(DescendantTokenCheck.class); final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("InputIllegalTokens.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected); } @Test @@ -59,7 +62,7 @@ public void testMaximumNumber() final String[] expected = { "17:12: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "LITERAL_NATIVE", "LITERAL_NATIVE"), }; - verify(checkConfig, getPath("InputIllegalTokens.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected); } @Test @@ -74,7 +77,7 @@ public void testMessage() final String[] expected = { "17:12: Using 'native' is not allowed.", }; - verify(checkConfig, getPath("InputIllegalTokens.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected); } @Test @@ -88,7 +91,7 @@ public void testMinimumNumber() final String[] expected = { "8:9: " + getCheckMessage(MSG_KEY_MIN, 1, 2, "LITERAL_SWITCH", "LITERAL_DEFAULT"), }; - verify(checkConfig, getPath("InputIllegalTokens.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected); } @Test @@ -101,7 +104,7 @@ public void testMinimumDepth() checkConfig.addAttribute("maximumNumber", "0"); checkConfig.addAttribute("minimumDepth", "3"); final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("InputIllegalTokens.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected); } @Test @@ -114,7 +117,7 @@ public void testMaximumDepth() checkConfig.addAttribute("maximumNumber", "0"); checkConfig.addAttribute("maximumDepth", "1"); final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("InputIllegalTokens.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected); } @Test @@ -147,7 +150,7 @@ public void testEmptyStatements() "75:10: Empty statement.", }; - verify(checkConfig, getPath("InputEmptyStatement.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenEmptyStatement.java"), expected); } @Test @@ -164,7 +167,7 @@ public void testMissingSwitchDefault() throws Exception { "17:9: switch without \"default\" clause.", }; - verify(checkConfig, getPath("InputMissingSwitchDefault.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenMissingSwitchDefault.java"), expected); } @Test @@ -183,7 +186,7 @@ public void testStringLiteralEquality() throws Exception { "12:20: Literal Strings should be compared using equals(), not '=='.", "17:22: Literal Strings should be compared using equals(), not '=='.", }; - verify(checkConfig, getPath("InputStringLiteralEquality.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenStringLiteralEquality.java"), expected); } @Test @@ -201,7 +204,7 @@ public void testIllegalTokenDefault() throws Exception { "11:18: Using 'POST_DEC' is not allowed.", "12:18: Using 'POST_INC' is not allowed.", }; - verify(checkConfig, getPath("InputIllegalTokens.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected); } @Test @@ -217,7 +220,7 @@ public void testIllegalTokenNative() throws Exception { final String[] expected = { "17:12: Using 'LITERAL_NATIVE' is not allowed.", }; - verify(checkConfig, getPath("InputIllegalTokens.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenIllegalTokens.java"), expected); } @Test @@ -234,7 +237,7 @@ public void testReturnFromCatch() throws Exception { "15:11: Return from catch is not allowed.", }; - verify(checkConfig, getPath("InputReturnFromCatch.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenReturnFromCatch.java"), expected); } @Test @@ -251,7 +254,7 @@ public void testReturnFromFinally() throws Exception { "15:11: Return from finally is not allowed.", }; - verify(checkConfig, getPath("InputReturnFromFinally.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected); } @Test @@ -265,7 +268,7 @@ public void testNoSum() throws Exception { final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("InputReturnFromFinally.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected); } @Test @@ -285,7 +288,7 @@ public void testWithSumCustomMsg() throws Exception { "23:51: this cannot be null.", }; - verify(checkConfig, getPath("InputReturnFromFinally.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected); } @Test @@ -304,7 +307,7 @@ public void testWithSumDefaultMsg() throws Exception { "23:51: " + getCheckMessage(MSG_KEY_SUM_MAX, 2, 1, "NOT_EQUAL"), }; - verify(checkConfig, getPath("InputReturnFromFinally.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected); } @Test @@ -325,7 +328,7 @@ public void testWithSumLessThenMinDefMsg() throws Exception { "24:77: " + getCheckMessage(MSG_KEY_SUM_MIN, 1, 3, "EQUAL"), }; - verify(checkConfig, getPath("InputReturnFromFinally.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected); } @Test @@ -347,6 +350,6 @@ public void testWithSumLessThenMinCustomMsg() throws Exception { "24:77: custom message", }; - verify(checkConfig, getPath("InputReturnFromFinally.java"), expected); + verify(checkConfig, getPath("InputDescendantTokenReturnFromFinally.java"), expected); } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputEmptyStatement.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenEmptyStatement.java similarity index 81% rename from src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputEmptyStatement.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenEmptyStatement.java index dd57a65a2bf..b197c15a179 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputEmptyStatement.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenEmptyStatement.java @@ -1,8 +1,8 @@ -package com.puppycrawl.tools.checkstyle.checks; +package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken; -public class InputEmptyStatement +public class InputDescendantTokenEmptyStatement { - public InputEmptyStatement() + public InputDescendantTokenEmptyStatement() { ; } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenIllegalTokens.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenIllegalTokens.java new file mode 100644 index 00000000000..00379b20fd4 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenIllegalTokens.java @@ -0,0 +1,18 @@ +package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken; + +public class InputDescendantTokenIllegalTokens +{ + public void methodWithPreviouslyIllegalTokens() + { + int i = 0; + switch (i) + { + default: + i--; + i++; + break; + } + } + + public native void nativeMethod(); +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputMissingSwitchDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenMissingSwitchDefault.java similarity index 71% rename from src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputMissingSwitchDefault.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenMissingSwitchDefault.java index 7db2bd5d85e..2475f95e5e5 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputMissingSwitchDefault.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenMissingSwitchDefault.java @@ -1,6 +1,6 @@ -package com.puppycrawl.tools.checkstyle.checks; +package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken; -public class InputMissingSwitchDefault { +public class InputDescendantTokenMissingSwitchDefault { public void foo() { int i = 1; switch (i) { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputReturnFromCatch.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenReturnFromCatch.java similarity index 76% rename from src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputReturnFromCatch.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenReturnFromCatch.java index 68702157faa..e9312a1c0dc 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputReturnFromCatch.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenReturnFromCatch.java @@ -1,6 +1,6 @@ -package com.puppycrawl.tools.checkstyle.checks; +package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken; -public class InputReturnFromCatch { +public class InputDescendantTokenReturnFromCatch { public void foo() { try { System.currentTimeMillis(); diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputReturnFromFinally.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenReturnFromFinally.java similarity index 83% rename from src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputReturnFromFinally.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenReturnFromFinally.java index bfc0aced523..566853d55ab 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputReturnFromFinally.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenReturnFromFinally.java @@ -1,6 +1,6 @@ -package com.puppycrawl.tools.checkstyle.checks; +package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken; -public class InputReturnFromFinally { +public class InputDescendantTokenReturnFromFinally { public void foo() { try { System.currentTimeMillis(); diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputStringLiteralEquality.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenStringLiteralEquality.java similarity index 90% rename from src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputStringLiteralEquality.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenStringLiteralEquality.java index 864f6f783f7..2ee90881378 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputStringLiteralEquality.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/misc/descendanttoken/InputDescendantTokenStringLiteralEquality.java @@ -1,6 +1,6 @@ -package com.puppycrawl.tools.checkstyle.checks; +package com.puppycrawl.tools.checkstyle.checks.misc.descendanttoken; -public class InputStringLiteralEquality +public class InputDescendantTokenStringLiteralEquality { void foo(String name) {