Search in sources :

Example 16 with DefaultConfiguration

use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.

the class BooleanExpressionComplexityCheckTest method testNullPointerException.

@Test
public void testNullPointerException() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(BooleanExpressionComplexityCheck.class);
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(checkConfig, getPath("InputBooleanExpressionComplexityNPE.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 17 with DefaultConfiguration

use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.

the class BooleanExpressionComplexityCheckTest method testNoBitwise.

@Test
public void testNoBitwise() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(BooleanExpressionComplexityCheck.class);
    checkConfig.addAttribute("max", "5");
    checkConfig.addAttribute("tokens", "BXOR,LAND,LOR");
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(checkConfig, getPath("InputBooleanExpressionComplexity.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 18 with DefaultConfiguration

use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.

the class ClassDataAbstractionCouplingCheckTest method test.

@Test
public void test() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(ClassDataAbstractionCouplingCheck.class);
    checkConfig.addAttribute("max", "0");
    checkConfig.addAttribute("excludedClasses", "InnerClass");
    final String[] expected = { "6:1: " + getCheckMessage(MSG_KEY, 4, 0, "[AnotherInnerClass, HashMap, HashSet, int]"), "7:5: " + getCheckMessage(MSG_KEY, 1, 0, "[ArrayList]"), "27:1: " + getCheckMessage(MSG_KEY, 2, 0, "[HashMap, HashSet]") };
    verify(checkConfig, getPath("InputClassCoupling.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 19 with DefaultConfiguration

use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.

the class ClassFanOutComplexityCheckTest method testDefaultConfiguration.

@Test
public void testDefaultConfiguration() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(ClassFanOutComplexityCheck.class);
    createChecker(checkConfig);
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(checkConfig, getPath("InputClassCoupling.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 20 with DefaultConfiguration

use of com.puppycrawl.tools.checkstyle.DefaultConfiguration in project checkstyle by checkstyle.

the class JavadocPackageCheckTest method testHtmlAllowed.

@Test
public void testHtmlAllowed() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(JavadocPackageCheck.class);
    checkConfig.addAttribute("allowLegacy", "true");
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(createChecker(checkConfig), getPath("pkghtml" + File.separator + "InputIgnored.java"), getPath("pkghtml" + File.separator + "package-info.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Aggregations

DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)1004 Test (org.junit.Test)986 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)47 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)31 File (java.io.File)22 Checker (com.puppycrawl.tools.checkstyle.Checker)16 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)13 BriefUtLogger (com.puppycrawl.tools.checkstyle.BriefUtLogger)10 Locale (java.util.Locale)5 Method (java.lang.reflect.Method)4 IllegalCatchCheck (com.puppycrawl.tools.checkstyle.checks.coding.IllegalCatchCheck)3 IOException (java.io.IOException)3 BaseCheckTestSupport (com.puppycrawl.tools.checkstyle.BaseCheckTestSupport)2 Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)2 LocalizedMessage (com.puppycrawl.tools.checkstyle.api.LocalizedMessage)2 FileContentsHolder (com.puppycrawl.tools.checkstyle.checks.FileContentsHolder)2 RandomAccessFile (java.io.RandomAccessFile)2 PropertiesExpander (com.puppycrawl.tools.checkstyle.PropertiesExpander)1 TokenTypes (com.puppycrawl.tools.checkstyle.api.TokenTypes)1 MSG_KEY (com.puppycrawl.tools.checkstyle.checks.AvoidEscapedUnicodeCharactersCheck.MSG_KEY)1