Skip to content

Commit 819650c

Browse files
committed
Fix OSGi tests
1 parent c8c212f commit 819650c

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

log4j-api-test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
-->
3737
<bnd-module-name>org.apache.logging.log4j.test</bnd-module-name>
3838
<bnd-extra-package-options>
39+
org.apache.commons.lang3.*;resolution:=optional,
3940
<!-- Both JUnit 4 and JUnit 5 are not required -->
4041
org.junit.*;resolution:=optional,
4142
org.hamcrest.*;resolution:=optional,
@@ -55,7 +56,6 @@
5556
maven.model.builder;substitute="maven-model-builder";transitive=false;static=true,
5657
plexus.utils;substitute="plexus-utils";transitive=false;static=true
5758
</bnd-extra-module-options>
58-
<Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
5959
</properties>
6060
<dependencies>
6161
<dependency>

log4j-osgi/src/test/java/org/apache/logging/log4j/osgi/tests/AbstractLoadBundleTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ private Bundle getCoreBundle() throws BundleException {
7171
}
7272

7373
private Bundle get12ApiBundle() throws BundleException {
74-
return installBundle("org.apache.logging.log4j.1.2-api");
74+
return installBundle("org.apache.logging.log4j.1.2.api");
7575
}
7676

7777
private Bundle getApiTestsBundle() throws BundleException {
78-
return installBundle("org.apache.logging.log4j.api-test");
78+
return installBundle("org.apache.logging.log4j.api.test");
7979
}
8080

8181
protected abstract FrameworkFactory getFactory();
@@ -261,21 +261,21 @@ public void testServiceLoader() throws BundleException, ReflectiveOperationExcep
261261
final Class<?> osgiServiceLocator = api.loadClass("org.apache.logging.log4j.util.OsgiServiceLocator");
262262
assertTrue("OsgiServiceLocator is active", (boolean) osgiServiceLocator.getMethod("isAvailable").invoke(null));
263263

264-
api.start();
265264
core.start();
266-
assertEquals("api-tests is not in RESOLVED state", Bundle.RESOLVED, apiTests.getState());
265+
apiTests.start();
266+
assertEquals("api-tests is not in ACTIVE state", Bundle.ACTIVE, apiTests.getState());
267267

268-
final Class<?> osgiServiceLocatorTest = api.loadClass("org.apache.logging.log4j.test.util.OsgiServiceLocatorTest");
268+
final Class<?> osgiServiceLocatorTest = apiTests.loadClass("org.apache.logging.log4j.test.util.OsgiServiceLocatorTest");
269269

270270
final Method loadProviders = osgiServiceLocatorTest.getDeclaredMethod("loadProviders");
271271
final Object obj = loadProviders.invoke(null);
272272
assertTrue(obj instanceof Stream);
273273
@SuppressWarnings("unchecked")
274-
final
275-
List<Object> services = ((Stream<Object>) obj).collect(Collectors.toList());
274+
final List<Object> services = ((Stream<Object>) obj).collect(Collectors.toList());
276275
assertEquals(1, services.size());
277276
assertEquals("org.apache.logging.log4j.core.impl.Log4jProvider", services.get(0).getClass().getName());
278277

278+
apiTests.stop();
279279
core.stop();
280280
api.stop();
281281
assertEquals("api-tests is not in ACTIVE state", Bundle.RESOLVED, apiTests.getState());

log4j-osgi/src/test/java/org/apache/logging/log4j/osgi/tests/JULProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class JULProviderTest {
5151
public Option[] config() {
5252
return options(
5353
linkBundle("org.apache.logging.log4j.api"),
54-
linkBundle("org.apache.logging.log4j.to-jul"),
54+
linkBundle("org.apache.logging.log4j.to.jul"),
5555
// required by Pax Exam's logging
5656
linkBundle("slf4j.api"),
5757
linkBundle("ch.qos.logback.classic"),
@@ -62,7 +62,7 @@ public Option[] config() {
6262
@Test(timeout = 10_000L)
6363
public void testJulFactoryResolves() {
6464
final Optional<Bundle> julBundle = Stream.of(context.getBundles())
65-
.filter(b -> "org.apache.logging.log4j.to-jul".equals(b.getSymbolicName()))
65+
.filter(b -> "org.apache.logging.log4j.to.jul".equals(b.getSymbolicName()))
6666
.findAny();
6767
assertTrue(julBundle.isPresent());
6868
final LoggerContextFactory factory = LogManager.getFactory();

log4j-osgi/src/test/java/org/apache/logging/log4j/osgi/tests/SLF4JProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class SLF4JProviderTest {
5151
public Option[] config() {
5252
return options(
5353
linkBundle("org.apache.logging.log4j.api"),
54-
linkBundle("org.apache.logging.log4j.to-slf4j"),
54+
linkBundle("org.apache.logging.log4j.to.slf4j"),
5555
linkBundle("slf4j.api"),
5656
linkBundle("ch.qos.logback.classic"),
5757
linkBundle("ch.qos.logback.core"),
@@ -61,7 +61,7 @@ public Option[] config() {
6161
@Test(timeout = 10_000L)
6262
public void testSlf4jFactoryResolves() {
6363
final Optional<Bundle> slf4jBundle = Stream.of(context.getBundles())
64-
.filter(b -> "org.apache.logging.log4j.to-slf4j".equals(b.getSymbolicName()))
64+
.filter(b -> "org.apache.logging.log4j.to.slf4j".equals(b.getSymbolicName()))
6565
.findAny();
6666
assertTrue(slf4jBundle.isPresent());
6767
final LoggerContextFactory factory = LogManager.getFactory();

log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/Activator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
package org.apache.logging.slf4j;
1818

1919
import org.apache.logging.log4j.util.ProviderActivator;
20+
import org.osgi.annotation.bundle.Header;
2021

22+
@Header(name = org.osgi.framework.Constants.BUNDLE_ACTIVATOR, value = "${@class}")
23+
@Header(name = org.osgi.framework.Constants.BUNDLE_ACTIVATIONPOLICY, value = org.osgi.framework.Constants.ACTIVATION_LAZY)
2124
public class Activator extends ProviderActivator {
2225

2326
public Activator() {

0 commit comments

Comments
 (0)