Search in sources :

Example 66 with Configuration

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

the class FallThroughTest method fallThroughTest.

@Test
public void fallThroughTest() throws Exception {
    final String msg = getCheckMessage(FallThroughCheck.class, "fall.through");
    final String[] expected = { "14:13: " + msg, "38:13: " + msg, "47:13: " + msg, "53:13: " + msg, "70:13: " + msg, "87:13: " + msg, "123:13: " + msg, "179:11: " + msg, "369:11: " + msg, "372:11: " + msg, "374:41: " + msg };
    final Configuration checkConfig = getCheckConfig("FallThrough");
    final String filePath = getPath("InputFallThrough.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 67 with Configuration

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

the class MissingSwitchDefaultTest method missingSwitchDefaultTest.

@Test
public void missingSwitchDefaultTest() throws Exception {
    final String msg = getCheckMessage(MissingSwitchDefaultCheck.class, "missing.switch.default");
    final String[] expected = { "11: " + msg, "19: " + msg, "23: " + msg, "31: " + msg, "38: " + msg, "42: " + msg };
    final Configuration checkConfig = getCheckConfig("MissingSwitchDefault");
    final String filePath = getPath("InputMissingSwitchDefault.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 68 with Configuration

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

the class AnnotationLocationTest method annotationTest.

@Test
public void annotationTest() throws Exception {
    final Class<AnnotationLocationCheck> clazz = AnnotationLocationCheck.class;
    getCheckMessage(clazz, "annotation.location.alone");
    final Configuration checkConfig = getCheckConfig("AnnotationLocation", "AnnotationLocationMostCases");
    final String msgLocationAlone = "annotation.location.alone";
    final String msgLocation = "annotation.location";
    final String[] expected = { "3: " + getCheckMessage(clazz, msgLocationAlone, "MyAnnotation1"), "20: " + getCheckMessage(clazz, msgLocation, "MyAnnotation1", "8", "4"), "27: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "7", "4"), "31: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "8", "4"), "32: " + getCheckMessage(clazz, msgLocation, "MyAnnotation3", "6", "4"), "33: " + getCheckMessage(clazz, msgLocation, "MyAnnotation4", "10", "4"), "54: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "12", "8"), "58: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "12", "8"), "78: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "11", "8"), "81: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "10", "8"), "90: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "1", "0") };
    final String filePath = getPath("InputAnnotationLocation.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) AnnotationLocationCheck(com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck) Test(org.junit.Test)

Example 69 with Configuration

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

the class CommentsIndentationTest method testCommentIsAtTheEndOfBlock.

@Test
public void testCommentIsAtTheEndOfBlock() throws Exception {
    final String[] expected = { "18: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 17, 25, 8), "33: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 35, 5, 4), "37: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 36, 0, 8), "47: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 46, 15, 12), "49: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 45, 10, 8), "54: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 53, 13, 8), "74: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 70, 18, 8), "88: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 85, 31, 8), "100: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 98, 21, 8), "115: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 116, 29, 12), "138: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 131, 26, 8), "164: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 161, 33, 8), "174: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 173, 21, 8), "186: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 184, 34, 8), "208: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 206, 26, 8), "214: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 213, 0, 8), "228: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 225, 12, 8), "234: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 233, 0, 8), "248: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 245, 12, 8), "255: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 252, 0, 8), "265: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 264, 14, 8), "271: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 269, 9, 8), "277: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 276, 9, 8), "316: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 315, 9, 8), "322: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 323, 0, 4), "336: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 333, 0, 8), "355: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 352, 9, 8) };
    final Configuration checkConfig = getCheckConfig("CommentsIndentation");
    final String filePath = getPath("InputCommentsIndentationCommentIsAtTheEndOfBlock.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 70 with Configuration

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

the class NoFinalizerTest method noFinalizerExtendedTest.

@Test
public void noFinalizerExtendedTest() throws Exception {
    final String msg = getCheckMessage(NoFinalizerCheck.class, "avoid.finalizer.method");
    final String[] expected = { "9: " + msg, "21: " + msg, "33: " + msg, "45: " + msg, "57: " + msg, "69: " + msg, "79: " + msg, "119: " + msg, "136: " + msg };
    final Configuration checkConfig = getCheckConfig("NoFinalizer");
    final String filePath = getPath("InputNoFinalizeExtend.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