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.control;
15  
16  import junit.framework.TestCase;
17  
18  import ch.qos.logback.classic.Level;
19  import ch.qos.logback.classic.control.ControlLogger;
20  import ch.qos.logback.classic.control.ControlLoggerContext;
21  
22  /**
23   * This class is for testing ControlLoggerContext which is a control class for testing HLoggerContext.
24   */
25  public class CLCTest extends TestCase {
26      ControlLoggerContext clc;
27  
28      protected void setUp() throws Exception {
29          clc = new ControlLoggerContext();
30      }
31  
32      public void test1() {
33          ControlLogger x = clc.getLogger("x");
34          assertEquals("x", x.getName());
35          assertEquals(clc.getRootLogger(), x.parent);
36  
37          ControlLogger abc = clc.getLogger("a.b.c");
38          assertEquals("a.b.c", abc.getName());
39          assertEquals(Level.DEBUG, abc.getEffectiveLevel());
40      }
41  
42      public void testCreation() {
43          ControlLogger xyz = clc.getLogger("x.y.z");
44          assertEquals("x.y.z", xyz.getName());
45          assertEquals("x.y", xyz.parent.getName());
46          assertEquals("x", xyz.parent.parent.getName());
47          assertEquals("root", xyz.parent.parent.parent.getName());
48  
49          ControlLogger xyz_ = clc.exists("x.y.z");
50          assertEquals("x.y.z", xyz_.getName());
51  
52      }
53  }