Skip to content

Replace Pax Logging with Logback in Pax Exam tests #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 33 additions & 19 deletions scr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
<bundle.file.name>
${bundle.build.name}/${project.build.finalName}.jar
</bundle.file.name>
<felix.ca.version>1.9.0</felix.ca.version>

<java.version>8</java.version>
<felix.java.version>${java.version}</felix.java.version>
Expand Down Expand Up @@ -121,13 +120,13 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.util.promise</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.util.function</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -196,30 +195,17 @@
<version>2.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>1.6.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-service</artifactId>
<version>1.6.3</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.3.15</version>
<version>1.2.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.3.12</version>
<version>1.2.12</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -264,6 +250,18 @@
<version>5.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.util.pushstream</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.configadmin</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<directory>${bundle.build.name}</directory>
Expand Down Expand Up @@ -329,6 +327,22 @@
<source>${java.version}</source>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<goals>
<goal>generate-depends-file</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<outputFile>${project.build.testOutputDirectory}/META-INF/maven/dependencies.properties</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.felix.scr.integration;

import static org.ops4j.pax.exam.Constants.EXAM_FAIL_ON_UNRESOLVED_KEY;
import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
Expand Down Expand Up @@ -138,8 +139,6 @@ public abstract class ComponentTestBase
//set to true to only get last 1000 lines of log.
protected static boolean restrictedLogging;

protected static String felixCaVersion = System.getProperty( "felix.ca.version" );

protected static final String PROP_NAME_FACTORY = ComponentTestBase.PROP_NAME + ".factory";

static
Expand Down Expand Up @@ -184,18 +183,23 @@ public static Option[] configuration()
final Option[] base = options(
provision(
CoreOptions.bundle( bundleFile.toURI().toString() ),
mavenBundle( "org.ops4j.pax.tinybundles", "tinybundles", "1.0.0" ),
mavenBundle( "org.osgi", "org.osgi.service.log", "1.4.0"),
mavenBundle( "org.osgi", "org.osgi.util.pushstream", "1.0.0"),
mavenBundle( "org.apache.felix", "org.apache.felix.configadmin", felixCaVersion ) ),
mavenBundle( "org.osgi", "org.osgi.util.promise"),
mavenBundle( "org.osgi", "org.osgi.util.function"),
mavenBundle( "org.osgi", "org.osgi.service.component"),
mavenBundle( "org.ops4j.pax.url", "pax-url-aether"),
mavenBundle( "org.ops4j.pax.tinybundles", "tinybundles" ).versionAsInProject(),
mavenBundle( "org.osgi", "org.osgi.service.log" ).versionAsInProject(),
mavenBundle( "org.slf4j", "slf4j-api" ).versionAsInProject(),
mavenBundle( "ch.qos.logback", "logback-core" ).versionAsInProject(),
mavenBundle( "ch.qos.logback", "logback-classic" ).versionAsInProject(),
mavenBundle( "org.osgi", "org.osgi.util.pushstream" ).versionAsInProject(),
mavenBundle( "org.apache.felix", "org.apache.felix.configadmin" ).versionAsInProject() ),
mavenBundle( "org.osgi", "org.osgi.util.promise" ).versionAsInProject(),
mavenBundle( "org.osgi", "org.osgi.util.function" ).versionAsInProject(),
mavenBundle( "org.osgi", "org.osgi.service.component" ).versionAsInProject(),
mavenBundle( "org.ops4j.pax.url", "pax-url-aether" ).versionAsInProject(),
junitBundles(), frameworkProperty( "org.osgi.framework.bsnversion" ).value( bsnVersionUniqueness ),
systemProperty( "ds.factory.enabled" ).value( Boolean.toString( NONSTANDARD_COMPONENT_FACTORY_BEHAVIOR ) ),
systemProperty( "ds.loglevel" ).value( DS_LOGLEVEL ),
systemProperty( "ds.cache.metadata" ).value( Boolean.toString(CACHE_META_DATA) )
systemProperty( "ds.cache.metadata" ).value( Boolean.toString(CACHE_META_DATA) ),
systemProperty( "logback.configurationFile" ).value( "src/test/resources/logback-test.xml" ),
systemProperty( EXAM_FAIL_ON_UNRESOLVED_KEY ).value( "true" )

);
final Option vmOption = ( paxRunnerVmOption != null )? CoreOptions.vmOption( paxRunnerVmOption ): null;
Expand Down
19 changes: 19 additions & 0 deletions scr/src/test/resources/exam.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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.
#
# Prevent PAX Logging to be activated
pax.exam.logging=none
33 changes: 33 additions & 0 deletions scr/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
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>

<!-- defined a console append -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%15.15thread] %-5level %-36.36logger{36} - %msg%n</pattern>
</encoder>
</appender>

<logger name="shaded.org.apache.http" level="WARN" />

<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration>