use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class CustomImportOrderCheckTest method testOrderRuleWithOneGroup.
@Test
public void testOrderRuleWithOneGroup() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(CustomImportOrderCheck.class);
checkConfig.addAttribute("thirdPartyPackageRegExp", "org.");
checkConfig.addAttribute("customImportOrderRules", "STANDARD_JAVA_PACKAGE");
checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true");
final String[] expected = { "4: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), "7: " + getCheckMessage(MSG_LEX, "java.util.List", "javax.swing.WindowConstants.*"), "8: " + getCheckMessage(MSG_LEX, "java.util.StringTokenizer", "javax.swing.WindowConstants.*"), "9: " + getCheckMessage(MSG_LEX, "java.util.*", "javax.swing.WindowConstants.*"), "10: " + getCheckMessage(MSG_LEX, "java.util.concurrent.AbstractExecutorService", "javax.swing.WindowConstants.*"), "11: " + getCheckMessage(MSG_LEX, "java.util.concurrent.*", "javax.swing.WindowConstants.*"), "14: " + getCheckMessage(MSG_LEX, "com.*", "com.puppycrawl.tools.*"), "16: " + getCheckMessage(MSG_LEX, "com.google.common.base.*", "com.puppycrawl.tools.*") };
verify(checkConfig, getPath("InputCustomImportOrder2.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class CustomImportOrderCheckTest method testWithoutThirdPartyPackage.
@Test
public void testWithoutThirdPartyPackage() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(CustomImportOrderCheck.class);
checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true");
checkConfig.addAttribute("separateLineBetweenGroups", "true");
checkConfig.addAttribute("customImportOrderRules", "SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC");
final String[] expected = { "4: " + getCheckMessage(MSG_LINE_SEPARATOR, "org.junit.*") };
verify(checkConfig, getPath("InputCustomImportOrderThirdPartyPackage.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class CustomImportOrderCheckTest method testImportsContainingJava.
@Test
public void testImportsContainingJava() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(CustomImportOrderCheck.class);
checkConfig.addAttribute("customImportOrderRules", "STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE");
final String[] expected = { "5: " + getCheckMessage(MSG_LINE_SEPARATOR, "com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck") };
verify(checkConfig, getPath("InputCustomImportOrderImportsContainingJava.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class IllegalImportCheckTest method testWithSupplied.
@Test
public void testWithSupplied() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(IllegalImportCheck.class);
checkConfig.addAttribute("illegalPkgs", "java.io");
final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY, "java.io.*"), "23:1: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), "27:1: " + getCheckMessage(MSG_KEY, "java.io.File.createTempFile") };
verify(checkConfig, getPath("InputIllegalImport.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class IllegalImportCheckTest method testWithDefault.
@Test
public void testWithDefault() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(IllegalImportCheck.class);
final String[] expected = { "15:1: " + getCheckMessage(MSG_KEY, "sun.applet.*"), "28:1: " + getCheckMessage(MSG_KEY, "sun.*") };
verify(checkConfig, getPath("InputIllegalImport.java"), expected);
}
Aggregations