Search in sources :

Example 51 with DefaultConfiguration

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

the class VisibilityModifierCheckTest method testImmutableValueSameTypeName.

@Test
public void testImmutableValueSameTypeName() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(VisibilityModifierCheck.class);
    checkConfig.addAttribute("allowPublicImmutableFields", "true");
    final String[] expected = { "7:46: " + getCheckMessage(MSG_KEY, "calendar"), "8:41: " + getCheckMessage(MSG_KEY, "calendar2"), "9:87: " + getCheckMessage(MSG_KEY, "calendar3"), "10:36: " + getCheckMessage(MSG_KEY, "address") };
    verify(checkConfig, getPath("InputImmutableSameTypeName.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 52 with DefaultConfiguration

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

the class VisibilityModifierCheckTest method testPublicFinalFieldsAllowed.

@Test
public void testPublicFinalFieldsAllowed() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(VisibilityModifierCheck.class);
    checkConfig.addAttribute("allowPublicFinalFields", "true");
    checkConfig.addAttribute("immutableClassCanonicalNames", "com.google.common.collect.ImmutableSet");
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(checkConfig, getPath("InputPublicImmutable.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 53 with DefaultConfiguration

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

the class HideUtilityClassConstructorCheckTest method testUtilClassPrivateCtor.

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

Example 54 with DefaultConfiguration

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

the class HideUtilityClassConstructorCheckTest method testEmptyClassWithOnlyPrivateFields.

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

Example 55 with DefaultConfiguration

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

the class HideUtilityClassConstructorCheckTest method testUtilClass.

@Test
public void testUtilClass() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(HideUtilityClassConstructorCheck.class);
    final String[] expected = { "3:1: " + getCheckMessage(MSG_KEY) };
    verify(checkConfig, getPath("InputUtilityClassConstructor.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