001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.classic.control;
015
016import junit.framework.TestCase;
017
018import ch.qos.logback.classic.Level;
019import ch.qos.logback.classic.control.ControlLogger;
020import ch.qos.logback.classic.control.ControlLoggerContext;
021
022/**
023 * This class is for testing ControlLoggerContext which is a control class for testing HLoggerContext.
024 */
025public class CLCTest extends TestCase {
026    ControlLoggerContext clc;
027
028    protected void setUp() throws Exception {
029        clc = new ControlLoggerContext();
030    }
031
032    public void test1() {
033        ControlLogger x = clc.getLogger("x");
034        assertEquals("x", x.getName());
035        assertEquals(clc.getRootLogger(), x.parent);
036
037        ControlLogger abc = clc.getLogger("a.b.c");
038        assertEquals("a.b.c", abc.getName());
039        assertEquals(Level.DEBUG, abc.getEffectiveLevel());
040    }
041
042    public void testCreation() {
043        ControlLogger xyz = clc.getLogger("x.y.z");
044        assertEquals("x.y.z", xyz.getName());
045        assertEquals("x.y", xyz.parent.getName());
046        assertEquals("x", xyz.parent.parent.getName());
047        assertEquals("root", xyz.parent.parent.parent.getName());
048
049        ControlLogger xyz_ = clc.exists("x.y.z");
050        assertEquals("x.y.z", xyz_.getName());
051
052    }
053}