[jboss-cvs] apache/commons-logging/src/test/org/apache/commons/logging/noop ...

Scott Stark scott.stark at jboss.com
Fri Feb 9 01:57:21 EST 2007


  User: starksm 
  Date: 07/02/09 01:57:21

  Added:       commons-logging/src/test/org/apache/commons/logging/noop 
                        NoOpLogTestCase.java
  Log:
  Update to the http://apache.ziply.com/jakarta/commons/logging/source/commons-logging-1.1-src.zip release
  
  Revision  Changes    Path
  1.1      date: 2007/02/09 06:57:21;  author: starksm;  state: Exp;apache/commons-logging/src/test/org/apache/commons/logging/noop/NoOpLogTestCase.java
  
  Index: NoOpLogTestCase.java
  ===================================================================
  /*
   * Copyright 2001-2006 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */ 
   
  package org.apache.commons.logging.noop;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.commons.logging.impl.NoOpLog;
  import org.apache.commons.logging.AbstractLogTest;
  
  /**
   * Tests for NoOpLog logging adapter.
   * <p>
   * This simply applies the tests defined in AbstractLogTest to this class.
   */
  public class NoOpLogTestCase extends AbstractLogTest
  {
      /**
       * Set up instance variables required by this test case.
       */
      public void setUp() throws Exception {
          LogFactory.releaseAll();
  
          System.setProperty(
                  "org.apache.commons.logging.Log",
                  "org.apache.commons.logging.impl.NoOpLog");
      }
  
      /**
       * Tear down instance variables required by this test case.
       */
      public void tearDown() {
          LogFactory.releaseAll();
      }
      
      /**
  	 * Override the abstract method from the parent class so that the
       * inherited tests can access the right Log object type. 
  	 */
  	public Log getLogObject()
  	{
  		return (Log) new NoOpLog(this.getClass().getName());
  	}
  
      // Test Serializability of standard instance
      public void testSerializable() throws Exception {
          Log log = LogFactory.getLog(this.getClass().getName());
          checkLog(log);
  
          // Serialize and deserialize the instance
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ObjectOutputStream oos = new ObjectOutputStream(baos);
          oos.writeObject(log);
          oos.close();
          ByteArrayInputStream bais =
              new ByteArrayInputStream(baos.toByteArray());
          ObjectInputStream ois = new ObjectInputStream(bais);
          log = (Log) ois.readObject();
          ois.close();
  
          checkLog(log);
      }
  
  
      // -------------------------------------------------------- Support Methods
  
      private void checkLog(Log log) {
  
          assertNotNull("Log exists", log);
          assertEquals("Log class",
                       "org.apache.commons.logging.impl.NoOpLog",
                       log.getClass().getName());
  
          // Can we call level checkers with no exceptions?
          // Note that *everything* is permanently disabled for NoOpLog
          assertFalse(log.isTraceEnabled());
          assertFalse(log.isDebugEnabled());
          assertFalse(log.isInfoEnabled());
          assertFalse(log.isWarnEnabled());
          assertFalse(log.isErrorEnabled());
          assertFalse(log.isFatalEnabled());
      }
  }
  
  
  



More information about the jboss-cvs-commits mailing list