Skip to content

Commit e25c308

Browse files
committed
Port OsgiRule changes from main
1 parent df8e72f commit e25c308

File tree

2 files changed

+12
-43
lines changed

2 files changed

+12
-43
lines changed

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

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
*/
1717
package org.apache.logging.log4j.osgi.tests.junit;
1818

19-
import java.io.InputStream;
2019
import java.util.HashMap;
2120
import java.util.Map;
22-
import java.util.Properties;
23-
import java.util.stream.Collectors;
2421
import org.junit.rules.ExternalResource;
2522
import org.osgi.framework.BundleException;
2623
import org.osgi.framework.launch.Framework;
@@ -53,25 +50,18 @@ protected void after() {
5350

5451
@Override
5552
protected void before() throws Throwable {
56-
try (final InputStream is = OsgiRule.class.getResourceAsStream("/osgi.properties")) {
57-
final Properties props = new Properties();
58-
props.load(is);
59-
final Map<String, String> configMap = props.entrySet().stream()
60-
.collect(Collectors.toMap(
61-
e -> String.valueOf(e.getKey()),
62-
e -> String.valueOf(e.getValue()),
63-
(prev, next) -> next,
64-
HashMap::new));
65-
System.getProperties().forEach((k, v) -> {
66-
final String key = String.valueOf(k);
67-
if (key.startsWith("felix") || key.startsWith("org.osgi")) {
68-
configMap.put(key, String.valueOf(v));
69-
}
70-
});
71-
framework = factory.newFramework(configMap);
72-
framework.init();
73-
framework.start();
74-
}
53+
final Map<String, String> configMap = new HashMap<>();
54+
// Cleans framework before first init. Subsequent init invocations do not clean framework.
55+
configMap.put("org.osgi.framework.storage.clean", "onFirstInit");
56+
configMap.put("felix.log.level", "4");
57+
configMap.put("eclipse.log.level", "ALL");
58+
// Hack to get the build working on Windows. Could try newer versions of Felix.
59+
configMap.put("felix.cache.locking", "false");
60+
// Delegates loading of endorsed libraries to JVM classloader
61+
// config.put("org.osgi.framework.bootdelegation", "javax.*,org.w3c.*,org.xml.*");
62+
framework = factory.newFramework(configMap);
63+
framework.init();
64+
framework.start();
7565
}
7666

7767
public Framework getFramework() {

log4j-osgi-test/src/test/resources/osgi.properties

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)