Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions log4j-transform-maven-shade-plugin-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.annotation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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();
Expand All @@ -135,6 +132,15 @@ private void testRelocation(final String src, final String pattern, final String
}
}

private static Stream<Arguments> 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;
Expand Down
Loading