View Javadoc
1   package ch.qos.logback.classic.layout;
2   
3   import static org.junit.Assert.assertTrue;
4   
5   import org.junit.Before;
6   import org.junit.Test;
7   
8   import ch.qos.logback.classic.Level;
9   import ch.qos.logback.classic.Logger;
10  import ch.qos.logback.classic.LoggerContext;
11  import ch.qos.logback.classic.spi.LoggingEvent;
12  
13  public class TTLLLayoutTest {
14  
15      LoggerContext context = new LoggerContext();
16      Logger logger = context.getLogger(TTLLLayoutTest.class);
17      TTLLLayout layout = new TTLLLayout();
18  
19      @Before
20      public void setUp() {
21          layout.setContext(context);
22          layout.start();
23      }
24  
25      @Test
26      public void nullMessage() {
27          LoggingEvent event = new LoggingEvent("", logger, Level.INFO, null, null, null);
28          event.setTimeStamp(0);
29          String result = layout.doLayout(event);
30          
31          String resultSuffix = result.substring(13).trim();
32          
33          assertTrue("[" + resultSuffix + "] did not match regexs", resultSuffix.matches("\\[.*\\] INFO ch.qos.logback.classic.layout.TTLLLayoutTest - null"));
34      }
35  }