Search in sources :

Example 1 with Event

use of com.tomtom.james.common.api.publisher.Event in project james by tomtom-international.

the class Log4j2PublisherTest method shouldLogEvent.

@Test
public void shouldLogEvent() {
    SimpleLogger logger = (SimpleLogger) LogManager.getLogger(LOGGER_NAME);
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    logger.setStream(new PrintStream(byteArrayOutputStream));
    createPublisher().publish(new Event(Collections.singletonMap("key", "value"), Instant.EPOCH));
    assertThat(byteArrayOutputStream.toString().trim()).isEqualTo("INFO logger @created=\"1970-01-01T00:00:00Z\" key=\"value\" type=\"james\"");
}
Also used : PrintStream(java.io.PrintStream) Event(com.tomtom.james.common.api.publisher.Event) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SimpleLogger(org.apache.logging.log4j.simple.SimpleLogger) Test(org.junit.jupiter.api.Test)

Aggregations

Event (com.tomtom.james.common.api.publisher.Event)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 SimpleLogger (org.apache.logging.log4j.simple.SimpleLogger)1 Test (org.junit.jupiter.api.Test)1