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 org.junit.Before;
17  import org.junit.Test;
18  import static org.junit.Assert.*;
19  
20  import ch.qos.logback.classic.Logger;
21  import ch.qos.logback.classic.LoggerContext;
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      @Before
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  }