cvs commit: spice/components/loggerstore/src/test/org/jcomponent/loggerstore MockLogKitLoggerStoreFactory.java LoggerStoreFactoryTestCase.java

Mauro Talevi <[email protected]> Mon, 10 Nov 2003 11:42:52 -0800
Newsgroups gmane.comp.java.spice.cvs
Message-ID <[email protected]>
maurotalevi    03/11/10 11:42:52

  Modified:    components/loggerstore/src/test/org/jcomponent/loggerstore
                        LoggerStoreFactoryTestCase.java
  Added:       components/loggerstore/src/test/org/jcomponent/loggerstore
                        MockLogKitLoggerStoreFactory.java
  Log:
  Completed test coverage
  
  Revision  Changes    Path
  1.7       +30 -1     spice/components/loggerstore/src/test/org/jcomponent/loggerstore/LoggerStoreFactoryTestCase.java
  
  Index: LoggerStoreFactoryTestCase.java
  ===================================================================
  RCS file: /cvsroot/spice/spice/components/loggerstore/src/test/org/jcomponent/loggerstore/LoggerStoreFactoryTestCase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LoggerStoreFactoryTestCase.java	18 Oct 2003 11:52:21 -0000	1.6
  +++ LoggerStoreFactoryTestCase.java	10 Nov 2003 19:42:52 -0000	1.7
  @@ -132,6 +132,20 @@
           runInvalidInputData( new LogKitLoggerStoreFactory() );
       }
   
  +    public void testLogKitLoggerStoreFactoryWithNullContextClassLoader()
  +        throws Exception
  +    {
  +        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        final HashMap config = new HashMap();
  +        config.put( Configuration.class.getName(), 
  +                    builder.build( getResource( "logkit-excalibur.xml" ) ) );
  +        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
  +        Thread.currentThread().setContextClassLoader( null );       
  +        final MockLogKitLoggerStoreFactory factory = new MockLogKitLoggerStoreFactory();
  +        assertEquals("LogKit ClassLoader", factory.getClassLoader(config), LogKitLoggerStoreFactory.class.getClassLoader() );
  +        Thread.currentThread().setContextClassLoader( contextClassLoader );
  +    }
  +
       public void testLogKitLoggerStoreFactoryWithSpecifiedClassLoader()
           throws Exception
       {
  @@ -147,6 +161,22 @@
                           "logkit-excalibur" );
       }
   
  +    public void testLogKitLoggerStoreFactoryWithSpecifiedAvalonLogger()
  +        throws Exception
  +    {
  +        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        final HashMap config = new HashMap();
  +        config.put( Configuration.class.getName(), 
  +                    builder.build( getResource( "logkit-excalibur.xml" ) ) );
  +        config.put( org.apache.avalon.framework.logger.Logger.class.getName(), 
  +                    new org.apache.avalon.framework.logger.ConsoleLogger() );
  +        
  +        runFactoryTest( new LogKitLoggerStoreFactory(),
  +                        ConsoleLogger.LEVEL_INFO,
  +                        config,
  +                        "logkit-excalibur" );
  +    }
  +
       public void testLogKitLoggerStoreFactoryWithConfigurationAndDefaultLoggerManager()
           throws Exception
       {
  @@ -154,7 +184,6 @@
           final HashMap config = new HashMap();
           config.put( Configuration.class.getName(), 
                       builder.build( getResource( "logkit-excalibur.xml" ) ) );
  -        config.put( Logger.class.getName(), new ConsoleLogger() );
   
           runFactoryTest( new LogKitLoggerStoreFactory(),
                           ConsoleLogger.LEVEL_INFO,
  
  
  
  1.1                  spice/components/loggerstore/src/test/org/jcomponent/loggerstore/MockLogKitLoggerStoreFactory.java
  
  Index: MockLogKitLoggerStoreFactory.java
  ===================================================================
  /*
   * Copyright (C) The Spice Group. All rights reserved.
   *
   * This software is published under the terms of the Spice
   * Software License version 1.1, a copy of which has been included
   * with this distribution in the LICENSE.txt file.
   */
  package org.jcomponent.loggerstore;
  
  import java.util.Map;
  
  import org.jcomponent.loggerstore.factories.LogKitLoggerStoreFactory;
  
  /**
   * MockLogKitLoggerStoreFactory extends LogKitLoggerStoreFactory
   * to allow testing of protected methods, not otherwise testable
   *
   * @author <a href="mailto:mauro.talevi at aquilonia.org">Mauro Talevi</a>
   * @version $Revision: 1.1 $ $Date: 2003/11/10 19:42:52 $
   */
  public class MockLogKitLoggerStoreFactory
      extends LogKitLoggerStoreFactory
  {
  
       protected ClassLoader getClassLoader( final Map data )
       {
           return super.getClassLoader( data );
       }
  
  }
  
  
  


-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/