1   /** 
2    * LOGBack: the reliable, fast and flexible logging library for Java.
3    *
4    * Copyright (C) 1999-2005, QOS.ch, LOGBack.com
5    *
6    * This library is free software, you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public License as
8    * published by the Free Software Foundation.
9    */
10  package ch.qos.logback.classic.control;
11  
12  import junit.framework.TestCase;
13  
14  import ch.qos.logback.classic.Level;
15  import ch.qos.logback.classic.control.ControlLogger;
16  import ch.qos.logback.classic.control.ControlLoggerContext;
17  
18  
19  /**
20   * This class is for testing ControlLoggerContext which is a control class for testing HLoggerContext.
21   */
22  public class CLCTest extends TestCase {
23    ControlLoggerContext clc;
24  
25  
26    protected void setUp() throws Exception {
27      clc = new ControlLoggerContext();
28    }
29  
30    public void test1() {
31      ControlLogger x = clc.getLogger("x");
32      assertEquals("x", x.getName());
33      assertEquals(clc.getRootLogger(), x.parent);
34  
35      ControlLogger abc = clc.getLogger("a.b.c");
36      assertEquals("a.b.c", abc.getName());
37      assertEquals(Level.DEBUG, abc.getEffectiveLevel());
38    }
39  
40    public void testCreation() {
41      ControlLogger xyz = clc.getLogger("x.y.z");
42      assertEquals("x.y.z", xyz.getName());
43      assertEquals("x.y", xyz.parent.getName());
44      assertEquals("x", xyz.parent.parent.getName());
45      assertEquals("root", xyz.parent.parent.parent.getName());
46  
47      ControlLogger xyz_ = clc.exists("x.y.z");
48      assertEquals("x.y.z", xyz_.getName());
49  
50  
51    }
52  }