jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r984713 - in /jackrabbit/trunk: jackrabbit-core/src/test/resources/logback-test.xml jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JUnitTest.java
Date Thu, 12 Aug 2010 10:29:54 GMT
Author: jukka
Date: Thu Aug 12 10:29:53 2010
New Revision: 984713

URL: http://svn.apache.org/viewvc?rev=984713&view=rev
Log:
JCR-2693: Logging per test case

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/resources/logback-test.xml
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JUnitTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/resources/logback-test.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/resources/logback-test.xml?rev=984713&r1=984712&r2=984713&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/resources/logback-test.xml (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/resources/logback-test.xml Thu Aug 12 10:29:53
2010
@@ -24,10 +24,26 @@
     </encoder>
   </appender>
 
+  <appender name="sift" class="ch.qos.logback.classic.sift.SiftingAppender">
+    <discriminator>
+      <Key>testclass</Key>
+      <DefaultValue>junit</DefaultValue>
+    </discriminator>
+    <sift>
+      <appender name="FILE-${testname}" class="ch.qos.logback.core.FileAppender">
+        <File>target/surefire-reports/${testclass}.log</File>
+        <layout class="ch.qos.logback.classic.PatternLayout">
+          <Pattern>%date{HH:mm:ss.SSS} %-5level %-40([%thread] %F:%L) %msg%n</Pattern>
+        </layout>
+      </appender>
+    </sift>
+  </appender>
+
   <logger name="org.apache.jackrabbit.test" level="DEBUG"/>
 
   <root level="INFO">
     <appender-ref ref="file"/>
+    <appender-ref ref="sift"/>
   </root>
 
 </configuration>

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JUnitTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JUnitTest.java?rev=984713&r1=984712&r2=984713&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JUnitTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JUnitTest.java
Thu Aug 12 10:29:53 2010
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.test;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
 
 import junit.framework.TestCase;
 
@@ -29,11 +30,25 @@ public abstract class JUnitTest extends 
     /**
      * Logger instance for test cases
      */
-    private static final Logger logger = LoggerFactory.getLogger(JUnitTest.class);
+    protected final Logger logger = LoggerFactory.getLogger(getClass());
 
     /**
      * Output stream for general messages from tests.
      */
     public final LogPrintWriter log = new LogPrintWriter(logger);
 
+    protected void setUp() throws Exception {
+        super.setUp();
+        MDC.put("testclass", getClass().getName());
+        MDC.put("testcase", getName());
+        logger.info("Starting test case {}", getName());
+    }
+ 
+    protected void tearDown() throws Exception {
+        logger.info("Completed test case {}", getName());
+        MDC.remove("testcase");
+        MDC.remove("testclass");
+        super.tearDown();
+    }
+
 }



Mime
View raw message