Search in sources :

Example 56 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class LeftCurlyTest method leftCurlyMethodsTest.

@Test
public void leftCurlyMethodsTest() throws Exception {
    final String[] expected = { "4:1: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 1), "9:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "16:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "19:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "23:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "31:1: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 1), "33:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "38:9: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 9), "41:9: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 9), "45:9: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 9), "57:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "61:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "69:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "72:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), "76:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5) };
    final Configuration checkConfig = getCheckConfig("LeftCurly");
    final String filePath = getPath("InputLeftCurlyMethod.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 57 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class RightCurlyTest method rightCurlyTestAlone.

@Test
public void rightCurlyTestAlone() throws Exception {
    final String[] expected = { "20:17: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 17), "32:13: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 13), "79:27: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_BREAK_BEFORE, "}", 27) };
    final Configuration checkConfig = getCheckConfig("RightCurly", "RightCurlySame");
    final String filePath = getPath("InputRightCurlyOther.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 58 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class RightCurlyTest method testRightCurlyAloneOther.

@Test
public void testRightCurlyAloneOther() throws Exception {
    final String[] expected = { "97:5: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_ALONE, "}", 5), "97:6: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_NEW, "}", 6), "108:5: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_ALONE, "}", 5), "108:6: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_NEW, "}", 6), "122:6: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_NEW, "}", 6) };
    final Configuration checkConfig = getCheckConfig("RightCurly", "RightCurlyAlone");
    final String filePath = getPath("InputRightCurlyOtherAlone.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 59 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class RightCurlyTest method testRightCurlyAloneSameAndLiteralDo.

@Test
public void testRightCurlyAloneSameAndLiteralDo() throws Exception {
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    final Configuration checkConfig = getCheckConfig("RightCurly", "RightCurlyAlone");
    final String filePath = getPath("InputRightCurlyDoWhileAlone.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 60 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class JavadocMethodTest method javadocMethodTest.

@Test
public void javadocMethodTest() throws Exception {
    final String msg = getCheckMessage(JavadocMethodCheck.class, "javadoc.missing");
    final String[] expected = { "57:5: " + msg };
    final Configuration checkConfig = getCheckConfig("JavadocMethod");
    final String filePath = getPath("InputJavadocMethodCheck.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Aggregations

Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)137 Test (org.junit.Test)127 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)21 DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)16 Properties (java.util.Properties)13 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)9 File (java.io.File)9 Checker (com.puppycrawl.tools.checkstyle.Checker)5 PropertiesExpander (com.puppycrawl.tools.checkstyle.PropertiesExpander)4 OneTopLevelClassCheck (com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 ModuleFactory (com.puppycrawl.tools.checkstyle.ModuleFactory)2 AuditListener (com.puppycrawl.tools.checkstyle.api.AuditListener)2 RootModule (com.puppycrawl.tools.checkstyle.api.RootModule)2 AnnotationLocationCheck (com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck)2 EmptyLineSeparatorCheck (com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck)2 MethodParamPadCheck (com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2