This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/2.x by this push:
new e25c308945 Port `OsgiRule` changes from `main`
e25c308945 is described below
commit e25c30894523b4dc8c65606d34db3a19415919ec
Author: Volkan Yazıcı <[email protected]>
AuthorDate: Fri Jan 12 10:40:49 2024 +0100
Port `OsgiRule` changes from `main`
---
.../logging/log4j/osgi/tests/junit/OsgiRule.java | 34 ++++++++--------------
log4j-osgi-test/src/test/resources/osgi.properties | 21 -------------
2 files changed, 12 insertions(+), 43 deletions(-)
diff --git
a/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/junit/OsgiRule.java
b/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/junit/OsgiRule.java
index bef1bece8f..b965992fe3 100644
---
a/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/junit/OsgiRule.java
+++
b/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/junit/OsgiRule.java
@@ -16,11 +16,8 @@
*/
package org.apache.logging.log4j.osgi.tests.junit;
-import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
-import java.util.Properties;
-import java.util.stream.Collectors;
import org.junit.rules.ExternalResource;
import org.osgi.framework.BundleException;
import org.osgi.framework.launch.Framework;
@@ -53,25 +50,18 @@ public class OsgiRule extends ExternalResource {
@Override
protected void before() throws Throwable {
- try (final InputStream is =
OsgiRule.class.getResourceAsStream("/osgi.properties")) {
- final Properties props = new Properties();
- props.load(is);
- final Map<String, String> configMap = props.entrySet().stream()
- .collect(Collectors.toMap(
- e -> String.valueOf(e.getKey()),
- e -> String.valueOf(e.getValue()),
- (prev, next) -> next,
- HashMap::new));
- System.getProperties().forEach((k, v) -> {
- final String key = String.valueOf(k);
- if (key.startsWith("felix") || key.startsWith("org.osgi")) {
- configMap.put(key, String.valueOf(v));
- }
- });
- framework = factory.newFramework(configMap);
- framework.init();
- framework.start();
- }
+ final Map<String, String> configMap = new HashMap<>();
+ // Cleans framework before first init. Subsequent init invocations do
not clean framework.
+ configMap.put("org.osgi.framework.storage.clean", "onFirstInit");
+ configMap.put("felix.log.level", "4");
+ configMap.put("eclipse.log.level", "ALL");
+ // Hack to get the build working on Windows. Could try newer versions
of Felix.
+ configMap.put("felix.cache.locking", "false");
+ // Delegates loading of endorsed libraries to JVM classloader
+ // config.put("org.osgi.framework.bootdelegation",
"javax.*,org.w3c.*,org.xml.*");
+ framework = factory.newFramework(configMap);
+ framework.init();
+ framework.start();
}
public Framework getFramework() {
diff --git a/log4j-osgi-test/src/test/resources/osgi.properties
b/log4j-osgi-test/src/test/resources/osgi.properties
deleted file mode 100644
index f5365f6afa..0000000000
--- a/log4j-osgi-test/src/test/resources/osgi.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# 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.
-#
-org.osgi.framework.storage.clean = onFirstInit
-felix.log.level = 4
-eclipse.log.level = ALL
-# Hack to get the build working on Windows. Could try newer versions of Felix.
-felix.cache.locking = false