Issue #2161: unify test input locations for checks package
This commit is contained in:
parent
9c488c1f51
commit
f47587c9fb
|
|
@ -1,3 +1,3 @@
|
|||
/src/test/resources/com/puppycrawl/tools/checkstyle/InputNewlineLfAtEndOfFile.java eol=lf
|
||||
/src/test/resources/com/puppycrawl/tools/checkstyle/InputNewlineCrlfAtEndOfFile.java eol=crlf
|
||||
/src/test/resources/com/puppycrawl/tools/checkstyle/InputNewlineCrAtEndOfFile.java -text
|
||||
/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputNewlineLfAtEndOfFile.java eol=lf
|
||||
/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputNewlineCrlfAtEndOfFile.java eol=crlf
|
||||
/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputNewlineCrAtEndOfFile.java -text
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ package com.puppycrawl.tools.checkstyle.checks;
|
|||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -30,6 +33,10 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
|||
|
||||
public class ArrayTypeStyleCheckTest
|
||||
extends BaseCheckTestSupport {
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRequiredTokens() {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ package com.puppycrawl.tools.checkstyle.checks;
|
|||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -28,9 +31,13 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
|||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
||||
public class AvoidEscapedUnicodeCharactersCheckTest extends BaseCheckTestSupport {
|
||||
|
||||
private final String msg = getCheckMessage("forbid.escaped.unicode.char");
|
||||
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRequiredTokens() {
|
||||
AvoidEscapedUnicodeCharactersCheck checkObj =
|
||||
|
|
@ -186,5 +193,4 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends BaseCheckTestSupport
|
|||
int[] expected = {TokenTypes.STRING_LITERAL, TokenTypes.CHAR_LITERAL };
|
||||
assertArrayEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.DescendantTokenCheck.MSG_KE
|
|||
import static com.puppycrawl.tools.checkstyle.checks.DescendantTokenCheck.MSG_KEY_SUM_MIN;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.junit.Test;
|
||||
|
|
@ -33,13 +34,18 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
|||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
||||
public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault()
|
||||
throws Exception {
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(DescendantTokenCheck.class);
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
verify(checkConfig, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -53,7 +59,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
final String[] expected = {
|
||||
"17:12: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "LITERAL_NATIVE", "LITERAL_NATIVE"),
|
||||
};
|
||||
verify(checkConfig, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -68,7 +74,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
final String[] expected = {
|
||||
"17:12: Using 'native' is not allowed.",
|
||||
};
|
||||
verify(checkConfig, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -82,7 +88,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
final String[] expected = {
|
||||
"8:9: " + getCheckMessage(MSG_KEY_MIN, 1, 2, "LITERAL_SWITCH", "LITERAL_DEFAULT"),
|
||||
};
|
||||
verify(checkConfig, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -95,7 +101,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
checkConfig.addAttribute("maximumNumber", "0");
|
||||
checkConfig.addAttribute("minimumDepth", "3");
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
verify(checkConfig, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -108,7 +114,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
checkConfig.addAttribute("maximumNumber", "0");
|
||||
checkConfig.addAttribute("maximumDepth", "1");
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
verify(checkConfig, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -123,22 +129,22 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
checkConfig.addAttribute("maximumMessage", "Empty statement.");
|
||||
|
||||
final String[] expected = {
|
||||
"7:7: Empty statement.",
|
||||
"12:7: Empty statement.",
|
||||
"17:7: Empty statement.",
|
||||
"22:19: Empty statement.",
|
||||
"26:10: Empty statement.",
|
||||
"29:16: Empty statement.",
|
||||
"33:10: Empty statement.",
|
||||
"43:10: Empty statement.",
|
||||
"49:13: Empty statement.",
|
||||
"51:13: Empty statement.",
|
||||
"54:19: Empty statement.",
|
||||
"58:10: Empty statement.",
|
||||
"61:9: Empty statement.",
|
||||
"66:10: Empty statement.",
|
||||
"72:10: Empty statement.",
|
||||
"76:10: Empty statement.",
|
||||
"80:10: Empty statement.",
|
||||
"17:19: Empty statement.",
|
||||
"21:10: Empty statement.",
|
||||
"24:16: Empty statement.",
|
||||
"28:10: Empty statement.",
|
||||
"38:10: Empty statement.",
|
||||
"44:13: Empty statement.",
|
||||
"46:13: Empty statement.",
|
||||
"49:19: Empty statement.",
|
||||
"53:10: Empty statement.",
|
||||
"56:9: Empty statement.",
|
||||
"61:10: Empty statement.",
|
||||
"67:10: Empty statement.",
|
||||
"71:10: Empty statement.",
|
||||
"75:10: Empty statement.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("InputEmptyStatement.java"), expected);
|
||||
|
|
@ -158,7 +164,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
"17:9: switch without \"default\" clause.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("checks/InputMissingSwitchDefault.java"), expected);
|
||||
verify(checkConfig, getPath("InputMissingSwitchDefault.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -176,7 +182,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
"12:20: Literal Strings should be compared using equals(), not '=='.",
|
||||
"17:22: Literal Strings should be compared using equals(), not '=='.",
|
||||
};
|
||||
verify(checkConfig, getPath("checks" + File.separator + "InputStringLiteralEquality.java"), expected);
|
||||
verify(checkConfig, getPath("InputStringLiteralEquality.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -194,7 +200,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
"11:18: Using 'POST_DEC' is not allowed.",
|
||||
"12:18: Using 'POST_INC' is not allowed.",
|
||||
};
|
||||
verify(checkConfig, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -210,7 +216,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
final String[] expected = {
|
||||
"17:12: Using 'LITERAL_NATIVE' is not allowed.",
|
||||
};
|
||||
verify(checkConfig, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -227,9 +233,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
"15:11: Return from catch is not allowed.",
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
getPath("checks" + File.separator + "InputReturnFromCatchCheck.java"),
|
||||
expected);
|
||||
verify(checkConfig, getPath("InputReturnFromCatchCheck.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -246,9 +250,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
"15:11: Return from finally is not allowed.",
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
getPath("checks" + File.separator + "InputReturnFromFinallyCheck.java"),
|
||||
expected);
|
||||
verify(checkConfig, getPath("InputReturnFromFinallyCheck.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -262,9 +264,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
|
||||
String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
|
||||
verify(checkConfig,
|
||||
getPath("checks" + File.separator + "InputReturnFromFinallyCheck.java"),
|
||||
expected);
|
||||
verify(checkConfig, getPath("InputReturnFromFinallyCheck.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -284,9 +284,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
"23:51: this cannot be null.",
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
getPath("checks" + File.separator + "InputReturnFromFinallyCheck.java"),
|
||||
expected);
|
||||
verify(checkConfig, getPath("InputReturnFromFinallyCheck.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -305,9 +303,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
"23:51: " + getCheckMessage(MSG_KEY_SUM_MAX, 2, 1, "NOT_EQUAL"),
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
getPath("checks" + File.separator + "InputReturnFromFinallyCheck.java"),
|
||||
expected);
|
||||
verify(checkConfig, getPath("InputReturnFromFinallyCheck.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -328,9 +324,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
"24:77: " + getCheckMessage(MSG_KEY_SUM_MIN, 1, 3, "EQUAL"),
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
getPath("checks" + File.separator + "InputReturnFromFinallyCheck.java"),
|
||||
expected);
|
||||
verify(checkConfig, getPath("InputReturnFromFinallyCheck.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -352,8 +346,6 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport {
|
|||
"24:77: custom message",
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
getPath("checks" + File.separator + "InputReturnFromFinallyCheck.java"),
|
||||
expected);
|
||||
verify(checkConfig, getPath("InputReturnFromFinallyCheck.java"), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import static org.junit.Assert.assertArrayEquals;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
|
@ -39,6 +40,11 @@ import com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck;
|
|||
|
||||
public class FileSetCheckLifecycleTest
|
||||
extends BaseCheckTestSupport {
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DefaultConfiguration createCheckerConfig(
|
||||
Configuration config) {
|
||||
|
|
@ -58,7 +64,7 @@ public class FileSetCheckLifecycleTest
|
|||
final Configuration checkConfig =
|
||||
createCheckConfig(TestFileSetCheck.class);
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
verify(checkConfig, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
|
||||
assertTrue("destroy() not called by Checker", TestFileSetCheck.isDestroyed());
|
||||
}
|
||||
|
|
@ -85,7 +91,7 @@ public class FileSetCheckLifecycleTest
|
|||
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
|
||||
verify(checker, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checker, getPath("InputIllegalTokens.java"), expected);
|
||||
|
||||
assertTrue("FileContent should be available during finishProcessing() call",
|
||||
TestFileSetCheck.isFileContentAvailable());
|
||||
|
|
|
|||
|
|
@ -21,12 +21,20 @@ package com.puppycrawl.tools.checkstyle.checks;
|
|||
|
||||
import static com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck.MSG_KEY;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
||||
public class FinalParametersCheckTest extends BaseCheckTestSupport {
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultTokens() throws Exception {
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ public class NewlineAtEndOfFileCheckTest
|
|||
return dc;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewlineLfAtEndOfFile() throws Exception {
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package com.puppycrawl.tools.checkstyle.checks;
|
|||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.junit.Test;
|
||||
|
|
@ -31,6 +32,15 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
|||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
||||
public class OuterTypeFilenameCheckTest extends BaseCheckTestSupport {
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNonCompilablePath(String filename) throws IOException {
|
||||
return super.getNonCompilablePath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRequiredTokens() {
|
||||
|
|
@ -49,7 +59,7 @@ public class OuterTypeFilenameCheckTest extends BaseCheckTestSupport {
|
|||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(OuterTypeFilenameCheck.class);
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
verify(checkConfig, getPath("checks/InputIllegalTokens.java"), expected);
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -109,7 +119,6 @@ public class OuterTypeFilenameCheckTest extends BaseCheckTestSupport {
|
|||
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
|
||||
verify(checkConfig, new File("src/test/resources-noncompilable/com/puppycrawl/tools/"
|
||||
+ "checkstyle/checks/package-info.java").getCanonicalPath(), expected);
|
||||
verify(checkConfig, getNonCompilablePath("package-info.java"), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
|
|||
import static org.powermock.api.mockito.PowerMockito.mock;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
|
@ -50,6 +51,15 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
|||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ SuppressWarningsHolder.class, SuppressWarningsHolderTest.class })
|
||||
public class SuppressWarningsHolderTest extends BaseCheckTestSupport {
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNonCompilablePath(String filename) throws IOException {
|
||||
return super.getNonCompilablePath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRequiredTokens() {
|
||||
|
|
@ -73,8 +83,7 @@ public class SuppressWarningsHolderTest extends BaseCheckTestSupport {
|
|||
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
|
||||
verify(checkConfig, new File("src/test/resources-noncompilable/com/puppycrawl/tools/"
|
||||
+ "checkstyle/InputSuppressWarningsHolder.java").getCanonicalPath(), expected);
|
||||
verify(checkConfig, getNonCompilablePath("InputSuppressWarningsHolder.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ import static com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck.MSG_KEY;
|
|||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -31,6 +34,10 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
|||
|
||||
public class TodoCommentCheckTest
|
||||
extends BaseCheckTestSupport {
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRequiredTokens() {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ import static com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck.MSG_KE
|
|||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
@ -40,6 +43,11 @@ public class TrailingCommentCheckTest extends BaseCheckTestSupport {
|
|||
checkConfig = createCheckConfig(TrailingCommentCheck.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRequiredTokens() {
|
||||
TrailingCommentCheck checkObj = new TrailingCommentCheck();
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ package com.puppycrawl.tools.checkstyle.checks;
|
|||
import static com.puppycrawl.tools.checkstyle.checks.UncommentedMainCheck.MSG_KEY;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
@ -35,6 +38,11 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
|||
|
||||
public class UncommentedMainCheckTest
|
||||
extends BaseCheckTestSupport {
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaults()
|
||||
throws Exception {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
|
|
@ -55,6 +56,11 @@ public class UniquePropertiesCheckTest extends BaseFileSetCheckTestSupport {
|
|||
checkConfig = createCheckConfig(UniquePropertiesCheck.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
/* Additional test for jacoco, since valueOf()
|
||||
* is generated by javac and jacoco reports that
|
||||
* valueOf() is uncovered.
|
||||
|
|
@ -78,8 +84,7 @@ public class UniquePropertiesCheckTest extends BaseFileSetCheckTestSupport {
|
|||
"28: " + getCheckMessage(MSG_KEY, "Support Link ", 2),
|
||||
"34: " + getCheckMessage(MSG_KEY, "failed", 2),
|
||||
};
|
||||
verify(checkConfig, getPath("InputUniquePropertiesCheck.properties"),
|
||||
expected);
|
||||
verify(checkConfig, getPath("InputUniquePropertiesCheck.properties"), expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ import static com.puppycrawl.tools.checkstyle.checks.UpperEllCheck.MSG_KEY;
|
|||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -31,6 +34,10 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
|||
|
||||
public class UpperEllCheckTest
|
||||
extends BaseCheckTestSupport {
|
||||
@Override
|
||||
protected String getPath(String filename) throws IOException {
|
||||
return super.getPath("checks" + File.separator + filename);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRequiredTokens() {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class UnusedImportsCheckTest extends BaseCheckTestSupport {
|
|||
"38:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.CheckerTest"),
|
||||
"39:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport"),
|
||||
"40:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.Definitions"),
|
||||
"41:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.Input15Extensions"),
|
||||
"41:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.Input15Extensions"),
|
||||
"42:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest"),
|
||||
"43:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.PackageNamesLoader"),
|
||||
"44:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.DefaultConfiguration"),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//Compilable with Java8
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
|
@ -1 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
// Test case file for checkstyle.
// Created: 2015
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;
/**
* Test case for detection of an existing CR newline at EOF, using the
* NewlineAtEndOfFileCheck.
* @author Martin Steiger
**/
public interface InputNewlineCrAtEndOfFile
{
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
public class InputSuppressWarningsHolder4 {
|
||||
|
||||
@com.puppycrawl.tools.checkstyle.CustomAnnotation()
|
||||
int a;
|
||||
|
||||
}
|
||||
@interface CustomAnnotation {
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// someexamples of 1.5 extensions
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
@interface MyAnnotation1 {
|
||||
String name();
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Test case file for checkstyle.
|
||||
// Created: 2001
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
/**
|
||||
* Test case for ArrayTypeStyle (Java vs C)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
|
@ -1,10 +1,5 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
/**
|
||||
* Input class for testing EmptyStatementCheck
|
||||
* @author Rick Giles
|
||||
* @version 5-May-2003
|
||||
*/
|
||||
public class InputEmptyStatement
|
||||
{
|
||||
public InputEmptyStatement()
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Test case file for checkstyle.
|
||||
// Created: 2003
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
public class InputFinalParametersPrimitiveTypes
|
||||
{
|
||||
|
|
@ -0,0 +1 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
// Test case file for checkstyle.
// Created: 2015
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks;
/**
* Test case for detection of an existing CR newline at EOF, using the
* NewlineAtEndOfFileCheck.
* @author Martin Steiger
**/
public interface InputNewlineCrAtEndOfFile
{
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Test case file for checkstyle.
|
||||
// Created: 2015
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
/**
|
||||
* Test case for detection of an existing CRLF newline at EOF, using the
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Test case file for checkstyle.
|
||||
// Created: 2015
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
/**
|
||||
* Test case for detection of an existing LF newline at EOF, using the
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Test case file for checkstyle.
|
||||
// Created: 2003
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
/**
|
||||
* Test case for detection of missing newlines at EOF, using the
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// someexamples of 1.5 extensions
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
public class InputOuterTypeFilenameCheck1 {
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// someexamples of 1.5 extensions
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
public class InputOuterTypeFilenameCheck2 {
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// someexamples of 1.5 extensions
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
class InputOuterTypeFilenameCheck3 {
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// someexamples of 1.5 extensions
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
class InputOuterTypeFilenameCheckWrongName2 {
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Test case file for checkstyle.
|
||||
// Created: 2001
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import java.io.*; // star import for instantiation tests
|
||||
import java.awt.Dimension; // explicit import for instantiation tests
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
// Created: Feb-2001
|
||||
// Ignore error
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
import java.io.*;
|
||||
/**
|
||||
* Contains simple mistakes:
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
public class InputSuppressWarningsHolder {
|
||||
static final String UNUSED = "unused";
|
||||
|
|
@ -7,13 +7,13 @@ public class InputSuppressWarningsHolder {
|
|||
int a;
|
||||
@SuppressWarnings(InputSuppressWarningsHolder.UNUSED)
|
||||
int b;
|
||||
@SuppressWarnings(com.puppycrawl.tools.checkstyle.InputSuppressWarningsHolder.UNUSED)
|
||||
@SuppressWarnings(com.puppycrawl.tools.checkstyle.checks.InputSuppressWarningsHolder.UNUSED)
|
||||
int c;
|
||||
@SuppressWarnings(value = UNUSED)
|
||||
int d;
|
||||
@SuppressWarnings(value = InputSuppressWarningsHolder.UNUSED)
|
||||
int e;
|
||||
@SuppressWarnings(value = com.puppycrawl.tools.checkstyle.InputSuppressWarningsHolder.UNUSED)
|
||||
@SuppressWarnings(value = com.puppycrawl.tools.checkstyle.checks.InputSuppressWarningsHolder.UNUSED)
|
||||
int f;
|
||||
@SuppressWarnings((1 != 1) ? "" : "unused")
|
||||
int g;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
public class InputSuppressWarningsHolder2
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
public class InputSuppressWarningsHolder3 {
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
public class InputSuppressWarningsHolder4 {
|
||||
|
||||
@com.puppycrawl.tools.checkstyle.checks.CustomAnnotation()
|
||||
int a;
|
||||
|
||||
}
|
||||
@interface CustomAnnotation {
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
public class InputTrailingComment {
|
||||
int i; // don't use trailing comments :)
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Test case file for checkstyle.
|
||||
// Created: 2003
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
/**
|
||||
* Test case for UncommentedMainCheck
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Test case file for checkstyle.
|
||||
// Created: 2003
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
|
||||
public class InputUncommentedMain2
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Test case file for checkstyle.
|
||||
// Created: 2003
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
class oneMoreClass {
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Test case file for checkstyle.
|
||||
// Created: 2003
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
class InputUncommentedMainTest4
|
||||
{
|
||||
|
|
@ -39,7 +39,7 @@ import com.puppycrawl.tools.checkstyle.Checker;
|
|||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.checks.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.PackageNamesLoader;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import com.puppycrawl.tools.checkstyle.Checker;
|
|||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.checks.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.PackageNamesLoader;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import com.puppycrawl.tools.checkstyle.Checker;
|
|||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.checks.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.PackageNamesLoader;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import com.puppycrawl.tools.checkstyle.Checker;
|
|||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.checks.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.PackageNamesLoader;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import com.puppycrawl.tools.checkstyle.Checker;
|
|||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.checks.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.PackageNamesLoader;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
|
|
|||
Loading…
Reference in New Issue