leif        02/02/24 20:50:18

  Modified:    src/java/org/apache/avalon/excalibur/testcase
                        ExcaliburTestCase.java
  Log:
  Fix a problem where the logger was not being set for tests which
  implement Initializable and reference the Logger in their initialize
  method.
  
  Revision  Changes    Path
  1.20      +17 -4     
jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/testcase/ExcaliburTestCase.java
  
  Index: ExcaliburTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/testcase/ExcaliburTestCase.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ExcaliburTestCase.java    20 Feb 2002 10:41:10 -0000      1.19
  +++ ExcaliburTestCase.java    25 Feb 2002 04:50:18 -0000      1.20
  @@ -146,7 +146,7 @@
    * </pre>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version $Id: ExcaliburTestCase.java,v 1.19 2002/02/20 10:41:10 leif Exp $
  + * @version $Id: ExcaliburTestCase.java,v 1.20 2002/02/25 04:50:18 leif Exp $
    */
   public class ExcaliburTestCase
       extends TestCase
  @@ -216,9 +216,6 @@
           final String resourceName = this.getClass().getName().replace( '.', 
'/' ) + ".xtest";
           URL resource = this.getClass().getClassLoader().getResource( 
resourceName );
           
  -        // Set the logger for the initialization phase.
  -        setCurrentLogger( "testcase" );
  -        
           if ( resource != null ) {
               getLogger().debug("Loading resource " + resourceName);
               prepare( resource.openStream() );
  @@ -276,10 +273,26 @@
       }
   
       /**
  +     * Exctract the base class name of a class.
  +     */
  +    private String getBaseClassName(Class clazz) {
  +        String name = clazz.getName();
  +        int pos = name.lastIndexOf('.');
  +        if (pos >= 0)
  +        {
  +            name = name.substring(pos + 1);
  +        }
  +        return name;
  +    }
  +    
  +    /**
        * Override <code>run</code> so that we can have code that is run once.
        */
       final public void run(TestResult result)
       {
  +        // Set the logger for the initialization phase.
  +        setCurrentLogger( getBaseClassName( getClass() ) );
  +        
           ArrayList methodList = (ArrayList) ExcaliburTestCase.m_tests.get( 
this.getClass() );
   
           if ( null == methodList || methodList.isEmpty() )
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to