diff --git a/log4j-transform-maven-shade-plugin-extensions/pom.xml b/log4j-transform-maven-shade-plugin-extensions/pom.xml index 3402d1e5..82d04043 100644 --- a/log4j-transform-maven-shade-plugin-extensions/pom.xml +++ b/log4j-transform-maven-shade-plugin-extensions/pom.xml @@ -62,6 +62,12 @@ test + + org.junit.jupiter + junit-jupiter-params + test + + org.osgi osgi.annotation diff --git a/log4j-transform-maven-shade-plugin-extensions/src/test/java/org/apache/logging/log4j/maven/plugins/shade/transformer/Log4j2PluginCacheFileTransformerTest.java b/log4j-transform-maven-shade-plugin-extensions/src/test/java/org/apache/logging/log4j/maven/plugins/shade/transformer/Log4j2PluginCacheFileTransformerTest.java index f27ab3fa..b7d30bd8 100644 --- a/log4j-transform-maven-shade-plugin-extensions/src/test/java/org/apache/logging/log4j/maven/plugins/shade/transformer/Log4j2PluginCacheFileTransformerTest.java +++ b/log4j-transform-maven-shade-plugin-extensions/src/test/java/org/apache/logging/log4j/maven/plugins/shade/transformer/Log4j2PluginCacheFileTransformerTest.java @@ -34,6 +34,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; +import java.util.stream.Stream; import org.apache.commons.io.IOUtils; import org.apache.logging.log4j.core.config.plugins.processor.PluginCache; import org.apache.logging.log4j.core.config.plugins.processor.PluginEntry; @@ -42,6 +43,9 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; final class Log4j2PluginCacheFileTransformerTest { @@ -110,16 +114,9 @@ private void assertTransformedCacheFile( } } - @Test - public void testRelocation() throws IOException { - // test with matching relocator - testRelocation("org.apache.logging", "new.location.org.apache.logging", "new.location.org.apache.logging"); - - // test without matching relocator - testRelocation("com.apache.logging", "new.location.com.apache.logging", "org.apache.logging"); - } - - private void testRelocation(final String src, final String pattern, final String target) throws IOException { + @ParameterizedTest + @MethodSource("relocationParameters") + public void testRelocation(final String src, final String pattern, final String target) throws IOException { final Log4j2PluginCacheFileTransformer transformer = new Log4j2PluginCacheFileTransformer(); final Relocator log4jRelocator = new SimpleRelocator(src, pattern, null, null); final PluginCache aggregator = new PluginCache(); @@ -135,6 +132,15 @@ private void testRelocation(final String src, final String pattern, final String } } + private static Stream relocationParameters() { + return Stream.of( + // test with matching relocator + Arguments.of( + "org.apache.logging", "new.location.org.apache.logging", "new.location.org.apache.logging"), + // test without matching relocator + Arguments.of("com.apache.logging", "new.location.com.apache.logging", "org.apache.logging")); + } + @AfterAll public static void tearDown() { pluginUrl = null;