From c29c371b670a5f764ac3adc261bdb84730062d2d Mon Sep 17 00:00:00 2001 From: rishabhdaim Date: Wed, 28 Oct 2026 19:27:34 +0530 Subject: [PATCH] OAK-12022 : fix composite tests with pax exam 4.14.0 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- oak-store-composite/pom.xml | 11 ++-- .../composite/it/CompositeTestSupport.java | 58 +++++++++++++++---- 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/oak-store-composite/pom.xml b/oak-store-composite/pom.xml index 839e6c7f60e..c921b1517aa 100644 --- a/oak-store-composite/pom.xml +++ b/oak-store-composite/pom.xml @@ -31,11 +31,6 @@ Oak Composite Store bundle - - - 4.13.1 - - @@ -227,6 +222,12 @@ org.apache.sling.testing.paxexam test + + org.ops4j.pax.tinybundles + tinybundles + 4.0.1 + test + org.ops4j.pax.exam pax-exam-junit4 diff --git a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/CompositeTestSupport.java b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/CompositeTestSupport.java index 6727a89758c..ca58f3c62d6 100644 --- a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/CompositeTestSupport.java +++ b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/it/CompositeTestSupport.java @@ -21,9 +21,10 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.UUID; import org.apache.sling.testing.paxexam.SlingOptions; -import org.apache.sling.testing.paxexam.TestSupport; +import org.ops4j.pax.exam.CoreOptions; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.options.ModifiableCompositeOption; @@ -42,13 +43,12 @@ * WARNING: when running the integration tests in an IDE, make sure to generate the oak-store-composite JAR first, otherwise your latest * code changes will be ignored. Just run `mvn package` to generate the JAR. */ -public abstract class CompositeTestSupport extends TestSupport { +public abstract class CompositeTestSupport { private static final String JACKRABBIT_GROUP_ID = "org.apache.jackrabbit"; protected abstract Path getConfigDir(); - @Override protected ModifiableCompositeOption baseConfiguration() { String bundlePath = System.getProperty("bundle.filename"); if (bundlePath == null) { @@ -57,13 +57,23 @@ protected ModifiableCompositeOption baseConfiguration() { if (!Files.exists(Paths.get(bundlePath))) { throw new IllegalArgumentException("The bundle jar to be tested needs to be built first with 'mvn package'"); } + String localRepository = System.getProperty("maven.repo.local", ""); return composite( - super.baseConfiguration(), + systemProperty("pax.exam.osgi.unresolved.fail").value("true"), + CoreOptions.keepCaches(), + CoreOptions.when(!localRepository.isBlank()).useOptions( + systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepository)), + CoreOptions.repository("https://repository.apache.org/snapshots/").id("apache-snapshots").allowSnapshots(), + CoreOptions.workingDirectory(Paths.get("target", "paxexam", getClass().getSimpleName(), + UUID.randomUUID().toString()).toAbsolutePath().toString()), + SlingOptions.backing(), + spiflyOptions(), + jpmsOptions(), logging("INFO"), junitBundles(), felixFileInstall(), oak(), - testBundle("bundle.filename"), + CoreOptions.bundle(Paths.get(bundlePath).toUri().toString()), frameworkProperty("repository.home").value("target") ); } @@ -107,17 +117,45 @@ public static Option jackrabbit() { protected static Option logging(String level) { return composite( mavenBundle("org.ops4j.pax.logging", "pax-logging-api", "1.11.13"), - SlingOptions.spyfly(), - mavenBundle("org.slf4j", "slf4j-api", "2.0.12"), - mavenBundle("org.slf4j", "slf4j-simple", "2.0.12"), + mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").versionAsInProject(), + mavenBundle().groupId("ch.qos.logback").artifactId("logback-core").versionAsInProject(), + mavenBundle().groupId("ch.qos.logback").artifactId("logback-classic").versionAsInProject(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(level), - SlingOptions.logback() + systemProperty("logback.configurationFile").value( + Paths.get("src", "test", "resources", "logback.xml").toUri().toString()) + ); + } + + protected static Option spiflyOptions() { + return composite( + mavenBundle("org.apache.aries", "org.apache.aries.util", "1.1.3"), + mavenBundle("org.ow2.asm", "asm", "9.7.1"), + mavenBundle("org.ow2.asm", "asm-tree", "9.7.1"), + mavenBundle("org.ow2.asm", "asm-analysis", "9.7.1"), + mavenBundle("org.ow2.asm", "asm-commons", "9.7.1"), + mavenBundle("org.ow2.asm", "asm-util", "9.7.1"), + mavenBundle("org.apache.aries.spifly", "org.apache.aries.spifly.dynamic.bundle", "1.3.7") + ); + } + + protected static Option jpmsOptions() { + return composite( + vmOption("--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED"), + vmOption("--add-opens=java.base/java.lang=ALL-UNNAMED"), + vmOption("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED"), + vmOption("--add-opens=java.base/java.io=ALL-UNNAMED"), + vmOption("--add-opens=java.base/java.net=ALL-UNNAMED"), + vmOption("--add-opens=java.base/java.nio=ALL-UNNAMED"), + vmOption("--add-opens=java.base/java.util=ALL-UNNAMED"), + vmOption("--add-opens=java.base/java.util.jar=ALL-UNNAMED"), + vmOption("--add-opens=java.base/java.util.regex=ALL-UNNAMED"), + vmOption("--add-opens=java.base/java.util.zip=ALL-UNNAMED"), + vmOption("--add-opens=java.base/sun.nio.ch=ALL-UNNAMED") ); } protected Option felixFileInstall() { return composite( - mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.9.22"), mavenBundle("org.apache.felix", "org.apache.felix.fileinstall", "3.7.4"), systemProperty("felix.fileinstall.dir").value(getConfigDir().toAbsolutePath().toString()), systemProperty("felix.fileinstall.enableConfigSave").value("false"),