001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     * 
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     * 
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */ 
017     
018     
019    package org.apache.commons.logging;
020    
021    import junit.framework.TestCase;
022    
023    
024    /**
025      * Generic tests that can be applied to any log adapter by
026      * subclassing this class and defining method getLogObject
027      * appropriately.
028      * 
029      * @author Sean C. Sullivan
030      * @version $Revision: 581090 $
031      */
032    public abstract class AbstractLogTest extends TestCase {
033    
034        public abstract Log getLogObject();
035    
036        public void testLoggingWithNullParameters()
037        {
038            Log log = this.getLogObject();
039    
040            assertNotNull(log);
041    
042    
043            log.debug(null);
044    
045            log.debug(null, null);
046    
047            log.debug(log.getClass().getName() + ": debug statement");
048    
049            log.debug(log.getClass().getName() + ": debug statement w/ null exception", new RuntimeException());
050    
051    
052            log.error(null);
053    
054            log.error(null, null);
055    
056            log.error(log.getClass().getName() + ": error statement");
057    
058            log.error(log.getClass().getName() + ": error statement w/ null exception", new RuntimeException());
059    
060    
061            log.fatal(null);
062    
063            log.fatal(null, null);
064    
065            log.fatal(log.getClass().getName() + ": fatal statement");
066    
067            log.fatal(log.getClass().getName() + ": fatal statement w/ null exception", new RuntimeException());
068    
069    
070            log.info(null);
071    
072            log.info(null, null);
073    
074            log.info(log.getClass().getName() + ": info statement");
075    
076            log.info(log.getClass().getName() + ": info statement w/ null exception", new RuntimeException());
077    
078    
079            log.trace(null);
080    
081            log.trace(null, null);
082    
083            log.trace(log.getClass().getName() + ": trace statement");
084    
085            log.trace(log.getClass().getName() + ": trace statement w/ null exception", new RuntimeException());
086    
087    
088            log.warn(null);
089    
090            log.warn(null, null);
091    
092            log.warn(log.getClass().getName() + ": warn statement");
093    
094            log.warn(log.getClass().getName() + ": warn statement w/ null exception", new RuntimeException());
095        }    
096    }