This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new fa84103c23 Add per-test property source
fa84103c23 is described below
commit fa84103c230f9f1801bf1e9a7a11f5c7de26b291
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Thu Oct 27 22:33:51 2022 +0200
Add per-test property source
The `@SetTestProperty` annotation allows to set a single property into
the Log4j2 environment properties.
The `@UsingTestProperties` annotation injects a `TestProperties`
instance into fields and method parameters. This can be used to set
multiple Log4j2 environment properties in code.
---
.../apache/logging/log4j/test/TestProperties.java | 40 ++++++
.../logging/log4j/test/junit/SetTestProperty.java | 63 +++++++++
.../log4j/test/junit/TestPropertyResolver.java | 94 ++++++++++++++
.../log4j/test/junit/TestPropertySource.java | 141 +++++++++++++++++++++
.../test/junit/TypeBasedParameterResolver.java | 30 +++--
.../log4j/test/junit/UsingTestProperties.java | 46 +++++++
.../org.apache.logging.log4j.util.PropertySource | 15 +++
.../log4j/test/junit/TestPropertySourceTest.java | 56 ++++++++
.../core/test/junit/ConfigurationResolver.java | 7 +-
.../core/test/junit/LoggerContextResolver.java | 13 +-
10 files changed, 487 insertions(+), 18 deletions(-)
diff --git
a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestProperties.java
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestProperties.java
new file mode 100644
index 0000000000..0c66fc8b94
--- /dev/null
+++
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestProperties.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+package org.apache.logging.log4j.test;
+
+/**
+ * A container for per-test properties.
+ */
+public interface TestProperties {
+
+ String getProperty(final String key);
+
+ boolean containsProperty(final String key);
+
+ void setProperty(final String key, final String value);
+
+ default void setProperty(final String key, final boolean value) {
+ setProperty(key, value ? "true" : "false");
+ }
+
+ default void setProperty(final String key, final int value) {
+ setProperty(key, Integer.toString(value));
+ }
+
+ void clearProperty(final String key);
+}
diff --git
a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SetTestProperty.java
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SetTestProperty.java
new file mode 100644
index 0000000000..2d85d168a3
--- /dev/null
+++
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SetTestProperty.java
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+package org.apache.logging.log4j.test.junit;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Repeatable;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junitpioneer.jupiter.ReadsEnvironmentVariable;
+import org.junitpioneer.jupiter.ReadsSystemProperty;
+
+/**
+ * Registers a Log4j2 system property with the {@link TestPropertySource}. The
+ * property will also be available in configuration files using the
+ * {@code ${test:...} lookup.
+ *
+ */
+@Retention(RUNTIME)
+@Target({ TYPE, METHOD })
+@Inherited
+@Documented
+@ExtendWith(ExtensionContextAnchor.class)
+@ExtendWith(TestPropertyResolver.class)
+@Repeatable(SetTestProperty.SetTestProperties.class)
+@ReadsSystemProperty
+@ReadsEnvironmentVariable
+public @interface SetTestProperty {
+
+ String key();
+
+ String value();
+
+ @Retention(RUNTIME)
+ @Target({ TYPE, METHOD })
+ @Documented
+ @Inherited
+ public @interface SetTestProperties {
+
+ SetTestProperty[] value();
+ }
+}
diff --git
a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertyResolver.java
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertyResolver.java
new file mode 100644
index 0000000000..53d27b1659
--- /dev/null
+++
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertyResolver.java
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+package org.apache.logging.log4j.test.junit;
+
+import org.apache.logging.log4j.test.TestProperties;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.platform.commons.support.HierarchyTraversalMode;
+import org.junit.platform.commons.support.ModifierSupport;
+import org.junit.platform.commons.support.ReflectionSupport;
+
+public class TestPropertyResolver extends
TypeBasedParameterResolver<TestProperties>
+ implements BeforeAllCallback, BeforeEachCallback {
+
+ public TestPropertyResolver() {
+ super(TestProperties.class);
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext context) throws Exception {
+ final TestProperties props =
TestPropertySource.createProperties(context);
+ final SetTestProperty[] setProperties = context.getRequiredTestMethod()
+ .getAnnotationsByType(SetTestProperty.class);
+ if (setProperties.length > 0) {
+ for (final SetTestProperty setProperty : setProperties) {
+ props.setProperty(setProperty.key(), setProperty.value());
+ }
+ }
+ final Class<?> testClass = context.getRequiredTestClass();
+ Object testInstance = context.getRequiredTestInstance();
+ ReflectionSupport
+ .findFields(testClass,
+ field -> ModifierSupport.isNotStatic(field)
+ &&
field.getType().isAssignableFrom(TestProperties.class),
+ HierarchyTraversalMode.BOTTOM_UP)
+ .forEach(field -> {
+ try {
+ field.setAccessible(true);
+ field.set(testInstance, props);
+ } catch (IllegalAccessException e) {
+ throw new UnsupportedOperationException(e);
+ }
+ });
+ }
+
+ @Override
+ public void beforeAll(ExtensionContext context) throws Exception {
+ final TestProperties props =
TestPropertySource.createProperties(context);
+ final SetTestProperty[] setProperties = context.getRequiredTestClass()
+ .getAnnotationsByType(SetTestProperty.class);
+ if (setProperties.length > 0) {
+ for (final SetTestProperty setProperty : setProperties) {
+ props.setProperty(setProperty.key(), setProperty.value());
+ }
+ }
+ final Class<?> testClass = context.getRequiredTestClass();
+ ReflectionSupport
+ .findFields(testClass,
+ field -> ModifierSupport.isStatic(field)
+ &&
field.getType().isAssignableFrom(TestProperties.class),
+ HierarchyTraversalMode.BOTTOM_UP)
+ .forEach(field -> {
+ try {
+ field.setAccessible(true);
+ field.set(null, props);
+ } catch (IllegalAccessException e) {
+ throw new UnsupportedOperationException(e);
+ }
+ });
+ }
+
+ @Override
+ public TestProperties resolveParameter(ParameterContext parameterContext,
ExtensionContext extensionContext)
+ throws ParameterResolutionException {
+ return TestPropertySource.createProperties(extensionContext);
+ }
+}
diff --git
a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertySource.java
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertySource.java
new file mode 100644
index 0000000000..d8190fdf4f
--- /dev/null
+++
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertySource.java
@@ -0,0 +1,141 @@
+/*
+ * 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.
+ */
+
+package org.apache.logging.log4j.test.junit;
+
+import org.apache.logging.log4j.test.TestProperties;
+import org.apache.logging.log4j.util.PropertySource;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
+import org.junit.jupiter.api.extension.ExtensionContext.Store;
+
+public class TestPropertySource implements PropertySource {
+
+ private static final String PREFIX = "log4j2.";
+ private static final Namespace NAMESPACE =
ExtensionContextAnchor.LOG4J2_NAMESPACE.append("properties");
+ private static final TestProperties EMPTY_PROPERTIES = new
EmptyTestProperties();
+
+ @Override
+ public int getPriority() {
+ // Highest priority
+ return Integer.MIN_VALUE;
+ }
+
+ public static TestProperties createProperties(ExtensionContext context) {
+ TestProperties props = getProperties(context);
+ // Make sure that the properties do not come from the parent
ExtensionContext
+ if (props instanceof JUnitTestProperties &&
context.equals(((JUnitTestProperties) props).getContext())) {
+ return props;
+ }
+ props = new JUnitTestProperties(context);
+ ExtensionContextAnchor.setAttribute(TestProperties.class, props,
context);
+ return props;
+ }
+
+ public static TestProperties getProperties() {
+ return getProperties(null);
+ }
+
+ private static TestProperties getProperties(ExtensionContext context) {
+ final ExtensionContext actualContext = context != null ? context :
ExtensionContextAnchor.getContext();
+ if (actualContext != null) {
+ TestProperties props =
ExtensionContextAnchor.getAttribute(TestProperties.class, TestProperties.class,
+ actualContext);
+ if (props != null) {
+ return props;
+ }
+ }
+ return EMPTY_PROPERTIES;
+ }
+
+ @Override
+ public CharSequence getNormalForm(Iterable<? extends CharSequence> tokens)
{
+ final CharSequence camelCase = Util.joinAsCamelCase(tokens);
+ // Do not use Strings to prevent recursive initialization
+ return camelCase.length() > 0 ? PREFIX + camelCase.toString() : null;
+ }
+
+ @Override
+ public String getProperty(String key) {
+ return getProperties().getProperty(key);
+ }
+
+ @Override
+ public boolean containsProperty(String key) {
+ return getProperties().containsProperty(key);
+ }
+
+ private static class JUnitTestProperties implements TestProperties {
+
+ private final ExtensionContext context;
+ private final Store store;
+
+ public JUnitTestProperties(ExtensionContext context) {
+ this.context = context;
+ this.store = context.getStore(NAMESPACE);
+ }
+
+ public ExtensionContext getContext() {
+ return context;
+ }
+
+ @Override
+ public String getProperty(String key) {
+ return store.get(key, String.class);
+ }
+
+ @Override
+ public boolean containsProperty(String key) {
+ return getProperty(key) != null;
+ }
+
+ @Override
+ public void setProperty(String key, String value) {
+ store.put(key, value);
+ }
+
+ @Override
+ public void clearProperty(String key) {
+ store.remove(key, String.class);
+ }
+
+ }
+
+ private static class EmptyTestProperties implements TestProperties {
+
+ @Override
+ public String getProperty(String key) {
+ return null;
+ }
+
+ @Override
+ public boolean containsProperty(String key) {
+ return false;
+ }
+
+ @Override
+ public void setProperty(String key, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clearProperty(String key) {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+}
diff --git
a/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/ConfigurationResolver.java
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TypeBasedParameterResolver.java
similarity index 53%
copy from
log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/ConfigurationResolver.java
copy to
log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TypeBasedParameterResolver.java
index c637b037d1..8cf338493b 100644
---
a/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/ConfigurationResolver.java
+++
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TypeBasedParameterResolver.java
@@ -14,26 +14,30 @@
* See the license for the specific language governing permissions and
* limitations under the license.
*/
+package org.apache.logging.log4j.test.junit;
-package org.apache.logging.log4j.core.test.junit;
+import java.lang.reflect.Type;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver;
+import org.junit.jupiter.api.extension.ParameterResolver;
-import static
org.apache.logging.log4j.core.test.junit.LoggerContextResolver.getParameterLoggerContext;
+public abstract class TypeBasedParameterResolver<T> implements
ParameterResolver {
+
+ private final Type supportedParameterType;
+
+ public TypeBasedParameterResolver(Type supportedParameterType) {
+ this.supportedParameterType = supportedParameterType;
+ }
-class ConfigurationResolver extends TypeBasedParameterResolver<Configuration> {
@Override
- public Configuration resolveParameter(
- ParameterContext parameterContext, ExtensionContext
extensionContext) throws ParameterResolutionException {
- final LoggerContext loggerContext =
getParameterLoggerContext(parameterContext, extensionContext);
- if (loggerContext == null) {
- throw new ParameterResolutionException("No LoggerContext defined");
- }
- return loggerContext.getConfiguration();
+ public boolean supportsParameter(ParameterContext parameterContext,
ExtensionContext extensionContext)
+ throws ParameterResolutionException {
+ return
this.supportedParameterType.equals(parameterContext.getParameter().getParameterizedType());
}
+
+ @Override
+ public abstract T resolveParameter(ParameterContext parameterContext,
ExtensionContext extensionContext)
+ throws ParameterResolutionException;
}
diff --git
a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingTestProperties.java
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingTestProperties.java
new file mode 100644
index 0000000000..cc696522ab
--- /dev/null
+++
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingTestProperties.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+package org.apache.logging.log4j.test.junit;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.logging.log4j.test.TestProperties;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junitpioneer.jupiter.ReadsEnvironmentVariable;
+import org.junitpioneer.jupiter.ReadsSystemProperty;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * A field or method parameter of type {@link TestProperties} will be injected
with a per-test source of Log4j2's
+ * system properties.
+ */
+@Retention(RUNTIME)
+@Target({ TYPE, METHOD })
+@Inherited
+@Documented
+@ExtendWith(ExtensionContextAnchor.class)
+@ExtendWith(TestPropertyResolver.class)
+@ReadsSystemProperty
+@ReadsEnvironmentVariable
+public @interface UsingTestProperties {
+}
diff --git
a/log4j-api-test/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource
b/log4j-api-test/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource
new file mode 100644
index 0000000000..2c7cb498d9
--- /dev/null
+++
b/log4j-api-test/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource
@@ -0,0 +1,15 @@
+# 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.apache.logging.log4j.test.junit.TestPropertySource
diff --git
a/log4j-api-test/src/test/java/org/apache/logging/log4j/test/junit/TestPropertySourceTest.java
b/log4j-api-test/src/test/java/org/apache/logging/log4j/test/junit/TestPropertySourceTest.java
new file mode 100644
index 0000000000..b068bdb589
--- /dev/null
+++
b/log4j-api-test/src/test/java/org/apache/logging/log4j/test/junit/TestPropertySourceTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+package org.apache.logging.log4j.test.junit;
+
+import org.apache.logging.log4j.test.TestProperties;
+import org.apache.logging.log4j.util.PropertiesUtil;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@UsingTestProperties
+public class TestPropertySourceTest {
+
+ private static TestProperties staticProperties;
+ private TestProperties instanceProperties;
+
+ @Test
+ public void testInjectedFields() {
+ assertThat(staticProperties).isNotNull();
+ assertThat(instanceProperties).isNotNull();
+
+ // Test that per-class properties are overridden by per-test properties
+ final PropertiesUtil env = PropertiesUtil.getProperties();
+ staticProperties.setProperty("log4j2.staticProperty", "static");
+ staticProperties.setProperty("log4j2.instanceProperty", "static");
+ instanceProperties.setProperty("log4j2.instanceProperty", "instance");
+
assertThat(env.getStringProperty("log4j2.staticProperty")).isEqualTo("static");
+
assertThat(env.getStringProperty("log4j.instanceProperty")).isEqualTo("instance");
+ }
+
+ @Test
+ public void testInjectedParameter(final TestProperties paramProperties) {
+ assertThat(paramProperties).isEqualTo(instanceProperties);
+ }
+
+ @Test
+ @SetTestProperty(key = "log4j2.testSetTestProperty", value = "true")
+ public void testSetTestProperty() {
+ final PropertiesUtil env = PropertiesUtil.getProperties();
+
assertThat(env.getBooleanProperty("log4j2.testSetTestProperty")).isTrue();
+ }
+}
diff --git
a/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/ConfigurationResolver.java
b/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/ConfigurationResolver.java
index c637b037d1..ff9be82a46 100644
---
a/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/ConfigurationResolver.java
+++
b/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/ConfigurationResolver.java
@@ -19,14 +19,19 @@ package org.apache.logging.log4j.core.test.junit;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.test.junit.TypeBasedParameterResolver;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver;
import static
org.apache.logging.log4j.core.test.junit.LoggerContextResolver.getParameterLoggerContext;
class ConfigurationResolver extends TypeBasedParameterResolver<Configuration> {
+
+ public ConfigurationResolver() {
+ super(Configuration.class);
+ }
+
@Override
public Configuration resolveParameter(
ParameterContext parameterContext, ExtensionContext
extensionContext) throws ParameterResolutionException {
diff --git
a/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/LoggerContextResolver.java
b/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/LoggerContextResolver.java
index 68259695bc..b63dacc6a1 100644
---
a/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/LoggerContextResolver.java
+++
b/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/LoggerContextResolver.java
@@ -17,6 +17,10 @@
package org.apache.logging.log4j.core.test.junit;
+import java.lang.reflect.Method;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.logging.log4j.test.junit.TypeBasedParameterResolver;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.LoggerContextAccessor;
import org.apache.logging.log4j.core.config.Configurator;
@@ -27,13 +31,14 @@ import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver;
-
-import java.lang.reflect.Method;
-import java.util.concurrent.TimeUnit;
class LoggerContextResolver extends TypeBasedParameterResolver<LoggerContext>
implements BeforeAllCallback,
AfterAllCallback, BeforeEachCallback, AfterEachCallback {
+
+ public LoggerContextResolver() {
+ super(LoggerContext.class);
+ }
+
@Override
public void beforeAll(ExtensionContext context) throws Exception {
final Class<?> testClass = context.getRequiredTestClass();