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()));
}
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");
}
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);
}
}
Aggregations