当前位置: 首页>>代码示例>>Java>>正文


Java DefaultConfiguration.addMessage方法代码示例

本文整理汇总了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());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:AbstractViolationReporterTest.java

示例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());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:AbstractViolationReporterTest.java

示例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());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:AbstractViolationReporterTest.java

示例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);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:12,代码来源:ParameterNumberCheckTest.java

示例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);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:15,代码来源:LineLengthCheckTest.java


注:本文中的com.puppycrawl.tools.checkstyle.DefaultConfiguration.addMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。