You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2005/09/05 22:48:17 UTC

svn commit: r278832 - /db/torque/test/trunk/maven-test-plugin/src/plugin-resources/java/org/apache/torque/BaseRuntimeTestCase.java

Author: tfischer
Date: Mon Sep  5 13:48:15 2005
New Revision: 278832

URL: http://svn.apache.org/viewcvs?rev=278832&view=rev
Log:
initialize logging, correct path to the Torque.properties file

Modified:
    db/torque/test/trunk/maven-test-plugin/src/plugin-resources/java/org/apache/torque/BaseRuntimeTestCase.java

Modified: db/torque/test/trunk/maven-test-plugin/src/plugin-resources/java/org/apache/torque/BaseRuntimeTestCase.java
URL: http://svn.apache.org/viewcvs/db/torque/test/trunk/maven-test-plugin/src/plugin-resources/java/org/apache/torque/BaseRuntimeTestCase.java?rev=278832&r1=278831&r2=278832&view=diff
==============================================================================
--- db/torque/test/trunk/maven-test-plugin/src/plugin-resources/java/org/apache/torque/BaseRuntimeTestCase.java (original)
+++ db/torque/test/trunk/maven-test-plugin/src/plugin-resources/java/org/apache/torque/BaseRuntimeTestCase.java Mon Sep  5 13:48:15 2005
@@ -18,6 +18,12 @@
 
 import junit.framework.TestCase;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.impl.Log4JLogger;
+import org.apache.commons.logging.impl.LogFactoryImpl;
+import org.apache.log4j.PropertyConfigurator;
+
 /**
  * Base functionality to be extended by all Torque test cases.  Test
  * case implementations are used to automate unit testing via JUnit.
@@ -27,12 +33,36 @@
  */
 public abstract class BaseRuntimeTestCase extends TestCase
 {
-    /** The path to the configuration file. */
+    /** The path to the Torque configuration file. */
     private static final String CONFIG_FILE
-            = "target/test/rttest/Torque.properties";
+            = "target/tests/base/Torque.properties";
+
+    /** The path to the log4j configuration file. */
+    private static final String LOG4J_CONFIG_FILE
+            = "target/tests/base/log4j.properties";
 
     /** Whether torque has been initialized. */
     static boolean hasInitialized = false;
+
+    static
+    {
+        // initialize log4j
+        PropertyConfigurator.configure(LOG4J_CONFIG_FILE);
+
+        // initialize commons-logging
+        // For whatever reasons, the default logger seems to be simplelog here.
+        // Only the loggers created after this configuration will be log4j
+        // loggers and write to the output file.
+        // Not the optimal solution, but better than nothing.
+        LogFactory.releaseAll();
+        LogFactory factory = LogFactory.getFactory();
+        factory.setAttribute(
+                LogFactoryImpl.LOG_PROPERTY,
+                Log4JLogger.class.getName());
+
+        Log log = LogFactory.getLog(BaseRuntimeTestCase.class);
+        log.debug("Initialized Logging");
+    }
 
     /**
      * Creates a new instance.



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org