diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterCheckTest.java index 1f16f0799..e74c06b94 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterCheckTest.java @@ -23,6 +23,7 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacter import static com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck.FILE_CONTAINS_TAB; import java.io.File; +import java.io.IOException; import org.junit.Test; @@ -32,6 +33,12 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; public class FileTabCharacterCheckTest extends BaseCheckTestSupport { + @Override + protected String getPath(String filename) throws IOException { + return super.getPath("checks" + File.separator + + "whitespace" + File.separator + filename); + } + @Override protected DefaultConfiguration createCheckerConfig( Configuration config) { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java index abd80ddd9..e50c979f5 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java @@ -125,9 +125,7 @@ public class GenericWhitespaceCheckTest @Test public void testMethodReferences() throws Exception { final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, new File("src/test/resources-noncompilable/com/puppycrawl/tools/" - + "checkstyle/grammars/java8/" - + "InputMethodReferencesTest3.java").getCanonicalPath(), expected); + verify(checkConfig, getNonCompilablePath("InputMethodReferencesTest3.java"), expected); } @Test diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java index 01b822e13..9920d3dc0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java @@ -21,6 +21,9 @@ package com.puppycrawl.tools.checkstyle.checks.whitespace; import static com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceAfterCheck.MSG_KEY; +import java.io.File; +import java.io.IOException; + import org.apache.commons.lang3.ArrayUtils; import org.junit.Before; import org.junit.Test; @@ -32,6 +35,12 @@ public class NoWhitespaceAfterCheckTest extends BaseCheckTestSupport { private DefaultConfiguration checkConfig; + @Override + protected String getPath(String filename) throws IOException { + return super.getPath("checks" + File.separator + + "whitespace" + File.separator + filename); + } + @Before public void setUp() { checkConfig = createCheckConfig(NoWhitespaceAfterCheck.class); @@ -100,13 +109,13 @@ public class NoWhitespaceAfterCheckTest "40:16: " + getCheckMessage(MSG_KEY, "int"), "43:63: " + getCheckMessage(MSG_KEY, "getLongMultArray"), }; - verify(checkConfig, getPath("whitespace/InputNoWhitespaceAfterArrayDeclarations.java"), expected); + verify(checkConfig, getPath("InputNoWhitespaceAfterArrayDeclarations.java"), expected); } @Test public void testNpe() throws Exception { final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("whitespace/InputNoWhiteSpaceAfterCheckFormerNpe.java"), + verify(checkConfig, getPath("InputNoWhiteSpaceAfterCheckFormerNpe.java"), expected); } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java index 4b207e21d..e17f971f9 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java @@ -21,6 +21,9 @@ package com.puppycrawl.tools.checkstyle.checks.whitespace; import static com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCheck.MSG_KEY; +import java.io.File; +import java.io.IOException; + import org.junit.Before; import org.junit.Test; @@ -36,6 +39,12 @@ public class NoWhitespaceBeforeCheckTest checkConfig = createCheckConfig(NoWhitespaceBeforeCheck.class); } + @Override + protected String getPath(String filename) throws IOException { + return super.getPath("checks" + File.separator + + "whitespace" + File.separator + filename); + } + @Test public void testDefault() throws Exception { final String[] expected = { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java index ffe8e5cc6..b549b3d2a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java @@ -24,6 +24,9 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPad import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.WS_NOT_PRECEDED; import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.WS_PRECEDED; +import java.io.File; +import java.io.IOException; + import org.apache.commons.lang3.ArrayUtils; import org.junit.Test; @@ -32,6 +35,12 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class ParenPadCheckTest extends BaseCheckTestSupport { + @Override + protected String getPath(String filename) throws IOException { + return super.getPath("checks" + File.separator + + "whitespace" + File.separator + filename); + } + @Test public void testDefault() throws Exception { @@ -109,7 +118,7 @@ public class ParenPadCheckTest "48:27: " + getCheckMessage(WS_PRECEDED, ")"), "51:26: " + getCheckMessage(WS_PRECEDED, ")"), }; - verify(checkConfig, getPath("checks/whitespace/InputForWhitespace.java"), expected); + verify(checkConfig, getPath("InputForWhitespace.java"), expected); } @Test @@ -129,7 +138,7 @@ public class ParenPadCheckTest "27:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("), "32:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("), }; - verify(checkConfig, getPath("checks/whitespace/InputForWhitespace.java"), expected); + verify(checkConfig, getPath("InputForWhitespace.java"), expected); } @Test @@ -138,7 +147,7 @@ public class ParenPadCheckTest createCheckConfig(ParenPadCheck.class); checkConfig.addAttribute("option", PadOption.SPACE.toString()); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("whitespace/ParenPadWithSpace.java"), + verify(checkConfig, getPath("ParenPadWithSpace.java"), expected); } @@ -213,7 +222,7 @@ public class ParenPadCheckTest "130:19: " + getCheckMessage(WS_FOLLOWED, "("), "130:19: " + getCheckMessage(WS_PRECEDED, ")"), }; - verify(checkConfig, getPath("whitespace/InputParenPad.java"), expected); + verify(checkConfig, getPath("InputParenPad.java"), expected); } @Test @@ -228,6 +237,6 @@ public class ParenPadCheckTest "115:53: " + getCheckMessage(WS_PRECEDED, ")"), "115:55: " + getCheckMessage(WS_PRECEDED, ")"), }; - verify(checkConfig, getPath("whitespace/InputParenPad.java"), expected); + verify(checkConfig, getPath("InputParenPad.java"), expected); } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheckTest.java index 75c0ffb5a..e7bc1e436 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheckTest.java @@ -24,6 +24,9 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPad import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.WS_NOT_PRECEDED; import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.WS_PRECEDED; +import java.io.File; +import java.io.IOException; + import org.apache.commons.lang3.ArrayUtils; import org.junit.Assert; import org.junit.Test; @@ -34,6 +37,12 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; public class TypecastParenPadCheckTest extends BaseCheckTestSupport { + @Override + protected String getPath(String filename) throws IOException { + return super.getPath("checks" + File.separator + + "whitespace" + File.separator + filename); + } + @Test public void testDefault() throws Exception { @@ -71,7 +80,7 @@ public class TypecastParenPadCheckTest createCheckConfig(TypecastParenPadCheck.class); checkConfig.addAttribute("option", PadOption.SPACE.toString()); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("checks/whitespace/InputWhitespaceAround.java"), + verify(checkConfig, getPath("InputWhitespaceAround.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheckTest.java index 8df729508..004157df7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheckTest.java @@ -23,6 +23,9 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterC import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck.WS_TYPECAST; import static org.junit.Assert.assertArrayEquals; +import java.io.File; +import java.io.IOException; + import org.apache.commons.lang3.ArrayUtils; import org.junit.Before; import org.junit.Test; @@ -39,6 +42,12 @@ public class WhitespaceAfterCheckTest checkConfig = createCheckConfig(WhitespaceAfterCheck.class); } + @Override + protected String getPath(String filename) throws IOException { + return super.getPath("checks" + File.separator + + "whitespace" + File.separator + filename); + } + @Test public void testGetRequiredTokens() { WhitespaceAfterCheck checkObj = new WhitespaceAfterCheck(); @@ -65,9 +74,9 @@ public class WhitespaceAfterCheckTest @Test public void testSemi() throws Exception { final String[] expected = { - "58:23: " + getCheckMessage(WS_NOT_FOLLOWED, ";"), - "58:29: " + getCheckMessage(WS_NOT_FOLLOWED, ";"), - "107:19: " + getCheckMessage(WS_NOT_FOLLOWED, ";"), + "54:23: " + getCheckMessage(WS_NOT_FOLLOWED, ";"), + "54:29: " + getCheckMessage(WS_NOT_FOLLOWED, ";"), + "103:19: " + getCheckMessage(WS_NOT_FOLLOWED, ";"), }; verify(checkConfig, getPath("InputBraces.java"), expected); } @@ -78,7 +87,7 @@ public class WhitespaceAfterCheckTest "14:31: " + getCheckMessage(WS_NOT_FOLLOWED, ";"), "17:31: " + getCheckMessage(WS_NOT_FOLLOWED, ";"), }; - verify(checkConfig, getPath("checks/whitespace/InputForWhitespace.java"), expected); + verify(checkConfig, getPath("InputForWhitespace.java"), expected); } @Test @@ -94,7 +103,7 @@ public class WhitespaceAfterCheckTest @Test public void test1322879() throws Exception { final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("checks/whitespace/InputWhitespaceAround.java"), + verify(checkConfig, getPath("InputWhitespaceAround.java"), expected); } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundTest.java index 701b1c88d..dd35d6a46 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundTest.java @@ -23,6 +23,9 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAround import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck.WS_NOT_PRECEDED; import static org.junit.Assert.assertArrayEquals; +import java.io.File; +import java.io.IOException; + import org.apache.commons.lang3.ArrayUtils; import org.junit.Before; import org.junit.Test; @@ -40,6 +43,12 @@ public class WhitespaceAroundTest checkConfig = createCheckConfig(WhitespaceAroundCheck.class); } + @Override + protected String getPath(String filename) throws IOException { + return super.getPath("checks" + File.separator + + "whitespace" + File.separator + filename); + } + @Test public void testGetRequiredTokens() { WhitespaceAroundCheck checkObj = new WhitespaceAroundCheck(); @@ -108,14 +117,14 @@ public class WhitespaceAroundTest public void testIt3() throws Exception { final String[] expected = { - "41:14: " + getCheckMessage(WS_NOT_FOLLOWED, "while"), - "58:12: " + getCheckMessage(WS_NOT_FOLLOWED, "for"), + "37:14: " + getCheckMessage(WS_NOT_FOLLOWED, "while"), + "54:12: " + getCheckMessage(WS_NOT_FOLLOWED, "for"), // + ":58:23: ';' is not followed by whitespace.", // + ":58:29: ';' is not followed by whitespace.", - "115:27: " + getCheckMessage(WS_NOT_FOLLOWED, "{"), - "115:27: " + getCheckMessage(WS_NOT_PRECEDED, "}"), - "118:40: " + getCheckMessage(WS_NOT_FOLLOWED, "{"), - "118:40: " + getCheckMessage(WS_NOT_PRECEDED, "}"), + "111:27: " + getCheckMessage(WS_NOT_FOLLOWED, "{"), + "111:27: " + getCheckMessage(WS_NOT_PRECEDED, "}"), + "114:40: " + getCheckMessage(WS_NOT_FOLLOWED, "{"), + "114:40: " + getCheckMessage(WS_NOT_PRECEDED, "}"), }; verify(checkConfig, getPath("InputBraces.java"), expected); } @@ -126,8 +135,8 @@ public class WhitespaceAroundTest checkConfig.addAttribute("allowEmptyMethods", "true"); checkConfig.addAttribute("allowEmptyConstructors", "true"); final String[] expected = { - "41:14: " + getCheckMessage(WS_NOT_FOLLOWED, "while"), - "58:12: " + getCheckMessage(WS_NOT_FOLLOWED, "for"), + "37:14: " + getCheckMessage(WS_NOT_FOLLOWED, "while"), + "54:12: " + getCheckMessage(WS_NOT_FOLLOWED, "for"), }; verify(checkConfig, getPath("InputBraces.java"), expected); } @@ -145,7 +154,7 @@ public class WhitespaceAroundTest @Test public void test1322879And1649038() throws Exception { final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("checks/whitespace/InputWhitespaceAround.java"), + verify(checkConfig, getPath("InputWhitespaceAround.java"), expected); } @@ -155,7 +164,7 @@ public class WhitespaceAroundTest final String[] expected = { "19:20: " + getCheckMessage(WS_NOT_PRECEDED, ":"), }; - verify(checkConfig, getPath("checks/whitespace/InputWhitespaceAround.java"), + verify(checkConfig, getPath("InputWhitespaceAround.java"), expected); } @@ -170,7 +179,7 @@ public class WhitespaceAroundTest "31:21: " + getCheckMessage(WS_NOT_FOLLOWED, "{"), "31:21: " + getCheckMessage(WS_NOT_PRECEDED, "}"), }; - verify(checkConfig, getPath("whitespace/InputEmptyTypesAndCycles.java"), + verify(checkConfig, getPath("InputEmptyTypesAndCycles.java"), expected); } @@ -189,7 +198,7 @@ public class WhitespaceAroundTest "60:18: " + getCheckMessage(WS_NOT_FOLLOWED, "{"), "60:18: " + getCheckMessage(WS_NOT_PRECEDED, "}"), }; - verify(checkConfig, getPath("whitespace/InputEmptyTypesAndCycles.java"), + verify(checkConfig, getPath("InputEmptyTypesAndCycles.java"), expected); } @@ -198,9 +207,7 @@ public class WhitespaceAroundTest final String[] expected = { "6:15: " + getCheckMessage(WS_NOT_FOLLOWED, "switch"), }; - verify(checkConfig, - getPath("whitespace/InputSwitchWhitespaceAround.java"), - expected); + verify(checkConfig, getPath("InputSwitchWhitespaceAround.java"), expected); } @Test @@ -208,18 +215,14 @@ public class WhitespaceAroundTest final String[] expected = { "9:16: " + getCheckMessage(WS_NOT_FOLLOWED, "while"), }; - verify(checkConfig, - getPath("whitespace/InputDoWhileWhitespaceAround.java"), - expected); + verify(checkConfig, getPath("InputDoWhileWhitespaceAround.java"), expected); } @Test public void allowEmptyMethods() throws Exception { checkConfig.addAttribute("allowEmptyMethods", "true"); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, - getPath("checks/whitespace/InputWhitespaceAround.java"), - expected); + verify(checkConfig, getPath("InputWhitespaceAround.java"), expected); } @Test diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/whitespace/InputMethodReferencesTest3.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/whitespace/InputMethodReferencesTest3.java new file mode 100644 index 000000000..4ef7b3d24 --- /dev/null +++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/whitespace/InputMethodReferencesTest3.java @@ -0,0 +1,18 @@ +//Compilable with Java8 +package com.puppycrawl.tools.checkstyle.checks.whitespace; +import java.util.function.Supplier; +public static class InputMethodReferencesTest3 +{ + public static class SomeClass { + public static class Nested { + public Nested() { + } + } + } + + public void methodName(V value) { + MyClass::myMethod; + Supplier> passes = SomeClass.Nested::new; + Supplier> fails = SomeClass.Nested::new; + } +} \ No newline at end of file diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/InputBraces.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputBraces.java similarity index 95% rename from src/test/resources/com/puppycrawl/tools/checkstyle/InputBraces.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputBraces.java index 762a5714d..54ef42ba2 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/InputBraces.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputBraces.java @@ -2,12 +2,8 @@ // Test case file for checkstyle. // Created: 2001 //////////////////////////////////////////////////////////////////////////////// -package com.puppycrawl.tools.checkstyle; +package com.puppycrawl.tools.checkstyle.checks.whitespace; -/** - * Test case for correct use of braces. - * @author Oliver Burn - **/ class InputBraces { /** @return helper func **/ diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputDoWhileWhitespaceAround.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputDoWhileWhitespaceAround.java similarity index 73% rename from src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputDoWhileWhitespaceAround.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputDoWhileWhitespaceAround.java index c500336ad..6c05bfdcc 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputDoWhileWhitespaceAround.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputDoWhileWhitespaceAround.java @@ -1,4 +1,4 @@ -package com.puppycrawl.tools.checkstyle.whitespace; +package com.puppycrawl.tools.checkstyle.checks.whitespace; public class InputDoWhileWhitespaceAround { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputEmptyTypesAndCycles.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputEmptyTypesAndCycles.java similarity index 96% rename from src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputEmptyTypesAndCycles.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputEmptyTypesAndCycles.java index 5c55cee75..6a436ed16 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputEmptyTypesAndCycles.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputEmptyTypesAndCycles.java @@ -2,7 +2,7 @@ // Test case file for checkstyle. // Created: 2001 //////////////////////////////////////////////////////////////////////////////// -package com.puppycrawl.tools.checkstyle.whitespace; +package com.puppycrawl.tools.checkstyle.checks.whitespace; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/InputGenerics.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputGenerics.java similarity index 92% rename from src/test/resources/com/puppycrawl/tools/checkstyle/InputGenerics.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputGenerics.java index 0361c0fa5..d1a2f6984 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/InputGenerics.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputGenerics.java @@ -1,4 +1,4 @@ -package com.puppycrawl.tools.checkstyle; +package com.puppycrawl.tools.checkstyle.checks.whitespace; import java.util.Collection; import java.util.Map; diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputNoWhiteSpaceAfterCheckFormerNpe.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputNoWhiteSpaceAfterCheckFormerNpe.java similarity index 66% rename from src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputNoWhiteSpaceAfterCheckFormerNpe.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputNoWhiteSpaceAfterCheckFormerNpe.java index dacc9a3a9..2f94861c9 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputNoWhiteSpaceAfterCheckFormerNpe.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputNoWhiteSpaceAfterCheckFormerNpe.java @@ -1,4 +1,4 @@ -package com.puppycrawl.tools.checkstyle.whitespace; +package com.puppycrawl.tools.checkstyle.checks.whitespace; public class InputNoWhiteSpaceAfterCheckFormerNpe { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputNoWhitespaceAfterArrayDeclarations.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputNoWhitespaceAfterArrayDeclarations.java similarity index 95% rename from src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputNoWhitespaceAfterArrayDeclarations.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputNoWhitespaceAfterArrayDeclarations.java index 2011eb738..a4942ffc7 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputNoWhitespaceAfterArrayDeclarations.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputNoWhitespaceAfterArrayDeclarations.java @@ -1,4 +1,4 @@ -package com.puppycrawl.tools.checkstyle.whitespace; +package com.puppycrawl.tools.checkstyle.checks.whitespace; public class InputNoWhitespaceAfterArrayDeclarations { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputParenPad.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputParenPad.java similarity index 98% rename from src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputParenPad.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputParenPad.java index ec627cff9..b3c08ea8b 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputParenPad.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputParenPad.java @@ -1,4 +1,4 @@ -package com.puppycrawl.tools.checkstyle.whitespace; +package com.puppycrawl.tools.checkstyle.checks.whitespace; import java.io.IOException; import java.io.StringWriter; diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputSimple.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputSimple.java new file mode 100644 index 000000000..073be3652 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputSimple.java @@ -0,0 +1,225 @@ +//////////////////////////////////////////////////////////////////////////////// +// Test case file for checkstyle. +// Created: Feb-2001 +// Ignore error +//////////////////////////////////////////////////////////////////////////////// +package com.puppycrawl.tools.checkstyle.checks.whitespace; +import java.io.*; +/** + * Contains simple mistakes: + * - Long lines + * - Tabs + * - Format of variables and parameters + * - Order of modifiers + * @author Oliver Burn + **/ +final class InputSimple +{ + // Long line ---------------------------------------------------------------- + // Contains a tab -> <- + // Contains trailing whitespace -> + + // Name format tests + // + /** Invalid format **/ + public static final int badConstant = 2; + /** Valid format **/ + public static final int MAX_ROWS = 2; + + /** Invalid format **/ + private static int badStatic = 2; + /** Valid format **/ + private static int sNumCreated = 0; + + /** Invalid format **/ + private int badMember = 2; + /** Valid format **/ + private int mNumCreated1 = 0; + /** Valid format **/ + protected int mNumCreated2 = 0; + + /** commas are wrong **/ + private int[] mInts = new int[] {1,2, 3, + 4}; + + // + // Accessor tests + // + /** should be private **/ + public static int sTest1; + /** should be private **/ + protected static int sTest3; + /** should be private **/ + static int sTest2; + + /** should be private **/ + int mTest1; + /** should be private **/ + public int mTest2; + + // + // Parameter name format tests + // + + /** + * @return hack + * @param badFormat1 bad format + * @param badFormat2 bad format + * @param badFormat3 bad format + * @throws java.lang.Exception abc + **/ + int test1(int badFormat1,int badFormat2, + final int badFormat3) + throws java.lang.Exception + { + return 0; + } + + /** method that is 20 lines long **/ + private void longMethod() + { + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + } + + /** constructor that is 10 lines long **/ + private InputSimple() + { + // a line + // a line + // a line + // a line + // a line + // a line + // a line + // a line + } + + /** test local variables */ + private void localVariables() + { + // normal decl + int abc = 0; + int ABC = 0; + + // final decls + final int cde = 0; + final int CDE = 0; + + // decl in for loop init statement + for (int k = 0; k < 1; k++) + { + String innerBlockVariable = ""; + } + for (int I = 0; I < 1; I++) + { + String InnerBlockVariable = ""; + } + } + + /** test method pattern */ + void ALL_UPPERCASE_METHOD() + { + } + + /** test illegal constant **/ + private static final int BAD__NAME = 3; + + // A very, very long line that is OK because it matches the regexp "^.*is OK.*regexp.*$" + // long line that has a tab -> <- and would be OK if tab counted as 1 char + // tabs that count as one char because of their position -> <- -> <-, OK + + /** some lines to test the error column after tabs */ + void errorColumnAfterTabs() + { + // with tab-width 8 all statements below start at the same column, + // with different combinations of ' ' and '\t' before the statement + int tab0 =1; + int tab1 =1; + int tab2 =1; + int tab3 =1; + int tab4 =1; + int tab5 =1; + } + + // FIXME: + /* FIXME: a + * FIXME: + * TODO + */ + /* NOTHING */ + /* YES */ /* FIXME: x */ /* YES!! */ + + /** test long comments **/ + void veryLong() + { + /* + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + blah blah blah blah + enough talk */ + } + + /** + * @see to lazy to document all args. Testing excessive # args + **/ + void toManyArgs(int aArg1, int aArg2, int aArg3, int aArg4, int aArg5, + int aArg6, int aArg7, int aArg8, int aArg9) + { + } +} + +/** Test class for variable naming in for each clauses. */ +class InputSimple2 +{ + /** Some more Javadoc. */ + public void doSomething() + { + //"O" should be named "o" + for (Object O : new java.util.ArrayList()) + { + + } + } +} + +/** Test enum for member naming check */ +enum MyEnum1 +{ + /** ABC constant */ + ABC, + + /** XYZ constant */ + XYZ; + + /** Should be mSomeMemeber */ + private int someMember; +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputSwitchWhitespaceAround.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputSwitchWhitespaceAround.java similarity index 78% rename from src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputSwitchWhitespaceAround.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputSwitchWhitespaceAround.java index 867166a63..81bb692b0 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/InputSwitchWhitespaceAround.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputSwitchWhitespaceAround.java @@ -1,4 +1,4 @@ -package com.puppycrawl.tools.checkstyle.whitespace; +package com.puppycrawl.tools.checkstyle.checks.whitespace; public class InputSwitchWhitespaceAround { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/InputWhitespace.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputWhitespace.java similarity index 99% rename from src/test/resources/com/puppycrawl/tools/checkstyle/InputWhitespace.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputWhitespace.java index 75df80731..fa45adc8b 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/InputWhitespace.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/InputWhitespace.java @@ -4,7 +4,7 @@ //////////////////////////////////////////////////////////////////////////////// package com . puppycrawl .tools. - checkstyle; + checkstyle.checks.whitespace; /** * Class for testing whitespace issues. diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/ParenPadWithSpace.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadWithSpace.java similarity index 85% rename from src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/ParenPadWithSpace.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadWithSpace.java index 07b452d81..c154596fb 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/whitespace/ParenPadWithSpace.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadWithSpace.java @@ -1,4 +1,4 @@ -package com.puppycrawl.tools.checkstyle.whitespace; +package com.puppycrawl.tools.checkstyle.checks.whitespace; public class ParenPadWithSpace {