本文整理汇总了Java中com.puppycrawl.tools.checkstyle.DefaultConfiguration.addMessage方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultConfiguration.addMessage方法的具体用法?Java DefaultConfiguration.addMessage怎么用?Java DefaultConfiguration.addMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.puppycrawl.tools.checkstyle.DefaultConfiguration
的用法示例。
在下文中一共展示了DefaultConfiguration.addMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCustomMessage
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void testCustomMessage() throws Exception {
final DefaultConfiguration config = createModuleConfig(emptyCheck.getClass());
config.addMessage("msgKey", "This is a custom message.");
emptyCheck.configure(config);
emptyCheck.log(0, "msgKey");
final SortedSet<LocalizedMessage> messages = emptyCheck.getMessages();
assertEquals("Amount of messages differs from expected",
1, messages.size());
assertEquals("Message differs from expected",
"This is a custom message.", messages.first()
.getMessage());
}
示例2: testCustomMessageWithParameters
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void testCustomMessageWithParameters() throws Exception {
final DefaultConfiguration config = createModuleConfig(emptyCheck.getClass());
config.addMessage("msgKey", "This is a custom message with {0}.");
emptyCheck.configure(config);
emptyCheck.log(0, "msgKey", "TestParam");
final SortedSet<LocalizedMessage> messages = emptyCheck.getMessages();
assertEquals("Amount of messages differs from expected",
1, messages.size());
assertEquals("Message differs from expected",
"This is a custom message with TestParam.",
messages.first().getMessage());
}
示例3: testCustomMessageWithParametersNegative
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void testCustomMessageWithParametersNegative() throws Exception {
final DefaultConfiguration config = createModuleConfig(emptyCheck.getClass());
config.addMessage("msgKey", "This is a custom message {0.");
emptyCheck.configure(config);
try {
emptyCheck.log(0, "msgKey", "TestParam");
emptyCheck.log(0, "msgKey", "TestParam");
fail("exception expected");
}
catch (IllegalArgumentException ex) {
assertEquals("Error message is unexpected",
"Unmatched braces in the pattern.", ex.getMessage());
}
}
示例4: shouldLogActualParameterNumber
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void shouldLogActualParameterNumber()
throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(ParameterNumberCheck.class);
checkConfig.addMessage("maxParam", "{0},{1}");
final String[] expected = {
"194:10: 7,9",
};
verify(checkConfig, getPath("InputParameterNumberSimple.java"), expected);
}
示例5: shouldLogActualLineLength
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void shouldLogActualLineLength()
throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(LineLengthCheck.class);
checkConfig.addAttribute("max", "80");
checkConfig.addAttribute("ignorePattern", "^.*is OK.*regexp.*$");
checkConfig.addMessage("maxLineLen", "{0},{1}");
final String[] expected = {
"18: 80,81",
"145: 80,83",
};
verify(checkConfig, getPath("InputLineLengthSimple.java"), expected);
}