| 1 | /* |
| 2 | * jDTAUS Core Test Suite |
| 3 | * Copyright (C) 2005 Christian Schulte |
| 4 | * <cs@schulte.it> |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | * |
| 20 | */ |
| 21 | package org.jdtaus.core.logging.spi.it; |
| 22 | |
| 23 | import junit.framework.TestCase; |
| 24 | import org.jdtaus.core.logging.spi.Logger; |
| 25 | |
| 26 | /** |
| 27 | * Testcase for {@code Logger} implementations. |
| 28 | * |
| 29 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> |
| 30 | * @version $JDTAUS: LoggerTest.java 8743 2012-10-07 03:06:20Z schulte $ |
| 31 | */ |
| 32 | public class LoggerTest extends TestCase |
| 33 | { |
| 34 | //--LoggerTest-------------------------------------------------------------- |
| 35 | |
| 36 | /** Implementation to test. */ |
| 37 | private Logger logger; |
| 38 | |
| 39 | /** Creates a new {@code LoggerTest} instance. */ |
| 40 | public LoggerTest() |
| 41 | { |
| 42 | super(); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Gets the {@code Logger} implementation tests are performed with. |
| 47 | * |
| 48 | * @return the {@code Logger} implementation tests are performed with. |
| 49 | */ |
| 50 | public Logger getLogger() |
| 51 | { |
| 52 | return this.logger; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Sets the {@code Logger} implementation tests are performed with. |
| 57 | * |
| 58 | * @param value the {@code Logger} implementation to perform tests with. |
| 59 | */ |
| 60 | public final void setLogger( final Logger value ) |
| 61 | { |
| 62 | this.logger = value; |
| 63 | } |
| 64 | |
| 65 | //--------------------------------------------------------------LoggerTest-- |
| 66 | //--Tests------------------------------------------------------------------- |
| 67 | |
| 68 | /** |
| 69 | * Tests the {@link Logger#isInfoEnabled() isXxxEnabled()} methods to not |
| 70 | * throw any exceptions. |
| 71 | */ |
| 72 | public void testIsEnabled() throws Exception |
| 73 | { |
| 74 | assert this.getLogger() != null; |
| 75 | |
| 76 | this.getLogger().isDebugEnabled(); |
| 77 | this.getLogger().isErrorEnabled(); |
| 78 | this.getLogger().isFatalEnabled(); |
| 79 | this.getLogger().isInfoEnabled(); |
| 80 | this.getLogger().isTraceEnabled(); |
| 81 | this.getLogger().isWarnEnabled(); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Test the various logger methods to not throw any exceptions. |
| 86 | */ |
| 87 | public void testLog() throws Exception |
| 88 | { |
| 89 | assert this.getLogger() != null; |
| 90 | |
| 91 | this.getLogger().debug( "TEST" ); |
| 92 | this.getLogger().debug( new Exception() ); |
| 93 | |
| 94 | this.getLogger().error( "TEST" ); |
| 95 | this.getLogger().error( new Exception() ); |
| 96 | |
| 97 | this.getLogger().fatal( "TEST" ); |
| 98 | this.getLogger().fatal( new Exception() ); |
| 99 | |
| 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 | } |