diff --git a/oak-it-osgi/pom.xml b/oak-it-osgi/pom.xml index 3442403af2c..65a54b37719 100644 --- a/oak-it-osgi/pom.xml +++ b/oak-it-osgi/pom.xml @@ -314,6 +314,12 @@ pax-url-wrap test + + org.apache.sling + org.apache.sling.testing.paxexam + 4.1.2 + test + io.dropwizard.metrics metrics-core diff --git a/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/IndexVersionSelectionIT.java b/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/IndexVersionSelectionIT.java index 2d18d769f36..7ce0a8c5162 100644 --- a/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/IndexVersionSelectionIT.java +++ b/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/IndexVersionSelectionIT.java @@ -299,7 +299,10 @@ public Option[] configuration() throws IOException, URISyntaxException { // mavenBundle().groupId("com.fasterxml.jackson.core").artifactId("jackson-databind").version("2.22.0"), mavenBundle().groupId("com.github.ben-manes.caffeine").artifactId("caffeine").version("3.1.8"), + mavenBundle("jakarta.servlet", "jakarta.servlet-api", "5.0.0"), + // required for slf4j 2.0.x + OSGiIT.spyflyOptions(), frameworkProperty("repository.home").value("target"), systemProperties(new SystemPropertyOption("felix.fileinstall.dir").value(getConfigDir())), diff --git a/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java b/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java index bdd6327ac7d..64c9e808ff9 100644 --- a/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java +++ b/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java @@ -18,6 +18,7 @@ import static org.junit.Assert.assertEquals; import static org.ops4j.pax.exam.CoreOptions.bundle; +import static org.ops4j.pax.exam.CoreOptions.composite; import static org.ops4j.pax.exam.CoreOptions.frameworkProperty; import static org.ops4j.pax.exam.CoreOptions.junitBundles; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; @@ -72,6 +73,7 @@ public Option[] configuration() throws IOException, URISyntaxException { mavenBundle( "org.apache.felix", "org.apache.felix.fileinstall", "3.2.6" ), mavenBundle( "org.ops4j.pax.logging", "pax-logging-api", "1.7.2" ), + // Jackson dependency for object serialisation. // (these only need to be defined here when the versions are different from the ones // defined in the project -- otherwise -> "bundle symbolic name and version are not unique") @@ -80,14 +82,34 @@ public Option[] configuration() throws IOException, URISyntaxException { // mavenBundle().groupId("com.fasterxml.jackson.core").artifactId("jackson-databind").version("2.22.0"), mavenBundle().groupId("com.github.ben-manes.caffeine").artifactId("caffeine").version("3.1.8"), + mavenBundle("jakarta.servlet", "jakarta.servlet-api", "5.0.0"), + // required for slf4j 2.0.x + spyflyOptions(), frameworkProperty("repository.home").value("target"), systemProperties(new SystemPropertyOption("felix.fileinstall.dir").value(getConfigDir())), jarBundles(), jpmsOptions()); } - private Option jpmsOptions(){ + /** + * Provides Apache Aries SPI Fly 1.3.x for SLF4J 2.x service-loader mediation in OSGi. + * SPI Fly 1.2.x (bundled by sling.testing.paxexam 3.1.0) embeds ASM 5.x and cannot + * weave Java 11+ bytecode. Version 1.3.7 uses external ASM 9.x and supports modern class files. + */ + static Option spyflyOptions() { + 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") + ); + } + + static Option jpmsOptions(){ DefaultCompositeOption composite = new DefaultCompositeOption(); if (Version.parseVersion(System.getProperty("java.specification.version")).getMajor() > 1){ if (java.nio.file.Files.exists(java.nio.file.FileSystems.getFileSystem(URI.create("jrt:/")).getPath("modules", "java.se.ee"))){ @@ -108,11 +130,11 @@ private Option jpmsOptions(){ return composite; } - private String getConfigDir(){ + static String getConfigDir(){ return new File(new File("src", "test"), "config").getAbsolutePath(); } - private Option jarBundles() throws MalformedURLException { + static Option jarBundles() throws MalformedURLException { DefaultCompositeOption composite = new DefaultCompositeOption(); for (File bundle : new File("target", "test-bundles").listFiles()) { if (bundle.getName().endsWith(".jar") && bundle.isFile()) { diff --git a/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/TikaExtractionOsgiIT.java b/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/TikaExtractionOsgiIT.java index 9233a6f3baa..e633f6bf07d 100644 --- a/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/TikaExtractionOsgiIT.java +++ b/oak-it-osgi/src/test/java/org/apache/jackrabbit/oak/osgi/TikaExtractionOsgiIT.java @@ -20,37 +20,53 @@ import org.apache.tika.parser.AutoDetectParser; import org.apache.tika.parser.Parser; import org.apache.tika.sax.WriteOutContentHandler; + import org.junit.Test; import org.junit.runner.RunWith; + import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.CoreOptions; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.PaxExam; import org.ops4j.pax.exam.options.DefaultCompositeOption; +import org.ops4j.pax.exam.options.SystemPropertyOption; import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerClass; + import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; -import org.osgi.framework.Version; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.xml.sax.ContentHandler; -import javax.inject.Inject; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; -import java.net.URI; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.stream.Collectors; +import javax.inject.Inject; + import static java.util.Arrays.stream; -import static org.junit.Assert.*; -import static org.ops4j.pax.exam.CoreOptions.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + +import static org.ops4j.pax.exam.CoreOptions.bundle; +import static org.ops4j.pax.exam.CoreOptions.composite; +import static org.ops4j.pax.exam.CoreOptions.frameworkProperty; +import static org.ops4j.pax.exam.CoreOptions.junitBundles; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; +import static org.ops4j.pax.exam.CoreOptions.systemProperties; +import static org.ops4j.pax.exam.CoreOptions.wrappedBundle; + +import static org.apache.jackrabbit.oak.osgi.OSGiIT.getConfigDir; @RunWith(PaxExam.class) @ExamReactorStrategy(PerClass.class) @@ -60,14 +76,10 @@ public class TikaExtractionOsgiIT { private static final String VERSION_PROP_RESOURCE_NAME = "versions.properties"; private static final String TIKA_VERSION = "tika"; private static final String POI_VERSION = "poi"; - private static final String COLLECTIONS4_VERSION = "commons-collections4"; private static final String COMPRESS_VERSION = "commons-compress"; - private static final String LANG3_VERSION = "commons-lang3"; - private static final String MATH3_VERSION = "commons-math3"; private static final String COMMONS_CSV_VERSION = "commons-csv"; - private static final String[] VERSION_KEYS = new String[]{TIKA_VERSION, POI_VERSION - , COLLECTIONS4_VERSION, COMPRESS_VERSION - , LANG3_VERSION, MATH3_VERSION, COMMONS_CSV_VERSION}; + private static final String[] VERSION_KEYS = new String[]{TIKA_VERSION, POI_VERSION, COMPRESS_VERSION, + COMMONS_CSV_VERSION}; private static final String EXPECTED_TEXT_FRAGMENT = "A sample document"; private static final String EXPECTED_CSV_FRAGMENT = @@ -80,43 +92,37 @@ public class TikaExtractionOsgiIT { public Option[] configuration() throws IOException { return CoreOptions.options( junitBundles(), - mavenBundle( "org.ops4j.pax.logging", "pax-logging-api", "2.2.3" ), - frameworkProperty("repository.home").value("target"), + mavenBundle("org.apache.felix", "org.apache.felix.scr", "2.1.28"), + // transitive deps of Felix SCR 2.1.x + mavenBundle("org.osgi", "org.osgi.util.promise", "1.1.1"), + mavenBundle("org.osgi", "org.osgi.util.function", "1.1.0"), + mavenBundle("org.apache.felix", "org.apache.felix.jaas", "1.0.2"), + mavenBundle("org.osgi", "org.osgi.dto", "1.0.0"), + // require at least ConfigAdmin 1.6 supported by felix.configadmin 1.9.0+ + mavenBundle( "org.apache.felix", "org.apache.felix.configadmin", "1.9.20" ), + mavenBundle( "org.apache.felix", "org.apache.felix.fileinstall", "3.2.6" ), + mavenBundle( "org.ops4j.pax.logging", "pax-logging-api", "1.7.2" ), + mavenBundle("org.apache.logging.log4j", "log4j-api", "2.23.0"), + mavenBundle("jakarta.servlet", "jakarta.servlet-api", "5.0.0"), + mavenBundle().groupId("com.github.ben-manes.caffeine").artifactId("caffeine").version("3.1.8"), + + // required for slf4j 2.0.x + OSGiIT.spyflyOptions(), setupTikaAndPoi(), - jpmsOptions() + frameworkProperty("repository.home").value("target"), + systemProperties(new SystemPropertyOption("felix.fileinstall.dir").value(getConfigDir())), + OSGiIT.jpmsOptions() // to debug a test, un-comment this and "run" the test which would block due to suspend="y" // then run debugger on a remote app with specified port // , vmOption( "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005" ) ); } - private Option jpmsOptions(){ - DefaultCompositeOption composite = new DefaultCompositeOption(); - if (Version.parseVersion(System.getProperty("java.specification.version")).getMajor() > 1){ - if (java.nio.file.Files.exists(java.nio.file.FileSystems.getFileSystem(URI.create("jrt:/")).getPath("modules", "java.se.ee"))){ - composite.add(vmOption("--add-modules=java.se.ee")); - } - composite.add(vmOption("--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED")); - composite.add(vmOption("--add-opens=java.base/java.lang=ALL-UNNAMED")); - composite.add(vmOption("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")); - composite.add(vmOption("--add-opens=java.base/java.io=ALL-UNNAMED")); - composite.add(vmOption("--add-opens=java.base/java.net=ALL-UNNAMED")); - composite.add(vmOption("--add-opens=java.base/java.nio=ALL-UNNAMED")); - composite.add(vmOption("--add-opens=java.base/java.util=ALL-UNNAMED")); - composite.add(vmOption("--add-opens=java.base/java.util.jar=ALL-UNNAMED")); - composite.add(vmOption("--add-opens=java.base/java.util.regex=ALL-UNNAMED")); - composite.add(vmOption("--add-opens=java.base/java.util.zip=ALL-UNNAMED")); - composite.add(vmOption("--add-opens=java.base/sun.nio.ch=ALL-UNNAMED")); - } - return composite; - } - - private Option setupTikaAndPoi() throws IOException { + private static Option setupTikaAndPoi() throws IOException { Map versions = setupVersions(); return composite( composite( - mavenBundle("org.apache.tika", "tika-core", versions.get(TIKA_VERSION)) - , mavenBundle("org.apache.tika", "tika-parsers", versions.get(TIKA_VERSION)) + mavenBundle("org.apache.tika", "tika-parsers", versions.get(TIKA_VERSION)) // for csv parsing , mavenBundle("org.apache.commons", "commons-csv", versions.get(COMMONS_CSV_VERSION)) // poi dependency start @@ -128,30 +134,13 @@ private Option setupTikaAndPoi() throws IOException { , wrappedBundle(mavenBundle("org.apache.poi", "ooxml-security", "1.0")) , wrappedBundle(mavenBundle("org.apache.xmlbeans", "xmlbeans", "5.0.3")) , wrappedBundle(mavenBundle("com.drewnoakes", "metadata-extractor", "2.6.2")) - , mavenBundle("org.apache.commons", "commons-collections4", versions.get(COLLECTIONS4_VERSION)) , mavenBundle("org.apache.commons", "commons-compress", versions.get(COMPRESS_VERSION)) - , mavenBundle("org.apache.commons", "commons-lang3", versions.get(LANG3_VERSION)) - , mavenBundle("org.apache.commons", "commons-math3", versions.get(MATH3_VERSION)) // poi dependency end ) - , jarBundles() + , OSGiIT.jarBundles() ); } - private Option jarBundles() throws MalformedURLException { - String[] jarNames = new String[]{"commons-io.jar", "commons-codec.jar"}; - File jarDir = new File("target", "test-bundles"); - - DefaultCompositeOption composite = new DefaultCompositeOption(); - - List jarFiles = stream(jarNames).map(jarName -> new File(jarDir, jarName)).collect(Collectors.toList()); - for (File jar : jarFiles) { - composite.add(bundle(jar.toURI().toURL().toString())); - } - - return composite; - } - private static Map setupVersions() throws IOException { Properties props = new Properties(); props.load(TikaExtractionOsgiIT.class.getClassLoader().getResourceAsStream(VERSION_PROP_RESOURCE_NAME)); diff --git a/oak-it-osgi/src/test/resources/versions.properties b/oak-it-osgi/src/test/resources/versions.properties index f9f61fba5a9..02763da5c3c 100644 --- a/oak-it-osgi/src/test/resources/versions.properties +++ b/oak-it-osgi/src/test/resources/versions.properties @@ -16,8 +16,5 @@ # tika=${tika.version} poi=5.2.2 -commons-collections4=4.4 commons-compress=1.28.0 -commons-lang3=3.18.0 -commons-math3=3.6.1 commons-csv=1.14.1 diff --git a/oak-it-osgi/test-bundles.xml b/oak-it-osgi/test-bundles.xml index 14e87fd7d3d..68bc786a042 100644 --- a/oak-it-osgi/test-bundles.xml +++ b/oak-it-osgi/test-bundles.xml @@ -39,6 +39,7 @@ com.fasterxml.jackson.core:jackson-annotations com.fasterxml.jackson.core:jackson-core com.fasterxml.jackson.core:jackson-databind + com.fasterxml.jackson.core:jackson-annotations org.apache.commons:commons-lang3 org.apache.commons:commons-math3 org.apache.commons:commons-text diff --git a/oak-parent/pom.xml b/oak-parent/pom.xml index ac47e40af5f..237ac7736c8 100644 --- a/oak-parent/pom.xml +++ b/oak-parent/pom.xml @@ -59,9 +59,9 @@ SegmentMK 4.7.2 5.3.1 - 1.7.36 - 1.7.36 - 1.2.13 + 2.0.18 + 2.0.18 + 1.6.3 2.1.214 1.28.5 10.16.1.1 diff --git a/oak-run-elastic/pom.xml b/oak-run-elastic/pom.xml index aba7148146c..2ea30795c0b 100644 --- a/oak-run-elastic/pom.xml +++ b/oak-run-elastic/pom.xml @@ -47,7 +47,6 @@ 142 MB: jackson update (OAK-12276) --> 142000000 - 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 a8aa9badc29..6727a89758c 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 @@ -107,6 +107,9 @@ 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"), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(level), SlingOptions.logback() );