Search in sources :

Example 26 with Configuration

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

the class CustomImportOrderTest method customImportTest1.

@Test
public void customImportTest1() throws Exception {
    final String[] expected = { "4: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), "6: " + getCheckMessage(clazz, MSG_LINE_SEPARATOR, "java.awt.Button"), "8: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Dialog", "java.awt.Frame"), "12: " + getCheckMessage(clazz, MSG_LEX, "java.io.File", "javax.swing.JTable"), "13: " + getCheckMessage(clazz, MSG_LEX, "java.io.IOException", "javax.swing.JTable"), "14: " + getCheckMessage(clazz, MSG_LEX, "java.io.InputStream", "javax.swing.JTable"), "15: " + getCheckMessage(clazz, MSG_LEX, "java.io.Reader", "javax.swing.JTable"), "17: " + getCheckMessage(clazz, MSG_LEX, "com.google.common.base.Ascii", "javax.swing.JTable") };
    final Configuration checkConfig = getCheckConfig("CustomImportOrder");
    final String filePath = getPath("InputCustomImportOrder1.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 27 with Configuration

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

the class CustomImportOrderTest method validGoogleStyleOrderOfImportsTest.

@Test
public void validGoogleStyleOrderOfImportsTest() throws Exception {
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    final Configuration checkConfig = getCheckConfig("CustomImportOrder");
    final String filePath = getPath("InputCustomImportOrderNoImports.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 28 with Configuration

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

the class CustomImportOrderTest method validTest.

@Test
public void validTest() throws Exception {
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    final Configuration checkConfig = getCheckConfig("CustomImportOrder");
    final String filePath = getPath("InputCustomImportOrderValid.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 29 with Configuration

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

the class CustomImportOrderTest method customImportTest2.

@Test
public void customImportTest2() throws Exception {
    final String[] expected = { "4: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), "9: " + getCheckMessage(clazz, MSG_LEX, "java.util.*", "java.util.StringTokenizer"), "11: " + getCheckMessage(clazz, MSG_LEX, "java.util.concurrent.*", "java.util.concurrent.AbstractExecutorService"), "13: " + getCheckMessage(clazz, MSG_LEX, "com.google.checkstyle.test.chapter2filebasic.rule21filename.*", "java.util.concurrent.AbstractExecutorService"), "14: " + getCheckMessage(clazz, MSG_LEX, "com.sun.xml.internal.xsom.impl.scd.Iterators", "java.util.concurrent.AbstractExecutorService"), "16: " + getCheckMessage(clazz, MSG_LEX, "com.google.common.reflect.*", "java.util.concurrent.AbstractExecutorService") };
    final Configuration checkConfig = getCheckConfig("CustomImportOrder");
    final String filePath = getPath("InputCustomImportOrder2.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 30 with Configuration

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

the class OneTopLevelClassTest method bad2Test.

@Test
public void bad2Test() throws Exception {
    final Class<OneTopLevelClassCheck> clazz = OneTopLevelClassCheck.class;
    final String messageKey = "one.top.level.class";
    final String[] expected = { "5: " + getCheckMessage(clazz, messageKey, "FooIn"), "7: " + getCheckMessage(clazz, messageKey, "FooClass") };
    final Configuration checkConfig = getCheckConfig("OneTopLevelClass");
    final String filePath = getPath("InputOneTopLevelClassBad2.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) OneTopLevelClassCheck(com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck) 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