Search in sources :

Example 6 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class FileSetCheckLifecycleTest method testTranslation.

@Test
public void testTranslation() throws Exception {
    final Configuration checkConfig = createCheckConfig(TestFileSetCheck.class);
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
    assertTrue("destroy() not called by Checker", TestFileSetCheck.isDestroyed());
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 7 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class EmptyLineSeparatorTest method emptyLineSeparatorTest.

@Test
public void emptyLineSeparatorTest() throws Exception {
    final Class<EmptyLineSeparatorCheck> clazz = EmptyLineSeparatorCheck.class;
    final String messageKey = "empty.line.separator";
    final String[] expected = { "19: " + getCheckMessage(clazz, messageKey, "package"), "20: " + getCheckMessage(clazz, messageKey, "import"), "33: " + getCheckMessage(clazz, messageKey, "CLASS_DEF"), "37: " + getCheckMessage(clazz, messageKey, "STATIC_INIT"), "66: " + getCheckMessage(clazz, messageKey, "METHOD_DEF"), "75: " + getCheckMessage(clazz, messageKey, "INTERFACE_DEF"), "82: " + getCheckMessage(clazz, messageKey, "INSTANCE_INIT"), "113: " + getCheckMessage(clazz, messageKey, "CLASS_DEF"), "119: " + getCheckMessage(clazz, messageKey, "VARIABLE_DEF") };
    final Configuration checkConfig = getCheckConfig("EmptyLineSeparator");
    final String filePath = getPath("InputEmptyLineSeparator.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) EmptyLineSeparatorCheck(com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck) Test(org.junit.Test)

Example 8 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class GenericWhitespaceTest method genericWhitespaceTest.

@Test
public void genericWhitespaceTest() throws Exception {
    final String msgPreceded = "ws.preceded";
    final String msgFollowed = "ws.followed";
    final String msgNotPreceded = "ws.notPreceded";
    final String msgIllegalFollow = "ws.illegalFollow";
    final Configuration checkConfig = getCheckConfig("GenericWhitespace");
    final String[] expected = { "16:13: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, "<"), "16:15: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "<"), "16:23: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, ">"), "16:43: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, "<"), "16:45: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "<"), "16:53: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, ">"), "17:13: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, "<"), "17:15: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "<"), "17:20: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, "<"), "17:22: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "<"), "17:30: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, ">"), "17:32: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, ">"), "17:32: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, ">"), "17:52: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, "<"), "17:54: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "<"), "17:59: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, "<"), "17:61: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "<"), "17:69: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, ">"), "17:71: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, ">"), "17:71: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, ">"), "30:17: " + getCheckMessage(checkConfig.getMessages(), msgNotPreceded, "<"), "30:21: " + getCheckMessage(checkConfig.getMessages(), msgIllegalFollow, ">"), "42:21: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, "<"), "42:30: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, ">"), "60:60: " + getCheckMessage(checkConfig.getMessages(), msgNotPreceded, "&"), "63:60: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, ">") };
    final String filePath = getPath("InputGenericWhitespace.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 9 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class MethodParamPadTest method operatorWrapTest.

@Test
public void operatorWrapTest() throws Exception {
    final Class<MethodParamPadCheck> clazz = MethodParamPadCheck.class;
    final String messageKeyPreceded = "ws.preceded";
    final String[] expected = { "11:32: " + getCheckMessage(clazz, messageKeyPreceded, "("), "13:15: " + getCheckMessage(clazz, messageKeyPreceded, "("), "20:24: " + getCheckMessage(clazz, messageKeyPreceded, "("), "29:39: " + getCheckMessage(clazz, messageKeyPreceded, "("), "35:16: " + getCheckMessage(clazz, messageKeyPreceded, "("), "41:21: " + getCheckMessage(clazz, messageKeyPreceded, "("), "47:18: " + getCheckMessage(clazz, messageKeyPreceded, "("), "52:36: " + getCheckMessage(clazz, messageKeyPreceded, "(") };
    final Configuration checkConfig = getCheckConfig("MethodParamPad");
    final String filePath = getPath("InputMethodParamPad.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) MethodParamPadCheck(com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck) Test(org.junit.Test)

Example 10 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class ParenPadTest method methodParenTest.

@Test
public void methodParenTest() throws Exception {
    final Class<ParenPadCheck> clazz = ParenPadCheck.class;
    final String messageKeyPreceded = "ws.preceded";
    final String messageKeyFollowed = "ws.followed";
    final String[] expected = { "44:27: " + getCheckMessage(clazz, messageKeyFollowed, "("), "44:27: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "45:18: " + getCheckMessage(clazz, messageKeyFollowed, "("), "48:27: " + getCheckMessage(clazz, messageKeyFollowed, "("), "49:19: " + getCheckMessage(clazz, messageKeyFollowed, "("), "49:19: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "52:27: " + getCheckMessage(clazz, messageKeyFollowed, "("), "53:21: " + getCheckMessage(clazz, messageKeyFollowed, "("), "54:18: " + getCheckMessage(clazz, messageKeyFollowed, "("), "54:52: " + getCheckMessage(clazz, messageKeyFollowed, "("), "54:52: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "57:26: " + getCheckMessage(clazz, messageKeyFollowed, "("), "58:22: " + getCheckMessage(clazz, messageKeyFollowed, "("), "59:24: " + getCheckMessage(clazz, messageKeyFollowed, "("), "60:26: " + getCheckMessage(clazz, messageKeyFollowed, "("), "60:51: " + getCheckMessage(clazz, messageKeyFollowed, "("), "60:57: " + getCheckMessage(clazz, messageKeyFollowed, "("), "61:29: " + getCheckMessage(clazz, messageKeyFollowed, "("), "62:43: " + getCheckMessage(clazz, messageKeyFollowed, "("), "63:41: " + getCheckMessage(clazz, messageKeyFollowed, "("), "65:43: " + getCheckMessage(clazz, messageKeyFollowed, "("), "78:28: " + getCheckMessage(clazz, messageKeyFollowed, "("), "78:28: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "79:19: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "82:33: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "83:19: " + getCheckMessage(clazz, messageKeyFollowed, "("), "83:19: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "86:29: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "87:35: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "88:51: " + getCheckMessage(clazz, messageKeyFollowed, "("), "88:51: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "88:53: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "90:38: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "91:32: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "92:35: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "93:30: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "94:60: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "94:62: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "94:69: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "95:34: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "96:47: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "97:42: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "99:44: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "112:17: " + getCheckMessage(clazz, messageKeyFollowed, "("), "113:23: " + getCheckMessage(clazz, messageKeyFollowed, "("), "113:25: " + getCheckMessage(clazz, messageKeyFollowed, "("), "113:31: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "114:26: " + getCheckMessage(clazz, messageKeyFollowed, "("), "114:28: " + getCheckMessage(clazz, messageKeyFollowed, "("), "114:34: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "114:50: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "115:26: " + getCheckMessage(clazz, messageKeyFollowed, "("), "115:28: " + getCheckMessage(clazz, messageKeyFollowed, "("), "115:35: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "115:53: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "115:55: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "119:17: " + getCheckMessage(clazz, messageKeyFollowed, "("), "119:22: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "123:30: " + getCheckMessage(clazz, messageKeyFollowed, "("), "123:44: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "126:22: " + getCheckMessage(clazz, messageKeyFollowed, "("), "126:22: " + getCheckMessage(clazz, messageKeyPreceded, ")"), "130:19: " + getCheckMessage(clazz, messageKeyFollowed, "("), "130:19: " + getCheckMessage(clazz, messageKeyPreceded, ")") };
    final Configuration checkConfig = getCheckConfig("ParenPad");
    final String filePath = getPath("InputParenPad.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) ParenPadCheck(com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck) Test(org.junit.Test)

Aggregations

Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)307 Test (org.junit.jupiter.api.Test)179 Test (org.junit.Test)100 DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)34 Properties (java.util.Properties)21 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)16 File (java.io.File)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 PropertiesExpander (com.puppycrawl.tools.checkstyle.PropertiesExpander)11 Checker (com.puppycrawl.tools.checkstyle.Checker)9 HashSet (java.util.HashSet)8 InputSource (org.xml.sax.InputSource)7 OneTopLevelClassCheck (com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 ConfigurationLoader (com.puppycrawl.tools.checkstyle.ConfigurationLoader)5 URI (java.net.URI)5 MethodParamPadCheck (com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck)4 Set (java.util.Set)4 ModuleFactory (com.puppycrawl.tools.checkstyle.ModuleFactory)3