View Javadoc
1   package ch.qos.logback.classic.spi;
2   
3   import java.io.PrintStream;
4   
5   import org.junit.jupiter.api.AfterEach;
6   import org.junit.jupiter.api.BeforeEach;
7   import org.junit.jupiter.api.Test;
8   import org.slf4j.Logger;
9   import org.slf4j.LoggerFactory;
10  import org.slf4j.LoggerFactoryFriend;
11  
12  import ch.qos.logback.classic.testUtil.StringPrintStream;
13  
14  import static org.junit.jupiter.api.Assertions.assertTrue;
15  
16  public class InvocationTest {
17  
18      private final PrintStream oldErr = System.err;
19      final String loggerName = this.getClass().getName();
20      StringPrintStream sps = new StringPrintStream(oldErr, true);
21  
22      @BeforeEach
23      public void setUp() throws Exception {
24          System.setErr(sps);
25      }
26  
27      @AfterEach
28      public void tearDown() throws Exception {
29          LoggerFactoryFriend.reset();
30          System.setErr(oldErr);
31      }
32  
33      // https://jira.qos.ch/browse/LOGBACK-1568 would have been prevented
34      // had this silly test existed.
35      @Test
36      public void smoke() {
37          Logger logger = LoggerFactory.getLogger(this.getClass());
38          logger.debug("Hello world.");
39  
40          assertTrue(sps.stringList.isEmpty());
41  
42      }
43  
44  }