Author: justin
Date: Mon Aug 16 14:58:31 2010
New Revision: 985980
URL: http://svn.apache.org/viewvc?rev=985980&view=rev
Log:
SLING-1659 - adding MDC setup to HttpTestBase and logback-test.xml (based
heavily on the one from jackrabbit-core)
Added:
sling/trunk/launchpad/testing/src/test/resources/logback-test.xml
Modified:
sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
Modified:
sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java?rev=985980&r1=985979&r2=985980&view=diff
==============================================================================
---
sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
(original)
+++
sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
Mon Aug 16 14:58:31 2010
@@ -41,6 +41,7 @@ import org.apache.commons.httpclient.aut
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.sling.commons.testing.util.JavascriptEngine;
+import org.slf4j.MDC;
/** Base class for HTTP-based Sling Launchpad integration tests */
public class HttpTestBase extends TestCase {
@@ -118,6 +119,9 @@ public class HttpTestBase extends TestCa
@Override
protected void setUp() throws Exception {
super.setUp();
+
+ MDC.put("testclass", getClass().getName());
+ MDC.put("testcase", getName());
// assume http and webdav are on the same host + port
URL url = null;
@@ -141,6 +145,9 @@ public class HttpTestBase extends TestCa
@Override
protected void tearDown() throws Exception {
+ MDC.remove("testcase");
+ MDC.remove("testclass");
+
super.tearDown();
for(String url : urlsToDelete) {
Added: sling/trunk/launchpad/testing/src/test/resources/logback-test.xml
URL:
http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/resources/logback-test.xml?rev=985980&view=auto
==============================================================================
--- sling/trunk/launchpad/testing/src/test/resources/logback-test.xml (added)
+++ sling/trunk/launchpad/testing/src/test/resources/logback-test.xml Mon Aug
16 14:58:31 2010
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<configuration>
+
+ <appender name="file" class="ch.qos.logback.core.FileAppender">
+ <file>target/sling-tests.log</file>
+ <encoder>
+ <pattern>%date{HH:mm:ss.SSS} %-5level %-40([%thread] %F:%L)
%msg%n</pattern>
+ </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.sling.launchpad" level="DEBUG" />
+
+ <root level="INFO">
+ <appender-ref ref="file" />
+ <appender-ref ref="sift" />
+ </root>
+
+</configuration>
\ No newline at end of file