This is an automated email from the ASF dual-hosted git repository.

olli pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-paxexam.git

commit 7d11ad3d0f198c6a3fc833c4d2b8f9ad62e3bbc3
Author: Oliver Lietz <[email protected]>
AuthorDate: Thu Dec 21 09:52:44 2017 +0100

    SLING-6665 Provide a logging Option for Pax Exam
    
    add initial logback option
---
 .../apache/sling/testing/paxexam/SlingOptions.java | 14 +++++++
 .../testing/paxexam/SlingVersionResolver.java      |  4 ++
 src/main/resources/templates/SlingOptions.txt      | 15 +++++++
 .../resources/templates/SlingVersionResolver.txt   |  6 ++-
 .../testing/paxexam/SlingOptionsLogbackIT.java     | 47 ++++++++++++++++++++++
 src/test/resources/logback.xml                     | 30 ++++++++++++++
 6 files changed, 115 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/testing/paxexam/SlingOptions.java 
b/src/main/java/org/apache/sling/testing/paxexam/SlingOptions.java
index 2663ad6..93ad6be 100644
--- a/src/main/java/org/apache/sling/testing/paxexam/SlingOptions.java
+++ b/src/main/java/org/apache/sling/testing/paxexam/SlingOptions.java
@@ -19,10 +19,12 @@
 package org.apache.sling.testing.paxexam;
 
 import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.util.PathUtils;
 
 import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 import static 
org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
 import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
 
@@ -104,6 +106,18 @@ public class SlingOptions {
         );
     }
 
+    public static Option logback() {
+        final String filename = 
String.format("file:%s/src/test/resources/logback.xml", PathUtils.getBaseDir());
+        return composite(
+            systemProperty("logback.configurationFile").value(filename),
+            
mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").version("1.7.21"),
+            
mavenBundle().groupId("org.slf4j").artifactId("jcl-over-slf4j").version("1.7.21"),
+            
mavenBundle().groupId("ch.qos.logback").artifactId("logback-core").version("1.1.7"),
+            
mavenBundle().groupId("ch.qos.logback").artifactId("logback-classic").version("1.1.7"),
+            config()
+        );
+    }
+
     public static Option sling() {
         return composite(
             config(),
diff --git 
a/src/main/java/org/apache/sling/testing/paxexam/SlingVersionResolver.java 
b/src/main/java/org/apache/sling/testing/paxexam/SlingVersionResolver.java
index f451aba..a465d74 100644
--- a/src/main/java/org/apache/sling/testing/paxexam/SlingVersionResolver.java
+++ b/src/main/java/org/apache/sling/testing/paxexam/SlingVersionResolver.java
@@ -55,6 +55,10 @@ public class SlingVersionResolver implements VersionResolver 
{
         versions.put("org.ops4j.pax.swissbox:pax-swissbox-property", "1.8.3");
         versions.put("org.ops4j.pax.url:pax-url-classpath", "2.5.4");
         versions.put("org.ops4j.pax.url:pax-url-commons", "2.5.4");
+        versions.put("org.slf4j:slf4j-api", "1.7.25");
+        versions.put("org.slf4j:jcl-over-slf4j", "1.7.25");
+        versions.put("ch.qos.logback:logback-core", "1.2.3");
+        versions.put("ch.qos.logback:logback-classic", "1.2.3");
         versions.put("com.composum.sling.core:composum-sling-core-commons", 
"1.8.2");
         versions.put("com.composum.sling.core:composum-sling-core-console", 
"1.8.2");
         versions.put("com.composum.sling.core:composum-sling-core-jslibs", 
"1.8.2");
diff --git a/src/main/resources/templates/SlingOptions.txt 
b/src/main/resources/templates/SlingOptions.txt
index 0e2b340..21198ed 100644
--- a/src/main/resources/templates/SlingOptions.txt
+++ b/src/main/resources/templates/SlingOptions.txt
@@ -19,9 +19,12 @@
 package org.apache.sling.testing.paxexam;
 
 import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.util.PathUtils;
 
 import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 import static 
org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
 import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
 
@@ -102,6 +105,18 @@ public class SlingOptions {
             paxUrl()
         );
     }
+
+    public static Option logback() {
+        final String filename = 
String.format("file:%s/src/test/resources/logback.xml", PathUtils.getBaseDir());
+        return composite(
+            systemProperty("logback.configurationFile").value(filename),
+            
mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").version("1.7.21"),
+            
mavenBundle().groupId("org.slf4j").artifactId("jcl-over-slf4j").version("1.7.21"),
+            
mavenBundle().groupId("ch.qos.logback").artifactId("logback-core").version("1.1.7"),
+            
mavenBundle().groupId("ch.qos.logback").artifactId("logback-classic").version("1.1.7"),
+            config()
+        );
+    }
 [# th:each="feature : ${features}"]
     public static Option [(${feature.javaName})]() {
         return composite([# th:each="fc,fcsStatus : ${feature.getFeatures()}"]
diff --git a/src/main/resources/templates/SlingVersionResolver.txt 
b/src/main/resources/templates/SlingVersionResolver.txt
index 3783b1e..add3a8c 100644
--- a/src/main/resources/templates/SlingVersionResolver.txt
+++ b/src/main/resources/templates/SlingVersionResolver.txt
@@ -54,7 +54,11 @@ public class SlingVersionResolver implements VersionResolver 
{
         versions.put("org.ops4j.base:ops4j-base-util-property", "1.5.0");
         versions.put("org.ops4j.pax.swissbox:pax-swissbox-property", "1.8.3");
         versions.put("org.ops4j.pax.url:pax-url-classpath", "2.5.4");
-        versions.put("org.ops4j.pax.url:pax-url-commons", "2.5.4");[# 
th:each="bundle : ${bundles}"]
+        versions.put("org.ops4j.pax.url:pax-url-commons", "2.5.4");
+        versions.put("org.slf4j:slf4j-api", "1.7.25");
+        versions.put("org.slf4j:jcl-over-slf4j", "1.7.25");
+        versions.put("ch.qos.logback:logback-core", "1.2.3");
+        versions.put("ch.qos.logback:logback-classic", "1.2.3");[# 
th:each="bundle : ${bundles}"]
         versions.put("[(${bundle.groupId})]:[(${bundle.artifactId})]", 
"[(${bundle.version})]");
 [/]    }
 
diff --git 
a/src/test/java/org/apache/sling/testing/paxexam/SlingOptionsLogbackIT.java 
b/src/test/java/org/apache/sling/testing/paxexam/SlingOptionsLogbackIT.java
new file mode 100644
index 0000000..e47ece4
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/paxexam/SlingOptionsLogbackIT.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+package org.apache.sling.testing.paxexam;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+import static org.apache.sling.testing.paxexam.SlingOptions.logback;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class SlingOptionsLogbackIT extends SlingOptionsTestSupport {
+
+    @Configuration
+    public Option[] configuration() {
+        return new Option[]{
+            baseConfiguration(),
+            logback()
+        };
+    }
+
+    @Test
+    public void test() {
+    }
+
+}
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
new file mode 100644
index 0000000..d46a4ae
--- /dev/null
+++ b/src/test/resources/logback.xml
@@ -0,0 +1,30 @@
+<?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/testing.log</file>
+    <encoder>
+      <pattern>%date %level [%thread] %logger{10} [%file : %line] 
%msg%n</pattern>
+    </encoder>
+  </appender>
+  <root level="debug">
+    <appender-ref ref="file"/>
+  </root>
+</configuration>

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to