001package ch.qos.logback.classic.layout;
002
003import static org.junit.Assert.assertTrue;
004
005import org.junit.Before;
006import org.junit.Test;
007
008import ch.qos.logback.classic.Level;
009import ch.qos.logback.classic.Logger;
010import ch.qos.logback.classic.LoggerContext;
011import ch.qos.logback.classic.spi.LoggingEvent;
012
013public class TTLLLayoutTest {
014
015    LoggerContext context = new LoggerContext();
016    Logger logger = context.getLogger(TTLLLayoutTest.class);
017    TTLLLayout layout = new TTLLLayout();
018
019    @Before
020    public void setUp() {
021        layout.setContext(context);
022        layout.start();
023    }
024
025    @Test
026    public void nullMessage() {
027        LoggingEvent event = new LoggingEvent("", logger, Level.INFO, null, null, null);
028        event.setTimeStamp(0);
029        String result = layout.doLayout(event);
030        
031        String resultSuffix = result.substring(13).trim();
032        
033        assertTrue("[" + resultSuffix + "] did not match regexs", resultSuffix.matches("\\[.*\\] INFO ch.qos.logback.classic.layout.TTLLLayoutTest - null"));
034    }
035}