001/*
002 *  jDTAUS Core Test Suite
003 *  Copyright (C) 2005 Christian Schulte
004 *  <cs@schulte.it>
005 *
006 *  This library is free software; you can redistribute it and/or
007 *  modify it under the terms of the GNU Lesser General Public
008 *  License as published by the Free Software Foundation; either
009 *  version 2.1 of the License, or any later version.
010 *
011 *  This library is distributed in the hope that it will be useful,
012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 *  Lesser General Public License for more details.
015 *
016 *  You should have received a copy of the GNU Lesser General Public
017 *  License along with this library; if not, write to the Free Software
018 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
019 *
020 */
021package org.jdtaus.core.logging.spi.it;
022
023import junit.framework.TestCase;
024import org.jdtaus.core.logging.spi.Logger;
025
026/**
027 * Testcase for {@code Logger} implementations.
028 *
029 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
030 * @version $JDTAUS: LoggerTest.java 8692 2012-10-01 14:16:57Z schulte $
031 */
032public class LoggerTest extends TestCase
033{
034    //--LoggerTest--------------------------------------------------------------
035
036    /** Implementation to test. */
037    private Logger logger;
038
039    /**
040     * Gets the {@code Logger} implementation tests are performed with.
041     *
042     * @return the {@code Logger} implementation tests are performed with.
043     */
044    public Logger getLogger()
045    {
046        return this.logger;
047    }
048
049    /**
050     * Sets the {@code Logger} implementation tests are performed with.
051     *
052     * @param value the {@code Logger} implementation to perform tests with.
053     */
054    public final void setLogger( final Logger value )
055    {
056        this.logger = value;
057    }
058
059    //--------------------------------------------------------------LoggerTest--
060    //--Tests-------------------------------------------------------------------
061
062    /**
063     * Tests the {@link Logger#isInfoEnabled() isXxxEnabled()} methods to not
064     * throw any exceptions.
065     */
066    public void testIsEnabled() throws Exception
067    {
068        assert this.getLogger() != null;
069
070        this.getLogger().isDebugEnabled();
071        this.getLogger().isErrorEnabled();
072        this.getLogger().isFatalEnabled();
073        this.getLogger().isInfoEnabled();
074        this.getLogger().isTraceEnabled();
075        this.getLogger().isWarnEnabled();
076    }
077
078    /**
079     * Test the various logger methods to not throw any exceptions.
080     */
081    public void testLog() throws Exception
082    {
083        assert this.getLogger() != null;
084
085        this.getLogger().debug( "TEST" );
086        this.getLogger().debug( new Exception() );
087
088        this.getLogger().error( "TEST" );
089        this.getLogger().error( new Exception() );
090
091        this.getLogger().fatal( "TEST" );
092        this.getLogger().fatal( new Exception() );
093
094        this.getLogger().info( "TEST" );
095        this.getLogger().info( new Exception() );
096
097        this.getLogger().trace( "TEST" );
098        this.getLogger().trace( new Exception() );
099
100        this.getLogger().warn( "TEST" );
101        this.getLogger().warn( new Exception() );
102    }
103
104    //-------------------------------------------------------------------Tests--
105}