Search in sources :

Example 1 with MessageFormatMessage

use of org.apache.logging.log4j.message.MessageFormatMessage in project jmeter-plugins-manager by undera.

the class LoggerAppenderTest method testFlow.

@Test
public void testFlow() throws Exception {
    PluginManager pmgr = new PluginManager();
    LoggerAppender appender = new LoggerAppender("test-appender", pmgr);
    PluginSuggester suggester = new PluginSuggester(pmgr);
    appender.setSuggester(suggester);
    assertEquals(suggester, appender.getSuggester());
    Log4jLogEvent.Builder builder = Log4jLogEvent.newBuilder();
    builder.setMessage(new MessageFormatMessage("Save file"));
    builder.setLoggerName("SaveService");
    appender.append(builder.build());
    LoggerAppender.SaveServiceFilter filter = new LoggerAppender.SaveServiceFilter(Filter.Result.ACCEPT, Filter.Result.DENY);
    assertEquals(Filter.Result.ACCEPT, filter.filter(builder.build()));
    builder.setLoggerName("SomeLogger");
    assertEquals(Filter.Result.DENY, filter.filter(builder.build()));
}
Also used : PluginManager(org.jmeterplugins.repository.PluginManager) MessageFormatMessage(org.apache.logging.log4j.message.MessageFormatMessage) PluginSuggester(org.jmeterplugins.repository.plugins.PluginSuggester) Log4jLogEvent(org.apache.logging.log4j.core.impl.Log4jLogEvent) PluginManagerTest(org.jmeterplugins.repository.PluginManagerTest) Test(org.junit.Test)

Example 2 with MessageFormatMessage

use of org.apache.logging.log4j.message.MessageFormatMessage in project logging-log4j2 by apache.

the class LoggerSupplierTest method flowTracing_SupplierOfMessageFormatMessage.

@Test
public void flowTracing_SupplierOfMessageFormatMessage() {
    logger.traceEntry(() -> new MessageFormatMessage("int foo={0}", 1234567890));
    assertThat(results).hasSize(1);
    String entry = results.get(0);
    assertThat(entry).startsWith("ENTER[ FLOW ] TRACE Enter").contains("(int foo=1,234,567,890)").doesNotContain("MessageFormatMessage");
}
Also used : MessageFormatMessage(org.apache.logging.log4j.message.MessageFormatMessage) Test(org.junit.jupiter.api.Test)

Example 3 with MessageFormatMessage

use of org.apache.logging.log4j.message.MessageFormatMessage in project Railcraft by Railcraft.

the class HumanReadableNumberFormatterTest method formatNumber.

@Test
void formatNumber() {
    double[] test = { 15e15, 98e18, 15e14, 105e14, 1400.3, 54983.6768, -34.56, -50_000, -100_000, 140_500 };
    String[] result = { "15Q", "98,000Q", "1,500T", "10.5Q", "1,400.3", "55K", "-34.56", "-50K", "-100K", "140.5K" };
    for (int i = 0; i < test.length; i++) {
        String output = HumanReadableNumberFormatter.format(test[i]);
        LogManager.getLogger("NumberFormatter").log(Level.INFO, new MessageFormatMessage("{0} == {1}", test[i], output));
        Assertions.assertEquals(result[i], output);
    }
}
Also used : MessageFormatMessage(org.apache.logging.log4j.message.MessageFormatMessage) Test(org.junit.jupiter.api.Test)

Aggregations

MessageFormatMessage (org.apache.logging.log4j.message.MessageFormatMessage)3 Test (org.junit.jupiter.api.Test)2 Log4jLogEvent (org.apache.logging.log4j.core.impl.Log4jLogEvent)1 PluginManager (org.jmeterplugins.repository.PluginManager)1 PluginManagerTest (org.jmeterplugins.repository.PluginManagerTest)1 PluginSuggester (org.jmeterplugins.repository.plugins.PluginSuggester)1 Test (org.junit.Test)1