Search in sources :

Example 16 with Configuration

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

the class EmptyCatchBlockTest method emptyBlockTestCatch.

@Test
public void emptyBlockTestCatch() throws Exception {
    final String[] expected = { "28: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty"), "49: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty"), "71: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty"), "79: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty"), "83: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty") };
    final Configuration checkConfig = getCheckConfig("EmptyCatchBlock");
    final String filePath = getPath("InputEmptyBlockCatch.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 17 with Configuration

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

the class OneStatementPerLineTest method oneStatementNonCompilableInputTest.

@Test
public void oneStatementNonCompilableInputTest() throws Exception {
    final String msg = getCheckMessage(OneStatementPerLineCheck.class, "multiple.statements.line");
    final String[] expected = { "32:6: " + msg, "37:58: " + msg, "38:58: " + msg, "38:74: " + msg, "39:50: " + msg, "43:91: " + msg };
    final Configuration checkConfig = getCheckConfig("OneStatementPerLine");
    final String filePath = new File("src/test/resources-noncompilable/" + "com/puppycrawl/tools/checkstyle/checks/coding/" + "InputOneStatementPerLine.java").getCanonicalPath();
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) File(java.io.File) Test(org.junit.Test)

Example 18 with Configuration

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

the class OneStatementPerLineTest method oneStatementTest.

@Test
public void oneStatementTest() throws Exception {
    final String msg = getCheckMessage(OneStatementPerLineCheck.class, "multiple.statements.line");
    final String[] expected = { "6:59: " + msg, "50:21: " + msg, "52:21: " + msg, "54:42: " + msg, "57:25: " + msg, "58:35: " + msg, "68:14: " + msg, "95:25: " + msg, "97:25: " + msg, "99:46: " + msg, "102:29: " + msg, "103:39: " + msg, "111:15: " + msg, "123:23: " + msg, "138:59: " + msg, "170:19: " + msg, "188:15: " + msg, "196:15: " + msg, "208:6: " + msg, "217:22: " + msg, "307:39: " + msg };
    final Configuration checkConfig = getCheckConfig("OneStatementPerLine");
    final String filePath = getPath("InputOneStatementPerLine.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 19 with Configuration

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

the class LineLengthTest method lineLengthTest.

@Test
public void lineLengthTest() throws Exception {
    final String[] expected = { "5: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 112), "29: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 113) };
    final Configuration checkConfig = getCheckConfig("LineLength");
    final String filePath = getPath("InputLineLength.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 20 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 messageKeyPrevious = "line.previous";
    final String messageKeyPreceded = "ws.preceded";
    final String[] expected = { "83:9: " + getCheckMessage(clazz, messageKeyPrevious, "("), "128:13: " + getCheckMessage(clazz, messageKeyPrevious, "("), "130:9: " + getCheckMessage(clazz, messageKeyPrevious, "("), "353:15: " + getCheckMessage(clazz, messageKeyPreceded, "("), "358:13: " + getCheckMessage(clazz, messageKeyPrevious, "(") };
    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)

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