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 8692 2012-10-01 14:16:57Z schulte $ 31 */ 32 public class LoggerTest extends TestCase 33 { 34 //--LoggerTest-------------------------------------------------------------- 35 36 /** Implementation to test. */ 37 private Logger logger; 38 39 /** 40 * Gets the {@code Logger} implementation tests are performed with. 41 * 42 * @return the {@code Logger} implementation tests are performed with. 43 */ 44 public Logger getLogger() 45 { 46 return this.logger; 47 } 48 49 /** 50 * Sets the {@code Logger} implementation tests are performed with. 51 * 52 * @param value the {@code Logger} implementation to perform tests with. 53 */ 54 public final void setLogger( final Logger value ) 55 { 56 this.logger = value; 57 } 58 59 //--------------------------------------------------------------LoggerTest-- 60 //--Tests------------------------------------------------------------------- 61 62 /** 63 * Tests the {@link Logger#isInfoEnabled() isXxxEnabled()} methods to not 64 * throw any exceptions. 65 */ 66 public void testIsEnabled() throws Exception 67 { 68 assert this.getLogger() != null; 69 70 this.getLogger().isDebugEnabled(); 71 this.getLogger().isErrorEnabled(); 72 this.getLogger().isFatalEnabled(); 73 this.getLogger().isInfoEnabled(); 74 this.getLogger().isTraceEnabled(); 75 this.getLogger().isWarnEnabled(); 76 } 77 78 /** 79 * Test the various logger methods to not throw any exceptions. 80 */ 81 public void testLog() throws Exception 82 { 83 assert this.getLogger() != null; 84 85 this.getLogger().debug( "TEST" ); 86 this.getLogger().debug( new Exception() ); 87 88 this.getLogger().error( "TEST" ); 89 this.getLogger().error( new Exception() ); 90 91 this.getLogger().fatal( "TEST" ); 92 this.getLogger().fatal( new Exception() ); 93 94 this.getLogger().info( "TEST" ); 95 this.getLogger().info( new Exception() ); 96 97 this.getLogger().trace( "TEST" ); 98 this.getLogger().trace( new Exception() ); 99 100 this.getLogger().warn( "TEST" ); 101 this.getLogger().warn( new Exception() ); 102 } 103 104 //-------------------------------------------------------------------Tests-- 105 }