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 8743 2012-10-07 03:06:20Z schulte $
031 */
032public class LoggerTest extends TestCase
033{
034    //--LoggerTest--------------------------------------------------------------
035
036    /** Implementation to test. */
037    private Logger logger;
038
039    /** Creates a new {@code LoggerTest} instance. */
040    public LoggerTest()
041    {
042        super();
043    }
044
045    /**
046     * Gets the {@code Logger} implementation tests are performed with.
047     *
048     * @return the {@code Logger} implementation tests are performed with.
049     */
050    public Logger getLogger()
051    {
052        return this.logger;
053    }
054
055    /**
056     * Sets the {@code Logger} implementation tests are performed with.
057     *
058     * @param value the {@code Logger} implementation to perform tests with.
059     */
060    public final void setLogger( final Logger value )
061    {
062        this.logger = value;
063    }
064
065    //--------------------------------------------------------------LoggerTest--
066    //--Tests-------------------------------------------------------------------
067
068    /**
069     * Tests the {@link Logger#isInfoEnabled() isXxxEnabled()} methods to not
070     * throw any exceptions.
071     */
072    public void testIsEnabled() throws Exception
073    {
074        assert this.getLogger() != null;
075
076        this.getLogger().isDebugEnabled();
077        this.getLogger().isErrorEnabled();
078        this.getLogger().isFatalEnabled();
079        this.getLogger().isInfoEnabled();
080        this.getLogger().isTraceEnabled();
081        this.getLogger().isWarnEnabled();
082    }
083
084    /**
085     * Test the various logger methods to not throw any exceptions.
086     */
087    public void testLog() throws Exception
088    {
089        assert this.getLogger() != null;
090
091        this.getLogger().debug( "TEST" );
092        this.getLogger().debug( new Exception() );
093
094        this.getLogger().error( "TEST" );
095        this.getLogger().error( new Exception() );
096
097        this.getLogger().fatal( "TEST" );
098        this.getLogger().fatal( new Exception() );
099
100        this.getLogger().info( "TEST" );
101        this.getLogger().info( new Exception() );
102
103        this.getLogger().trace( "TEST" );
104        this.getLogger().trace( new Exception() );
105
106        this.getLogger().warn( "TEST" );
107        this.getLogger().warn( new Exception() );
108    }
109
110    //-------------------------------------------------------------------Tests--
111}