17ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu/**
27ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * Copyright (c) 2004-2011 QOS.ch
37ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * All rights reserved.
47ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu *
57ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * Permission is hereby granted, free  of charge, to any person obtaining
67ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * a  copy  of this  software  and  associated  documentation files  (the
77ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * "Software"), to  deal in  the Software without  restriction, including
87ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * without limitation  the rights to  use, copy, modify,  merge, publish,
97ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * distribute,  sublicense, and/or sell  copies of  the Software,  and to
107ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * permit persons to whom the Software  is furnished to do so, subject to
117ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * the following conditions:
127ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu *
137ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * The  above  copyright  notice  and  this permission  notice  shall  be
147ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * included in all copies or substantial portions of the Software.
157ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu *
167ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
177ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
187ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
197ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
207ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
217ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
227ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
237ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu *
247ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu */
2588c4c456766193e012eb890e2208473d99b91f83Ceki Gulcupackage org.slf4j.impl;
2688c4c456766193e012eb890e2208473d99b91f83Ceki Gulcu
2788c4c456766193e012eb890e2208473d99b91f83Ceki Gulcuimport java.util.Random;
2888c4c456766193e012eb890e2208473d99b91f83Ceki Gulcu
2988c4c456766193e012eb890e2208473d99b91f83Ceki Gulcuimport junit.framework.TestCase;
3088c4c456766193e012eb890e2208473d99b91f83Ceki Gulcu
3188c4c456766193e012eb890e2208473d99b91f83Ceki Gulcuimport org.slf4j.Logger;
3288c4c456766193e012eb890e2208473d99b91f83Ceki Gulcuimport org.slf4j.LoggerFactory;
3388c4c456766193e012eb890e2208473d99b91f83Ceki Gulcu
3488c4c456766193e012eb890e2208473d99b91f83Ceki Gulcupublic class RecursiveInitializationTest extends TestCase {
3588c4c456766193e012eb890e2208473d99b91f83Ceki Gulcu
3631212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu    // value of LogManager.DEFAULT_CONFIGURATION_KEY;
3731212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu    static String CONFIG_FILE_KEY = "log4j.configuration";
3831212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu
3931212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu    int diff = new Random().nextInt(10000);
4031212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu
4131212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu    protected void setUp() throws Exception {
4231212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu        System.setProperty(CONFIG_FILE_KEY, "recursiveInit.properties");
4331212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu        super.setUp();
4431212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu    }
4531212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu
4631212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu    protected void tearDown() throws Exception {
4731212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu        System.clearProperty(CONFIG_FILE_KEY);
4831212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu        super.tearDown();
4931212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu    }
5031212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu
5131212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu    public void testLog4j() {
5231212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu        Logger logger = LoggerFactory.getLogger("x" + diff);
5331212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu        System.out.println("logger class=" + logger.getClass().getName());
5431212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu        logger.info("hello");
5531212435723e2dfd5d6716d1f6a7b0e66a1e6b38Ceki Gulcu    }
5688c4c456766193e012eb890e2208473d99b91f83Ceki Gulcu
5788c4c456766193e012eb890e2208473d99b91f83Ceki Gulcu}
58