use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class ImportControlCheckTest method testRegExpInPackage.
// all import-control_pkg-re* files should be equivalent so use one test for all
private void testRegExpInPackage(String file) throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(ImportControlCheck.class);
checkConfig.addAttribute("file", getPath(file));
final String[] expected = { "5:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File") };
verify(checkConfig, getPath("InputImportControl.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class ImportControlCheckTest method testEmpty.
@Test
public void testEmpty() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(ImportControlCheck.class);
checkConfig.addAttribute("file", " ");
final String[] expected = { "1:1: " + getCheckMessage(MSG_MISSING_FILE) };
verify(checkConfig, getPath("InputImportControl.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class CustomImportOrderCheckTest method testNoPackage2.
@Test
public void testNoPackage2() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(CustomImportOrderCheck.class);
checkConfig.addAttribute("customImportOrderRules", "STATIC###THIRD_PARTY_PACKAGE");
checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true");
checkConfig.addAttribute("separateLineBetweenGroups", "true");
createChecker(checkConfig);
final String[] expected = { "3: " + getCheckMessage(MSG_LINE_SEPARATOR, "com.puppycrawl.tools.checkstyle.utils.AnnotationUtility.containsAnnotation"), "7: " + getCheckMessage(MSG_LINE_SEPARATOR, "com.sun.accessibility.internal.resources.*"), "11: " + getCheckMessage(MSG_LINE_SEPARATOR, "java.util.Arrays"), "19: " + getCheckMessage(MSG_LINE_SEPARATOR, "org.apache.commons.beanutils.converters.ArrayConverter") };
verify(checkConfig, getPath("InputCustomImportOrderNoPackage2.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class CustomImportOrderCheckTest method testDefaultPackage2.
@Test
public void testDefaultPackage2() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(CustomImportOrderCheck.class);
checkConfig.addAttribute("thirdPartyPackageRegExp", "com|org");
checkConfig.addAttribute("customImportOrderRules", "STATIC###SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE");
checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true");
final String[] expected = { "7: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), "10: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.awt.Button"), "11: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.awt.Frame"), "12: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.awt.Dialog"), "13: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.awt.event.ActionEvent"), "14: " + getCheckMessage(MSG_ORDER, STD, THIRD, "javax.swing.JComponent"), "15: " + getCheckMessage(MSG_ORDER, STD, THIRD, "javax.swing.JTable"), "16: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.io.File"), "17: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.io.IOException"), "18: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.io.InputStream"), "19: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.io.Reader"), "23: " + getCheckMessage(MSG_LEX, "com.google.common.*", "com.puppycrawl.tools.*") };
verify(checkConfig, getNonCompilablePath("InputDefaultPackage.java"), expected);
}
use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.
the class CustomImportOrderCheckTest method testWithoutLineSeparator2.
@Test
public void testWithoutLineSeparator2() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(CustomImportOrderCheck.class);
checkConfig.addAttribute("separateLineBetweenGroups", "false");
checkConfig.addAttribute("customImportOrderRules", "STATIC###STANDARD_JAVA_PACKAGE");
checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true");
final String[] expected = { "4: " + getCheckMessage(MSG_LEX, "java.io.File.createTempFile", "javax.swing.WindowConstants.*"), "8: " + getCheckMessage(MSG_LEX, "com.*", "com.puppycrawl.tools.*") };
verify(checkConfig, getPath("InputCustomImportOrder_NoSeparator.java"), expected);
}
Aggregations