View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, 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.spi;
15  
16  import ch.qos.logback.classic.Logger;
17  import ch.qos.logback.classic.LoggerContext;
18  import org.junit.jupiter.api.BeforeEach;
19  import org.junit.jupiter.api.Test;
20  
21  import static org.junit.jupiter.api.Assertions.assertEquals;
22  
23  public class LoggerComparatorTest {
24  
25      LoggerComparator comparator = new LoggerComparator();
26      LoggerContext lc = new LoggerContext();
27  
28      Logger root = lc.getLogger("root");
29  
30      Logger a = lc.getLogger("a");
31      Logger b = lc.getLogger("b");
32  
33      @BeforeEach
34      public void setUp() throws Exception {
35  
36      }
37  
38      @Test
39      public void testSmoke() {
40          assertEquals(0, comparator.compare(a, a));
41          assertEquals(-1, comparator.compare(a, b));
42          assertEquals(1, comparator.compare(b, a));
43          assertEquals(-1, comparator.compare(root, a));
44          // following two tests failed before bug #127 was fixed
45          assertEquals(1, comparator.compare(a, root));
46          assertEquals(0, comparator.compare(root, root));
47      }
48  }