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