Search in sources :

Example 26 with DefaultConfiguration

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

the class JavadocStyleCheckTest method testDefaultSettings.

@Test
public void testDefaultSettings() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(JavadocStyleCheck.class);
    final String[] expected = { "20: " + getCheckMessage(MSG_NO_PERIOD), "53: " + getCheckMessage(MSG_NO_PERIOD), "63:11: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>This guy is missing end of bold tag"), "66:7: " + getCheckMessage(MSG_EXTRA_HTML, "</td>Extra tag shouldn't be here"), "68:19: " + getCheckMessage(MSG_UNCLOSED_HTML, "<code>dummy."), "74: " + getCheckMessage(MSG_NO_PERIOD), "75:23: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>should fail"), "81: " + getCheckMessage(MSG_NO_PERIOD), "82:31: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>should fail"), "88: " + getCheckMessage(MSG_NO_PERIOD), "89:31: " + getCheckMessage(MSG_EXTRA_HTML, "</code>"), "90: " + getCheckMessage(MSG_INCOMPLETE_TAG, "    * should fail <"), "109:39: " + getCheckMessage(MSG_EXTRA_HTML, "</img>"), "186:8: " + getCheckMessage(MSG_UNCLOSED_HTML, "<blockquote>"), "193: " + getCheckMessage(MSG_NO_PERIOD), "238: " + getCheckMessage(MSG_NO_PERIOD), "335:33: " + getCheckMessage(MSG_EXTRA_HTML, "</string>"), "361:37: " + getCheckMessage(MSG_UNCLOSED_HTML, "<code>"), "372: " + getCheckMessage(MSG_NO_PERIOD), "378:15: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>Note:<b> it's unterminated tag.</p>"), "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)

Example 27 with DefaultConfiguration

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

the class JavadocStyleCheckTest method testRestrictedTokenSet.

@Test
public void testRestrictedTokenSet() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(JavadocStyleCheck.class);
    checkConfig.addAttribute("tokens", "METHOD_DEF");
    checkConfig.addAttribute("scope", "public");
    checkConfig.addAttribute("checkFirstSentence", "true");
    checkConfig.addAttribute("checkEmptyJavadoc", "false");
    checkConfig.addAttribute("checkHtml", "false");
    final String[] expected = { "88: " + 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 28 with DefaultConfiguration

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

the class JavadocTypeCheckTest method testTags.

@Test
public void testTags() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(JavadocTypeCheck.class);
    final String[] expected = { "8: " + getCheckMessage(MSG_JAVADOC_MISSING), "302: " + getCheckMessage(MSG_JAVADOC_MISSING), "327: " + getCheckMessage(MSG_JAVADOC_MISSING) };
    verify(checkConfig, getPath("InputTags.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 29 with DefaultConfiguration

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

the class JavadocTypeCheckTest method testAuthorRegularEx.

@Test
public void testAuthorRegularEx() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(JavadocTypeCheck.class);
    checkConfig.addAttribute("authorFormat", "0*");
    final String[] expected = { "22: " + getCheckMessage(MSG_MISSING_TAG, "@author"), "58: " + getCheckMessage(MSG_MISSING_TAG, "@author"), "94: " + getCheckMessage(MSG_MISSING_TAG, "@author") };
    verify(checkConfig, getPath("InputJavadoc.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 30 with DefaultConfiguration

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

the class JavadocTypeCheckTest method testBadTagSuppress.

@Test
public void testBadTagSuppress() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(JavadocTypeCheck.class);
    checkConfig.addAttribute("allowUnknownTags", "true");
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(checkConfig, getPath("InputBadTag.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