diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java b/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java index 8beb1218d..d51792f9d 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java @@ -88,8 +88,7 @@ public class BaseCheckTestSupport { return dc; } - protected String getPath(String filename) - throws IOException { + protected String getPath(String filename) throws IOException { return new File("src/test/resources/com/puppycrawl/tools/checkstyle/" + filename).getCanonicalPath(); } @@ -98,10 +97,14 @@ public class BaseCheckTestSupport { } protected String getSrcPath(String filename) throws IOException { - return new File("src/test/java/com/puppycrawl/tools/checkstyle/" + filename).getCanonicalPath(); } + protected String getNonCompilablePath(String filename) throws IOException { + return new File("src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/" + + filename).getCanonicalPath(); + } + protected void verify(Configuration aConfig, String fileName, String... expected) throws Exception { verify(createChecker(aConfig), fileName, fileName, expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java index 9ac4c8431..0cb3a6c81 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java @@ -22,6 +22,7 @@ package com.puppycrawl.tools.checkstyle.checks.coding; import static com.puppycrawl.tools.checkstyle.checks.coding.DefaultComesLastCheck.MSG_KEY; import java.io.File; +import java.io.IOException; import org.apache.commons.lang3.ArrayUtils; import org.junit.Assert; @@ -31,6 +32,18 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; public class DefaultComesLastCheckTest extends BaseCheckTestSupport { + @Override + protected String getPath(String filename) throws IOException { + return super.getPath("checks" + File.separator + + "coding" + File.separator + filename); + } + + @Override + protected String getNonCompilablePath(String filename) throws IOException { + return super.getNonCompilablePath("checks" + File.separator + + "coding" + File.separator + filename); + } + @Test public void testIt() throws Exception { final DefaultConfiguration checkConfig = @@ -40,7 +53,7 @@ public class DefaultComesLastCheckTest extends BaseCheckTestSupport { "31:24: " + getCheckMessage(MSG_KEY), }; verify(checkConfig, - getPath("coding" + File.separator + "InputDefaultComesLast.java"), + getPath("InputDefaultComesLast.java"), expected); } @@ -51,10 +64,8 @@ public class DefaultComesLastCheckTest extends BaseCheckTestSupport { createCheckConfig(DefaultComesLastCheck.class); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; verify(checkConfig, - new File( - "src/test/resources-noncompilable/com/puppycrawl/tools/" - + "checkstyle/coding/InputDefaultComesLast2.java").getCanonicalPath(), - expected); + getNonCompilablePath("InputDefaultComesLast2.java"), + expected); } @Test diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/coding/InputDefaultComesLast2.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/InputDefaultComesLast2.java similarity index 85% rename from src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/coding/InputDefaultComesLast2.java rename to src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/InputDefaultComesLast2.java index 37f705e48..382e85293 100644 --- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/coding/InputDefaultComesLast2.java +++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/InputDefaultComesLast2.java @@ -1,5 +1,5 @@ //Compilable with Java8 -package com.puppycrawl.tools.checkstyle.coding; +package com.puppycrawl.tools.checkstyle.checks.coding; public interface JsonTranslator { String toJson(Response one, Response two, Response three); diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/coding/InputDefaultComesLast.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputDefaultComesLast.java similarity index 93% rename from src/test/resources/com/puppycrawl/tools/checkstyle/coding/InputDefaultComesLast.java rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputDefaultComesLast.java index 2f19a5f83..20945fdb4 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/coding/InputDefaultComesLast.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputDefaultComesLast.java @@ -1,4 +1,4 @@ -package com.puppycrawl.tools.checkstyle.coding; +package com.puppycrawl.tools.checkstyle.checks.coding; public class InputDefaultComesLast {