diff options
Diffstat (limited to 'src/it/java/com/google/checkstyle/test/base/AbstractModuleTestSupport.java')
-rw-r--r-- | src/it/java/com/google/checkstyle/test/base/AbstractModuleTestSupport.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/it/java/com/google/checkstyle/test/base/AbstractModuleTestSupport.java b/src/it/java/com/google/checkstyle/test/base/AbstractModuleTestSupport.java index 946f79760..d23a3e099 100644 --- a/src/it/java/com/google/checkstyle/test/base/AbstractModuleTestSupport.java +++ b/src/it/java/com/google/checkstyle/test/base/AbstractModuleTestSupport.java @@ -87,7 +87,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport * Returns test logger. * @return logger test logger */ - public BriefUtLogger getBriefUtLogger() { + public final BriefUtLogger getBriefUtLogger() { return new BriefUtLogger(stream); } @@ -122,7 +122,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport * @return {@link Checker} instance based on the given {@link Configuration} instance. * @throws Exception if an exception occurs during checker configuration. */ - public Checker createChecker(Configuration moduleConfig) + public final Checker createChecker(Configuration moduleConfig) throws Exception { if (checkstyleModules == null) { checkstyleModules = CheckUtil.getCheckstyleModules(); @@ -134,7 +134,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport for (Class<?> moduleClass : checkstyleModules) { if (moduleClass.getSimpleName().equals(name) || moduleClass.getSimpleName().equals(name + "Check")) { - if (ModuleReflectionUtils.isCheckstyleCheck(moduleClass) + if (ModuleReflectionUtils.isCheckstyleTreeWalkerCheck(moduleClass) || ModuleReflectionUtils.isTreeWalkerFilterModule(moduleClass)) { moduleCreationOption = ModuleCreationOption.IN_TREEWALKER; } @@ -151,9 +151,9 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport * @param moduleCreationOption {@code IN_TREEWALKER} if the {@code moduleConfig} should be added * under {@link TreeWalker}. * @return {@link Checker} instance. - * @throws CheckstyleException if an exception occurs during checker configuration. + * @throws Exception if an exception occurs during checker configuration. */ - protected Checker createChecker(Configuration moduleConfig, + protected final Checker createChecker(Configuration moduleConfig, ModuleCreationOption moduleCreationOption) throws Exception { final DefaultConfiguration dc; @@ -183,7 +183,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport * @param config {@link Configuration} instance. * @return {@link DefaultConfiguration} for the {@link Checker}. */ - protected DefaultConfiguration createTreeWalkerConfig(Configuration config) { + protected static DefaultConfiguration createTreeWalkerConfig(Configuration config) { final DefaultConfiguration dc = new DefaultConfiguration("configuration"); final DefaultConfiguration twConf = createModuleConfig(TreeWalker.class); @@ -199,7 +199,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport * @param config {@link Configuration} instance. * @return {@link DefaultConfiguration} for the given {@link Configuration} instance. */ - protected DefaultConfiguration createRootConfig(Configuration config) { + protected static DefaultConfiguration createRootConfig(Configuration config) { final DefaultConfiguration dc = new DefaultConfiguration("root"); dc.addChild(config); return dc; @@ -218,7 +218,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport * @param warnsExpected an array of expected warning numbers. * @throws Exception if exception occurs during verification process. */ - protected void verify(Configuration config, String fileName, String[] expected, + protected final void verify(Configuration config, String fileName, String[] expected, Integer... warnsExpected) throws Exception { verify(createChecker(config), new File[] {new File(fileName)}, @@ -234,7 +234,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport * @param warnsExpected an array of expected warning line numbers. * @throws Exception if exception occurs during verification process. */ - protected void verify(Checker checker, + protected final void verify(Checker checker, File[] processedFiles, String messageFileName, String[] expected, @@ -281,10 +281,12 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport * Gets the check message 'as is' from appropriate 'messages.properties' * file. * + * @param aClass The package the message is located in. * @param messageKey the key of message in 'messages.properties' file. * @param arguments the arguments of message in 'messages.properties' file. + * @return The message of the check with the arguments applied. */ - protected String getCheckMessage(Class<? extends AbstractViolationReporter> aClass, + protected static String getCheckMessage(Class<? extends AbstractViolationReporter> aClass, String messageKey, Object... arguments) { String checkMessage; try { @@ -302,10 +304,12 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport /** * Gets the check message 'as is' from appropriate 'messages.properties' file. + * @param messages The map of messages to scan. * @param messageKey the key of message in 'messages.properties' file. * @param arguments the arguments of message in 'messages.properties' file. + * @return The message of the check with the arguments applied. */ - protected String getCheckMessage(Map<String, String> messages, String messageKey, + protected static String getCheckMessage(Map<String, String> messages, String messageKey, Object... arguments) { String checkMessage = null; for (Map.Entry<String, String> entry : messages.entrySet()) { @@ -333,6 +337,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport * Returns {@link Configuration} instance for the given module name. * This implementation uses {@link AbstractModuleTestSupport#getConfiguration()} method inside. * @param moduleName module name. + * @param moduleId module id. * @return {@link Configuration} instance for the given module name. * @throws CheckstyleException if exception occurs during configuration loading. */ |