View Javadoc

    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 static org.junit.Assert.assertFalse;
    29  import static org.junit.Assert.assertTrue;
    30
    31  import org.junit.Test;
    32
    33  public class InvokeJCLTest {
    34
    35      @Test
    36      public void testIsEnabledAPI() {
    37          // assume that we are running over slf4j-jdk14
    38          Log log = LogFactory.getLog(InvokeJCLTest.class);
    39          assertFalse(log.isTraceEnabled());
    40          assertFalse(log.isDebugEnabled());
    41          assertTrue(log.isInfoEnabled());
    42          assertTrue(log.isWarnEnabled());
    43          assertTrue(log.isErrorEnabled());
    44          assertTrue(log.isFatalEnabled());
    45      }
    46
    47      @Test
    48      public void testPrintAPI() {
    49          Log log = LogFactory.getLog(InvokeJCLTest.class);
    50          Exception e = new Exception("just testing");
    51
    52          log.trace(null);
    53          log.trace("trace message");
    54
    55          log.debug(null);
    56          log.debug("debug message");
    57
    58          log.info(null);
    59          log.info("info  message");
    60
    61          log.warn(null);
    62          log.warn("warn message");
    63
    64          log.error(null);
    65          log.error("error message");
    66
    67          log.fatal(null);
    68          log.fatal("fatal message");
    69
    70          log.trace(null, e);
    71          log.trace("trace message", e);
    72
    73          log.debug(null, e);
    74          log.debug("debug message", e);
    75
    76          log.info(null, e);
    77          log.info("info  message", e);
    78
    79          log.warn(null, e);
    80          log.warn("warn message", e);
    81
    82          log.error(null, e);
    83          log.error("error message", e);
    84
    85          log.fatal(null, e);
    86          log.fatal("fatal message", e);
    87      }
    88  }