Search in sources :

Example 86 with DefaultConfiguration

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

the class ModifierOrderCheckTest method testAnnotationOnAnnotationDeclaration.

@Test
public void testAnnotationOnAnnotationDeclaration() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(ModifierOrderCheck.class);
    final String[] expected = { "3:8: " + getCheckMessage(MSG_ANNOTATION_ORDER, "@InterfaceAnnotation") };
    verify(checkConfig, getPath("InputModifierOrderAnnotationDeclaration.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 87 with DefaultConfiguration

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

the class ModifierOrderCheckTest method testDefaultMethods.

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

Example 88 with DefaultConfiguration

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

the class ModifierOrderCheckTest method testSkipTypeAnnotations.

@Test
public void testSkipTypeAnnotations() throws Exception {
    // Type Annotations are avaliable only in Java 8
    // We skip type annotations from validation
    // See https://github.com/checkstyle/checkstyle/issues/903#issuecomment-172228013
    final DefaultConfiguration checkConfig = createCheckConfig(ModifierOrderCheck.class);
    final String[] expected = { "103:13: " + getCheckMessage(MSG_ANNOTATION_ORDER, "@MethodAnnotation") };
    verify(checkConfig, getNonCompilablePath("InputTypeAnnotations.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 89 with DefaultConfiguration

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

the class RedundantModifierCheckTest method testIt.

@Test
public void testIt() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(RedundantModifierCheck.class);
    final String[] expected = { "54:12: " + getCheckMessage(MSG_KEY, "static"), "57:9: " + getCheckMessage(MSG_KEY, "public"), "63:9: " + getCheckMessage(MSG_KEY, "abstract"), "66:9: " + getCheckMessage(MSG_KEY, "public"), //"69:9: Redundant 'abstract' modifier.",
    "72:9: " + getCheckMessage(MSG_KEY, "final"), "79:13: " + getCheckMessage(MSG_KEY, "final"), "88:12: " + getCheckMessage(MSG_KEY, "final"), "99:1: " + getCheckMessage(MSG_KEY, "abstract"), "116:5: " + getCheckMessage(MSG_KEY, "public"), "117:5: " + getCheckMessage(MSG_KEY, "final"), "118:5: " + getCheckMessage(MSG_KEY, "static"), "120:5: " + getCheckMessage(MSG_KEY, "public"), "121:5: " + getCheckMessage(MSG_KEY, "abstract") };
    verify(checkConfig, getPath("InputModifier.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 90 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)

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