Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@LogbackInitializer
public class TestLocalAppender {
@Test
@ResourceLock(value = "LOGGING", mode = ResourceAccessMode.READ_WRITE)
public void testLocalAppenderA() {
OtherLogProducingService service = new OtherLogProducingService();
LocalAppender localAppender = LocalAppender.initialize("com.bk.logging.OtherLogProducingService");
service.writeSomeLoggingStatements("Other logging servie A");
assertThat(localAppender.getEvents()).extracting("message")
.containsOnly("Let's assert some logs! Other logging servie A", "This message is in a separate thread");
localAppender.cleanup();
}
@Test
@ResourceLock(value = "LOGGING", mode = ResourceAccessMode.READ_WRITE)
public void testLocalAppenderB() {
OtherLogProducingService service = new OtherLogProducingService();
LocalAppender localAppender = LocalAppender.initialize("com.bk.logging.OtherLogProducingService");
service.writeSomeLoggingStatements("Other logging servie B");
assertThat(localAppender.getEvents()).extracting("message")
.containsOnly("Let's assert some logs! Other logging servie B", "This message is in a separate thread");
localAppender.cleanup();
}
@Test
@ResourceLock(value = "LOGGING", mode = ResourceAccessMode.READ)
public void justAnotherTest() {
OtherLogProducingService service = new OtherLogProducingService();
service.writeSomeLoggingStatements("Local appender");
// Executing just to add some logs
}
@Test
@ResourceLock(value = "LOGGING", mode = ResourceAccessMode.READ)
public void yetAnotherTest() {
OtherLogProducingService service = new OtherLogProducingService();
service.writeSomeLoggingStatements("Local appender");
// Executing just to add some logs
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment