Search in sources :

Example 36 with DefaultConfiguration

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

the class HideUtilityClassConstructorCheckTest method testProtectedCtor.

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

Example 37 with DefaultConfiguration

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

the class OneTopLevelClassCheckTest method testFileWithThreeTopLevelEnum.

@Test
public void testFileWithThreeTopLevelEnum() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(OneTopLevelClassCheck.class);
    final String[] expected = { "3: " + getCheckMessage(MSG_KEY, "InputOneTopLevelEnum2inner1"), "11: " + getCheckMessage(MSG_KEY, "InputOneTopLevelEnum2inner2") };
    verify(checkConfig, getPath("InputOneTopLevelEnum2.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 38 with DefaultConfiguration

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

the class OneTopLevelClassCheckTest method testFileWithFewTopLevelClasses.

@Test
public void testFileWithFewTopLevelClasses() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(OneTopLevelClassCheck.class);
    final String[] expected = { "25: " + getCheckMessage(MSG_KEY, "NoSuperClone"), "29: " + getCheckMessage(MSG_KEY, "InnerClone"), "33: " + getCheckMessage(MSG_KEY, "CloneWithTypeArguments"), "37: " + getCheckMessage(MSG_KEY, "CloneWithTypeArgumentsAndNoSuper"), "41: " + getCheckMessage(MSG_KEY, "MyClassWithGenericSuperMethod"), "45: " + getCheckMessage(MSG_KEY, "AnotherClass"), "48: " + getCheckMessage(MSG_KEY, "NativeTest") };
    verify(checkConfig, getPath("InputClone.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 39 with DefaultConfiguration

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

the class OneTopLevelClassCheckTest method testFileWithSecondEnumTopLevelClass.

@Test
public void testFileWithSecondEnumTopLevelClass() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(OneTopLevelClassCheck.class);
    final String[] expected = { "10: " + getCheckMessage(MSG_KEY, "InputDeclarationOrderEnum") };
    verify(checkConfig, getPath("InputDeclarationOrder.java"), expected);
}
Also used : DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Example 40 with DefaultConfiguration

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

the class OneTopLevelClassCheckTest method testFileWithOneTopLevelEnum.

@Test
public void testFileWithOneTopLevelEnum() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(OneTopLevelClassCheck.class);
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    verify(checkConfig, getPath("InputOneTopLevelEnum.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