Search in sources :

Example 96 with DefaultConfiguration

use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.

the class ExplicitInitializationCheckTest method testDefault.

@Test
public void testDefault() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(ExplicitInitializationCheck.class);
    final String[] expected = { "4:17: " + getCheckMessage(MSG_KEY, "x", 0), "5:20: " + getCheckMessage(MSG_KEY, "bar", "null"), "9:18: " + getCheckMessage(MSG_KEY, "y4", 0), "10:21: " + getCheckMessage(MSG_KEY, "b1", "false"), "14:22: " + getCheckMessage(MSG_KEY, "str1", "null"), "14:35: " + getCheckMessage(MSG_KEY, "str3", "null"), "15:9: " + getCheckMessage(MSG_KEY, "ar1", "null"), "18:11: " + getCheckMessage(MSG_KEY, "f1", 0), "19:12: " + getCheckMessage(MSG_KEY, "d1", 0), "22:17: " + getCheckMessage(MSG_KEY, "ch1", "\\0"), "23:17: " + getCheckMessage(MSG_KEY, "ch2", "\\0"), "39:25: " + getCheckMessage(MSG_KEY, "bar", "null"), "40:27: " + getCheckMessage(MSG_KEY, "barArray", "null"), "47:21: " + getCheckMessage(MSG_KEY, "x", 0), "48:29: " + getCheckMessage(MSG_KEY, "bar", "null"), "49:31: " + getCheckMessage(MSG_KEY, "barArray", "null"), "52:17: " + getCheckMessage(MSG_KEY, "x", 0), "53:25: " + getCheckMessage(MSG_KEY, "bar", "null"), "54:27: " + getCheckMessage(MSG_KEY, "barArray", "null") };
    verify(checkConfig, getPath("InputExplicitInit.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 97 with DefaultConfiguration

use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.

the class FallThroughCheckTest method testFallThroughNoElse.

@Test
public void testFallThroughNoElse() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(FallThroughCheck.class);
    final String[] expected = { "20:13: " + getCheckMessage(MSG_FALL_THROUGH), "35:13: " + getCheckMessage(MSG_FALL_THROUGH), "39:13: " + getCheckMessage(MSG_FALL_THROUGH), "46:13: " + getCheckMessage(MSG_FALL_THROUGH), "60:13: " + getCheckMessage(MSG_FALL_THROUGH), "67:13: " + getCheckMessage(MSG_FALL_THROUGH), "80:21: " + getCheckMessage(MSG_FALL_THROUGH), "86:13: " + getCheckMessage(MSG_FALL_THROUGH), "88:13: " + getCheckMessage(MSG_FALL_THROUGH) };
    verify(checkConfig, getPath("InputFallThrough2.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 98 with DefaultConfiguration

use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.

the class FallThroughCheckTest method testDefault.

@Test
public void testDefault() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(FallThroughCheck.class);
    final String[] expected = { "14:13: " + getCheckMessage(MSG_FALL_THROUGH), "38:13: " + getCheckMessage(MSG_FALL_THROUGH), "47:13: " + getCheckMessage(MSG_FALL_THROUGH), "53:13: " + getCheckMessage(MSG_FALL_THROUGH), "70:13: " + getCheckMessage(MSG_FALL_THROUGH), "87:13: " + getCheckMessage(MSG_FALL_THROUGH), "123:13: " + getCheckMessage(MSG_FALL_THROUGH), "179:11: " + getCheckMessage(MSG_FALL_THROUGH), "369:11: " + getCheckMessage(MSG_FALL_THROUGH), "372:11: " + getCheckMessage(MSG_FALL_THROUGH), "374:40: " + getCheckMessage(MSG_FALL_THROUGH), "416:13: " + getCheckMessage(MSG_FALL_THROUGH), "424:9: " + getCheckMessage(MSG_FALL_THROUGH), "436:9: " + getCheckMessage(MSG_FALL_THROUGH), "446:9: " + getCheckMessage(MSG_FALL_THROUGH) };
    verify(checkConfig, getPath("InputFallThrough.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 99 with DefaultConfiguration

use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.

the class FallThroughCheckTest method testLastCaseGroup.

@Test
public void testLastCaseGroup() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(FallThroughCheck.class);
    checkConfig.addAttribute("checkLastCaseGroup", "true");
    final String[] expected = { "14:13: " + getCheckMessage(MSG_FALL_THROUGH), "38:13: " + getCheckMessage(MSG_FALL_THROUGH), "47:13: " + getCheckMessage(MSG_FALL_THROUGH), "53:13: " + getCheckMessage(MSG_FALL_THROUGH), "70:13: " + getCheckMessage(MSG_FALL_THROUGH), "87:13: " + getCheckMessage(MSG_FALL_THROUGH), "123:13: " + getCheckMessage(MSG_FALL_THROUGH), "123:13: " + getCheckMessage(MSG_FALL_THROUGH_LAST), "179:11: " + getCheckMessage(MSG_FALL_THROUGH), "369:11: " + getCheckMessage(MSG_FALL_THROUGH), "372:11: " + getCheckMessage(MSG_FALL_THROUGH), "374:40: " + getCheckMessage(MSG_FALL_THROUGH), "376:11: " + getCheckMessage(MSG_FALL_THROUGH_LAST), "416:13: " + getCheckMessage(MSG_FALL_THROUGH), "424:9: " + getCheckMessage(MSG_FALL_THROUGH), "436:9: " + getCheckMessage(MSG_FALL_THROUGH), "446:9: " + getCheckMessage(MSG_FALL_THROUGH) };
    verify(checkConfig, getPath("InputFallThrough.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 100 with DefaultConfiguration

use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.

the class FallThroughCheckTest method testOwnPattern.

@Test
public void testOwnPattern() throws Exception {
    final String ownPattern = "Continue with next case";
    final DefaultConfiguration checkConfig = createCheckConfig(FallThroughCheck.class);
    checkConfig.addAttribute("reliefPattern", ownPattern);
    final String[] expected = { "14:13: " + getCheckMessage(MSG_FALL_THROUGH), "38:13: " + getCheckMessage(MSG_FALL_THROUGH), "47:13: " + getCheckMessage(MSG_FALL_THROUGH), "53:13: " + getCheckMessage(MSG_FALL_THROUGH), "70:13: " + getCheckMessage(MSG_FALL_THROUGH), "87:13: " + getCheckMessage(MSG_FALL_THROUGH), "123:13: " + getCheckMessage(MSG_FALL_THROUGH), "145:11: " + getCheckMessage(MSG_FALL_THROUGH), "170:11: " + getCheckMessage(MSG_FALL_THROUGH), "179:11: " + getCheckMessage(MSG_FALL_THROUGH), "186:11: " + getCheckMessage(MSG_FALL_THROUGH), "204:11: " + getCheckMessage(MSG_FALL_THROUGH), "222:11: " + getCheckMessage(MSG_FALL_THROUGH), "252:26: " + getCheckMessage(MSG_FALL_THROUGH), "266:11: " + getCheckMessage(MSG_FALL_THROUGH), "281:11: " + getCheckMessage(MSG_FALL_THROUGH), "284:11: " + getCheckMessage(MSG_FALL_THROUGH), "288:11: " + getCheckMessage(MSG_FALL_THROUGH), "290:25: " + getCheckMessage(MSG_FALL_THROUGH), "306:11: " + getCheckMessage(MSG_FALL_THROUGH), "309:11: " + getCheckMessage(MSG_FALL_THROUGH), "311:25: " + getCheckMessage(MSG_FALL_THROUGH), "327:11: " + getCheckMessage(MSG_FALL_THROUGH), "330:11: " + getCheckMessage(MSG_FALL_THROUGH), "332:23: " + getCheckMessage(MSG_FALL_THROUGH), "348:11: " + getCheckMessage(MSG_FALL_THROUGH), "351:11: " + getCheckMessage(MSG_FALL_THROUGH), "353:30: " + getCheckMessage(MSG_FALL_THROUGH), "416:13: " + getCheckMessage(MSG_FALL_THROUGH), "424:9: " + getCheckMessage(MSG_FALL_THROUGH), "436:9: " + getCheckMessage(MSG_FALL_THROUGH), "446:9: " + getCheckMessage(MSG_FALL_THROUGH), "491:9: " + getCheckMessage(MSG_FALL_THROUGH), "495:9: " + getCheckMessage(MSG_FALL_THROUGH), "501:9: " + getCheckMessage(MSG_FALL_THROUGH), "507:9: " + getCheckMessage(MSG_FALL_THROUGH), "514:9: " + getCheckMessage(MSG_FALL_THROUGH) };
    verify(checkConfig, getPath("InputFallThrough.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Aggregations

DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)1004 Test (org.junit.Test)986 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)47 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)31 File (java.io.File)22 Checker (com.puppycrawl.tools.checkstyle.Checker)16 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)13 BriefUtLogger (com.puppycrawl.tools.checkstyle.BriefUtLogger)10 Locale (java.util.Locale)5 Method (java.lang.reflect.Method)4 IllegalCatchCheck (com.puppycrawl.tools.checkstyle.checks.coding.IllegalCatchCheck)3 IOException (java.io.IOException)3 BaseCheckTestSupport (com.puppycrawl.tools.checkstyle.BaseCheckTestSupport)2 Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)2 LocalizedMessage (com.puppycrawl.tools.checkstyle.api.LocalizedMessage)2 FileContentsHolder (com.puppycrawl.tools.checkstyle.checks.FileContentsHolder)2 RandomAccessFile (java.io.RandomAccessFile)2 PropertiesExpander (com.puppycrawl.tools.checkstyle.PropertiesExpander)1 TokenTypes (com.puppycrawl.tools.checkstyle.api.TokenTypes)1 MSG_KEY (com.puppycrawl.tools.checkstyle.checks.AvoidEscapedUnicodeCharactersCheck.MSG_KEY)1