Hi,

I'm having problems with the logging component in conjunction with Unit
Tests (JUnit). Within a testCase I cannot use the logging component. I keep
getting the error:

Class org.apache.commons.logging.impl.Log4JCategoryLog does not implement
Log

I looked at the class Log4JCategoryLog and it clearly does implement the
class Log.

Below you can find the full stack trace as well as a sample Unit Test Class.

Note: 
- The Main method within the test class does not throw any exception,
however the testCase does.
- I have not explicitly specified which Log Implementation to use, however
Log4J is available within the classpath.

thanks,

Martin Maher

##############
Exception:

0 [main] INFO part.TestLogger  - Test 1 

org.apache.commons.logging.LogConfigurationException: 
org.apache.commons.logging.LogConfigurationException: 
org.apache.commons.logging.LogConfigurationException: Class
org.apache.commons.logging.impl.Log4JCategoryLog does not implement Log

at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.ja
va:555)         
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.ja
va:289)         
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.ja
va:259)         
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:390)    
at
com.webasto.cimload.transformer.part.TestLogger.outputLogMessage(TestLogger.
java:44)        
at com.webasto.cimload.transformer.part.TestLogger.testA(TestLogger.java:36)

at java.lang.reflect.Method.invoke(Native Method)       
at junit.framework.TestCase.runTest(TestCase.java:166)  
at junit.framework.TestCase.runBare(TestCase.java:140)  
at junit.framework.TestResult$1.protect(TestResult.java:106)    
at junit.framework.TestResult.runProtected(TestResult.java:124)         
at junit.framework.TestResult.run(TestResult.java:109)  
at junit.framework.TestCase.run(TestCase.java:131)      
at junit.framework.TestSuite.runTest(TestSuite.java:173)        
at junit.framework.TestSuite.run(TestSuite.java:168)    
at junit.swingui.TestRunner$17.run(TestRunner.java:644) 

##############
Class:

package com.webasto.cimload.transformer.part;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import junit.framework.TestCase;
import junit.framework.TestSuite;

public class TestLogger extends TestCase {

  public TestLogger(String _name) {
    super(_name);
  }

  public void testA() {
    try {
      outputLogMessage("Test 2");
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }

  public static void outputLogMessage(String msg) {
    Log log = LogFactory.getLog(TestLogger.class);
    log.info(msg);
  }

  public static void main(String[] argv) {

    outputLogMessage("Test 1");

    String[] testCaseList = {TestLogger.class.getName()};

    junit.swingui.TestRunner.main(testCaseList);
  }

}

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

Reply via email to