Search in sources :

Example 21 with DefaultConfiguration

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

the class JavadocPackageCheckTest method testMissingWithAllowLegacy.

@Test
public void testMissingWithAllowLegacy() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(JavadocPackageCheck.class);
    checkConfig.addAttribute("allowLegacy", "true");
    final String[] expected = { "0: " + getCheckMessage(MSG_PACKAGE_INFO) };
    verify(createChecker(checkConfig), getPath("InputBadCls.java"), getPath("InputBadCls.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 22 with DefaultConfiguration

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

the class JavadocStyleCheckTest method packageInfoMissing.

@Test
public void packageInfoMissing() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(JavadocStyleCheck.class);
    final String[] expected = { "1: " + getCheckMessage(MSG_JAVADOC_MISSING) };
    verify(createChecker(checkConfig), getPath("bothfiles" + File.separator + "package-info.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 23 with DefaultConfiguration

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

the class JavadocStyleCheckTest method packageInfoAnnotation.

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

Example 24 with DefaultConfiguration

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

the class JavadocStyleCheckTest method testScopePublic.

@Test
public void testScopePublic() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(JavadocStyleCheck.class);
    checkConfig.addAttribute("checkFirstSentence", "true");
    checkConfig.addAttribute("checkHtml", "true");
    checkConfig.addAttribute("checkEmptyJavadoc", "true");
    checkConfig.addAttribute("scope", "public");
    final String[] expected = { "88: " + getCheckMessage(MSG_NO_PERIOD), "89:31: " + getCheckMessage(MSG_EXTRA_HTML, "</code>"), "90: " + getCheckMessage(MSG_INCOMPLETE_TAG, "    * should fail <"), "205: " + getCheckMessage(MSG_EMPTY), "230: " + getCheckMessage(MSG_EMPTY), "238: " + getCheckMessage(MSG_NO_PERIOD), "335:33: " + getCheckMessage(MSG_EXTRA_HTML, "</string>"), "382: " + getCheckMessage(MSG_NO_PERIOD), "386: " + getCheckMessage(MSG_NO_PERIOD), "418: " + getCheckMessage(MSG_NO_PERIOD) };
    verify(checkConfig, getPath("InputJavadocStyle.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 25 with DefaultConfiguration

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

the class JavadocStyleCheckTest method testFirstSentence.

@Test
public void testFirstSentence() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(JavadocStyleCheck.class);
    checkConfig.addAttribute("checkFirstSentence", "true");
    checkConfig.addAttribute("checkHtml", "false");
    final String[] expected = { "20: " + getCheckMessage(MSG_NO_PERIOD), "53: " + getCheckMessage(MSG_NO_PERIOD), "74: " + getCheckMessage(MSG_NO_PERIOD), "81: " + getCheckMessage(MSG_NO_PERIOD), "88: " + getCheckMessage(MSG_NO_PERIOD), "193: " + getCheckMessage(MSG_NO_PERIOD), "238: " + getCheckMessage(MSG_NO_PERIOD), "372: " + getCheckMessage(MSG_NO_PERIOD), "382: " + getCheckMessage(MSG_NO_PERIOD), "386: " + getCheckMessage(MSG_NO_PERIOD), "393: " + getCheckMessage(MSG_NO_PERIOD), "405: " + getCheckMessage(MSG_NO_PERIOD), "418: " + getCheckMessage(MSG_NO_PERIOD) };
    verify(checkConfig, getPath("InputJavadocStyle.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