Source code

    001/**
    002 * Copyright (c) 2004-2011 QOS.ch
    003 * All rights reserved.
    004 *
    005 * Permission is hereby granted, free  of charge, to any person obtaining
    006 * a  copy  of this  software  and  associated  documentation files  (the
    007 * "Software"), to  deal in  the Software without  restriction, including
    008 * without limitation  the rights to  use, copy, modify,  merge, publish,
    009 * distribute,  sublicense, and/or sell  copies of  the Software,  and to
    010 * permit persons to whom the Software  is furnished to do so, subject to
    011 * the following conditions:
    012 *
    013 * The  above  copyright  notice  and  this permission  notice  shall  be
    014 * included in all copies or substantial portions of the Software.
    015 *
    016 * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
    017 * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
    018 * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
    019 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    020 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    021 * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
    022 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    023 *
    024 */
    025
    026package org.apache.commons.logging;
    027
    028import static org.junit.Assert.assertFalse;
    029import static org.junit.Assert.assertTrue;
    030
    031import org.junit.Test;
    032
    033public class InvokeJCLTest {
    034
    035    @Test
    036    public void testIsEnabledAPI() {
    037        // assume that we are running over slf4j-jdk14
    038        Log log = LogFactory.getLog(InvokeJCLTest.class);
    039        assertFalse(log.isTraceEnabled());
    040        assertFalse(log.isDebugEnabled());
    041        assertTrue(log.isInfoEnabled());
    042        assertTrue(log.isWarnEnabled());
    043        assertTrue(log.isErrorEnabled());
    044        assertTrue(log.isFatalEnabled());
    045    }
    046
    047    @Test
    048    public void testPrintAPI() {
    049        Log log = LogFactory.getLog(InvokeJCLTest.class);
    050        Exception e = new Exception("just testing");
    051
    052        log.trace(null);
    053        log.trace("trace message");
    054
    055        log.debug(null);
    056        log.debug("debug message");
    057
    058        log.info(null);
    059        log.info("info  message");
    060
    061        log.warn(null);
    062        log.warn("warn message");
    063
    064        log.error(null);
    065        log.error("error message");
    066
    067        log.fatal(null);
    068        log.fatal("fatal message");
    069
    070        log.trace(null, e);
    071        log.trace("trace message", e);
    072
    073        log.debug(null, e);
    074        log.debug("debug message", e);
    075
    076        log.info(null, e);
    077        log.info("info  message", e);
    078
    079        log.warn(null, e);
    080        log.warn("warn message", e);
    081
    082        log.error(null, e);
    083        log.error("error message", e);
    084
    085        log.fatal(null, e);
    086        log.fatal("fatal message", e);
    087    }
    088}