Home | History | Annotate | Download | only in logging
      1 /**
      2  * Copyright (c) 2004-2011 QOS.ch
      3  * All rights reserved.
      4  *
      5  * Permission is hereby granted, free  of charge, to any person obtaining
      6  * a  copy  of this  software  and  associated  documentation files  (the
      7  * "Software"), to  deal in  the Software without  restriction, including
      8  * without limitation  the rights to  use, copy, modify,  merge, publish,
      9  * distribute,  sublicense, and/or sell  copies of  the Software,  and to
     10  * permit persons to whom the Software  is furnished to do so, subject to
     11  * the following conditions:
     12  *
     13  * The  above  copyright  notice  and  this permission  notice  shall  be
     14  * included in all copies or substantial portions of the Software.
     15  *
     16  * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
     17  * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
     18  * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
     19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     21  * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
     22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     23  *
     24  */
     25 
     26 package org.apache.commons.logging;
     27 
     28 import junit.framework.TestCase;
     29 
     30 public class InvokeJCLTest extends TestCase {
     31 
     32     public void testIsEnabledAPI() {
     33         // assume that we are running over slf4j-jdk14
     34         Log log = LogFactory.getLog(InvokeJCLTest.class);
     35         assertFalse(log.isTraceEnabled());
     36         assertFalse(log.isDebugEnabled());
     37         assertTrue(log.isInfoEnabled());
     38         assertTrue(log.isWarnEnabled());
     39         assertTrue(log.isErrorEnabled());
     40         assertTrue(log.isFatalEnabled());
     41     }
     42 
     43     public void testPrintAPI() {
     44         Log log = LogFactory.getLog(InvokeJCLTest.class);
     45         Exception e = new Exception("just testing");
     46 
     47         log.trace(null);
     48         log.trace("trace message");
     49 
     50         log.debug(null);
     51         log.debug("debug message");
     52 
     53         log.info(null);
     54         log.info("info  message");
     55 
     56         log.warn(null);
     57         log.warn("warn message");
     58 
     59         log.error(null);
     60         log.error("error message");
     61 
     62         log.fatal(null);
     63         log.fatal("fatal message");
     64 
     65         log.trace(null, e);
     66         log.trace("trace message", e);
     67 
     68         log.debug(null, e);
     69         log.debug("debug message", e);
     70 
     71         log.info(null, e);
     72         log.info("info  message", e);
     73 
     74         log.warn(null, e);
     75         log.warn("warn message", e);
     76 
     77         log.error(null, e);
     78         log.error("error message", e);
     79 
     80         log.fatal(null, e);
     81         log.fatal("fatal message", e);
     82     }
     83 }
     84