Search in sources :

Example 21 with Configuration

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

the class OperatorWrapTest method operatorWrapTest.

@Test
public void operatorWrapTest() throws Exception {
    final Class<OperatorWrapCheck> clazz = OperatorWrapCheck.class;
    final String messageKey = "line.new";
    final String[] expected = { "11:27: " + getCheckMessage(clazz, messageKey, "+"), "12:28: " + getCheckMessage(clazz, messageKey, "-"), "20:27: " + getCheckMessage(clazz, messageKey, "&&"), "62:42: " + getCheckMessage(clazz, messageKey, "?"), "66:27: " + getCheckMessage(clazz, messageKey, "!="), "72:30: " + getCheckMessage(clazz, messageKey, "=="), "78:27: " + getCheckMessage(clazz, messageKey, ">"), "84:35: " + getCheckMessage(clazz, messageKey, "||"), "107:46: " + getCheckMessage(clazz, messageKey, "?"), "111:31: " + getCheckMessage(clazz, messageKey, "!="), "117:34: " + getCheckMessage(clazz, messageKey, "=="), "123:31: " + getCheckMessage(clazz, messageKey, ">"), "129:39: " + getCheckMessage(clazz, messageKey, "||"), "153:46: " + getCheckMessage(clazz, messageKey, "?"), "157:31: " + getCheckMessage(clazz, messageKey, "!="), "163:34: " + getCheckMessage(clazz, messageKey, "=="), "169:31: " + getCheckMessage(clazz, messageKey, ">"), "175:39: " + getCheckMessage(clazz, messageKey, "||"), "194:38: " + getCheckMessage(clazz, messageKey, "?") };
    final Configuration checkConfig = getCheckConfig("OperatorWrap");
    final String filePath = getPath("InputOperatorWrap.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) OperatorWrapCheck(com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck) Test(org.junit.Test)

Example 22 with Configuration

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

the class SeparatorWrapTest method separatorWrapCommaTest.

@Test
public void separatorWrapCommaTest() throws Exception {
    final String[] expected = { "31:17: " + getCheckMessage(SeparatorWrapCheck.class, "line.previous", ",") };
    final Configuration checkConfig = getCheckConfig("SeparatorWrap", "SeparatorWrapComma");
    final String filePath = getPath("InputSeparatorWrapComma.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 23 with Configuration

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

the class AvoidStarImportTest method starImportTest.

@Test
public void starImportTest() throws Exception {
    final String[] expected = { "3: Using the '.*' form of import should be avoided - java.io.*.", "4: Using the '.*' form of import should be avoided - java.lang.*.", "18: Using the '.*' form of import should be avoided - javax.swing.WindowConstants.*.", "19: Using the '.*' form of import should be avoided - javax.swing.WindowConstants.*." };
    final Configuration checkConfig = getCheckConfig("AvoidStarImport");
    final String filePath = getPath("InputAvoidStarImport.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 24 with Configuration

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

the class NoLineWrapTest method badLineWrapTest.

@Test
public void badLineWrapTest() throws Exception {
    final String[] expected = { "1: " + getCheckMessage(NoLineWrapCheck.class, "no.line.wrap", "package"), "6: " + getCheckMessage(NoLineWrapCheck.class, "no.line.wrap", "import") };
    final Configuration checkConfig = getCheckConfig("NoLineWrap");
    final String filePath = getPath("InputNoLineWrapBad.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 25 with Configuration

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

the class NoLineWrapTest method goodLineWrapTest.

@Test
public void goodLineWrapTest() throws Exception {
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    final Configuration checkConfig = getCheckConfig("NoLineWrap");
    final String filePath = getPath("InputNoLineWrapGood.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) 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