View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2021, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.classic.pattern;
15  
16  import ch.qos.logback.classic.spi.LoggingEvent;
17  import org.junit.jupiter.api.Test;
18  
19  import java.time.Instant;
20  
21  import static org.junit.jupiter.api.Assertions.assertEquals;
22  
23  public class MicrosecondConverterTest {
24  
25      MicrosecondConverter mc = new MicrosecondConverter();
26      public long timeStamp;
27      public int nanoseconds;
28  
29      @Test
30      public void smoke() {
31          LoggingEvent le = new LoggingEvent();
32          Instant instant = Instant.parse("2011-12-03T10:15:30Z");
33          instant = instant.plusNanos(123_456_789);
34          le.setInstant(instant);
35  
36          String result = mc.convert(le);
37          assertEquals("456", result);
38      }
39  
40  }