|
16 | 16 | */
|
17 | 17 | package org.apache.logging.log4j.osgi.tests.junit;
|
18 | 18 |
|
19 |
| -import java.io.InputStream; |
20 | 19 | import java.util.HashMap;
|
21 | 20 | import java.util.Map;
|
22 |
| -import java.util.Properties; |
23 |
| -import java.util.stream.Collectors; |
24 | 21 | import org.junit.rules.ExternalResource;
|
25 | 22 | import org.osgi.framework.BundleException;
|
26 | 23 | import org.osgi.framework.launch.Framework;
|
@@ -53,25 +50,18 @@ protected void after() {
|
53 | 50 |
|
54 | 51 | @Override
|
55 | 52 | 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(); |
75 | 65 | }
|
76 | 66 |
|
77 | 67 | public Framework getFramework() {
|
|
0 commit comments