Search in sources :

Example 76 with DefaultConfiguration

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

the class AtclauseOrderCheckTest method testIncorrect.

@Test
public void testIncorrect() throws Exception {
    final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]";
    final DefaultConfiguration checkConfig = createCheckConfig(AtclauseOrderCheck.class);
    final String[] expected = { "9: " + getCheckMessage(MSG_KEY, tagOrder), "11: " + getCheckMessage(MSG_KEY, tagOrder), "12: " + getCheckMessage(MSG_KEY, tagOrder), "40: " + getCheckMessage(MSG_KEY, tagOrder), "50: " + getCheckMessage(MSG_KEY, tagOrder), "51: " + getCheckMessage(MSG_KEY, tagOrder), "52: " + getCheckMessage(MSG_KEY, tagOrder), "62: " + getCheckMessage(MSG_KEY, tagOrder), "69: " + getCheckMessage(MSG_KEY, tagOrder), "86: " + getCheckMessage(MSG_KEY, tagOrder), "87: " + getCheckMessage(MSG_KEY, tagOrder), "99: " + getCheckMessage(MSG_KEY, tagOrder), "100: " + getCheckMessage(MSG_KEY, tagOrder), "101: " + getCheckMessage(MSG_KEY, tagOrder), "115: " + getCheckMessage(MSG_KEY, tagOrder), "123: " + getCheckMessage(MSG_KEY, tagOrder), "124: " + getCheckMessage(MSG_KEY, tagOrder), "134: " + getCheckMessage(MSG_KEY, tagOrder), "135: " + getCheckMessage(MSG_KEY, tagOrder), "145: " + getCheckMessage(MSG_KEY, tagOrder), "146: " + getCheckMessage(MSG_KEY, tagOrder), "153: " + getCheckMessage(MSG_KEY, tagOrder), "161: " + getCheckMessage(MSG_KEY, tagOrder), "172: " + getCheckMessage(MSG_KEY, tagOrder), "183: " + getCheckMessage(MSG_KEY, tagOrder), "185: " + getCheckMessage(MSG_KEY, tagOrder), "199: " + getCheckMessage(MSG_KEY, tagOrder), "202: " + getCheckMessage(MSG_KEY, tagOrder), "213: " + getCheckMessage(MSG_KEY, tagOrder), "223: " + getCheckMessage(MSG_KEY, tagOrder), "230: " + getCheckMessage(MSG_KEY, tagOrder), "237: " + getCheckMessage(MSG_KEY, tagOrder), "247: " + getCheckMessage(MSG_KEY, tagOrder), "248: " + getCheckMessage(MSG_KEY, tagOrder), "259: " + getCheckMessage(MSG_KEY, tagOrder), "261: " + getCheckMessage(MSG_KEY, tagOrder), "275: " + getCheckMessage(MSG_KEY, tagOrder), "277: " + getCheckMessage(MSG_KEY, tagOrder), "278: " + getCheckMessage(MSG_KEY, tagOrder), "288: " + getCheckMessage(MSG_KEY, tagOrder) };
    verify(checkConfig, getPath("InputIncorrectAtClauseOrder.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 77 with DefaultConfiguration

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

the class JavadocMethodCheckTest method allowedAnnotationsTest.

@Test
public void allowedAnnotationsTest() throws Exception {
    final DefaultConfiguration config = createCheckConfig(JavadocMethodCheck.class);
    config.addAttribute("allowedAnnotations", "Override,ThisIsOk, \t\n\t ThisIsOkToo");
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(config, getPath("InputAllowedAnnotations.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 78 with DefaultConfiguration

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

the class JavadocMethodCheckTest method extendAnnotationTest.

@Test
public void extendAnnotationTest() throws Exception {
    final DefaultConfiguration config = createCheckConfig(JavadocMethodCheck.class);
    config.addAttribute("allowedAnnotations", "MyAnnotation, Override");
    config.addAttribute("minLineCount", "2");
    final String[] expected = { "44:1: " + getCheckMessage(MSG_JAVADOC_MISSING) };
    verify(config, getPath("InputExtendAnnotation.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 79 with DefaultConfiguration

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

the class JavadocMethodCheckTest method newTest.

@Test
public void newTest() throws Exception {
    final DefaultConfiguration config = createCheckConfig(JavadocMethodCheck.class);
    config.addAttribute("allowedAnnotations", "MyAnnotation, Override");
    config.addAttribute("minLineCount", "2");
    final String[] expected = { "57:5: " + getCheckMessage(MSG_JAVADOC_MISSING) };
    verify(config, getPath("InputJavadocMethodSmallMethods.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 80 with DefaultConfiguration

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

the class CyclomaticComplexityCheckTest method testHighMax.

@Test
public void testHighMax() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(CyclomaticComplexityCheck.class);
    checkConfig.addAttribute("max", "100");
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(checkConfig, getPath("InputComplexitySwitchBlocks.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