final ActorSystem system = ActorSystem.create("test-system", config);
new LogJavaTestKit(system) {{
system.eventStream().subscribe(getRef(), LogEvent.class);
ActorRef ref = system.actorOf(Props.create(ActorWithMDC.class));
ref.tell(new Log(ErrorLevel(), "An Error"), system.deadLetters());
expectLog(ErrorLevel(), "An Error", "Map(messageLength -> 8)");
ref.tell(new Log(WarningLevel(), "A Warning"), system.deadLetters());
expectLog(WarningLevel(), "A Warning", "Map(messageLength -> 9)");
ref.tell(new Log(InfoLevel(), "Some Info"), system.deadLetters());
expectLog(InfoLevel(), "Some Info", "Map(messageLength -> 9)");
ref.tell(new Log(DebugLevel(), "No MDC for 4th call"), system.deadLetters());
expectLog(DebugLevel(), "No MDC for 4th call");
ref.tell(new Log(Logging.DebugLevel(), "And now yes, a debug with MDC"), system.deadLetters());
expectLog(DebugLevel(), "And now yes, a debug with MDC", "Map(messageLength -> 29)");
}};
}