Fix the OSGi Functional Tests for JDK 11 Signed-off-by: Jan Supol <jan.supol@oracle.com>
diff --git a/examples/osgi-helloworld-webapp/functional-test/pom.xml b/examples/osgi-helloworld-webapp/functional-test/pom.xml index 7bc1a63..96dd8e7 100644 --- a/examples/osgi-helloworld-webapp/functional-test/pom.xml +++ b/examples/osgi-helloworld-webapp/functional-test/pom.xml
@@ -225,24 +225,17 @@ <profiles> <profile> - <id>testsSkipJdk11</id> + <id>testsJdk11</id> <activation> <jdk>[11,)</jdk> </activation> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <!-- Exclude unit tests on jdk 11 for now --> - <excludes> - <exclude>**/WebAppFelixTest.java</exclude> - </excludes> - </configuration> - </plugin> - </plugins> - </build> + <dependencies> + <dependency> + <groupId>com.sun.activation</groupId> + <artifactId>jakarta.activation</artifactId> + <version>${jakarta.activation.version}</version> + </dependency> + </dependencies> </profile> <profile> <id>release</id>
diff --git a/examples/osgi-helloworld-webapp/functional-test/src/test/java/org/glassfish/jersey/examples/helloworld/test/AbstractWebAppTest.java b/examples/osgi-helloworld-webapp/functional-test/src/test/java/org/glassfish/jersey/examples/helloworld/test/AbstractWebAppTest.java index 78ae2e3..fc11f8f 100644 --- a/examples/osgi-helloworld-webapp/functional-test/src/test/java/org/glassfish/jersey/examples/helloworld/test/AbstractWebAppTest.java +++ b/examples/osgi-helloworld-webapp/functional-test/src/test/java/org/glassfish/jersey/examples/helloworld/test/AbstractWebAppTest.java
@@ -35,6 +35,7 @@ import javax.inject.Inject; +import org.glassfish.jersey.internal.util.JdkVersion; import org.glassfish.jersey.internal.util.PropertiesHelper; import org.ops4j.pax.exam.Configuration; @@ -54,6 +55,7 @@ import static org.ops4j.pax.exam.CoreOptions.options; import static org.ops4j.pax.exam.CoreOptions.systemPackage; import static org.ops4j.pax.exam.CoreOptions.systemProperty; +import static org.ops4j.pax.exam.CoreOptions.vmOption; /** * @author Jakub Podlesak @@ -104,6 +106,7 @@ // uncomment for verbose class loading info // vmOption("-verbose:class"), + getAddOpensForFelixFrameWorkSecurity(), // bootDelegationPackage("org.glassfish.jersey.client.*"), @@ -147,6 +150,7 @@ mavenBundle().groupId("jakarta.xml.bind").artifactId("jakarta.xml.bind-api").versionAsInProject(), //SUN JAXB IMPL OSGI mavenBundle().groupId("com.sun.xml.bind").artifactId("jaxb-osgi").versionAsInProject().versionAsInProject(), + getActivationBundle(), systemPackage("com.sun.source.tree"), systemPackage("com.sun.source.util"), @@ -190,6 +194,18 @@ return options; } + private static Option getActivationBundle() { + return JdkVersion.getJdkVersion().getMajor() > 8 + ? mavenBundle().groupId("com.sun.activation").artifactId("jakarta.activation").versionAsInProject() + : null; + } + + private static Option getAddOpensForFelixFrameWorkSecurity() { + return JdkVersion.getJdkVersion().getMajor() > 8 + ? vmOption("--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED") + : null; + } + public List<Option> jettyOptions() { return Arrays.asList(options( mavenBundle().groupId("org.ops4j.pax.web").artifactId("pax-web-jetty-bundle").versionAsInProject(),
diff --git a/examples/osgi-helloworld-webapp/war-bundle/pom.xml b/examples/osgi-helloworld-webapp/war-bundle/pom.xml index c53317a..7e3dbb6 100644 --- a/examples/osgi-helloworld-webapp/war-bundle/pom.xml +++ b/examples/osgi-helloworld-webapp/war-bundle/pom.xml
@@ -66,6 +66,11 @@ <artifactId>org.apache.felix.eventadmin</artifactId> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + <scope>provided</scope> + </dependency> </dependencies> <build>
diff --git a/examples/osgi-http-service/bundle/pom.xml b/examples/osgi-http-service/bundle/pom.xml index 3b41c66..0545b4f 100644 --- a/examples/osgi-http-service/bundle/pom.xml +++ b/examples/osgi-http-service/bundle/pom.xml
@@ -51,6 +51,11 @@ <artifactId>org.apache.felix.eventadmin</artifactId> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + <scope>provided</scope> + </dependency> </dependencies> <build>
diff --git a/examples/osgi-http-service/functional-test/pom.xml b/examples/osgi-http-service/functional-test/pom.xml index 9b6d7db..3e8d10d 100644 --- a/examples/osgi-http-service/functional-test/pom.xml +++ b/examples/osgi-http-service/functional-test/pom.xml
@@ -202,25 +202,17 @@ <profiles> <profile> - <id>testsSkipJdk11</id> + <id>testsJdk11</id> <activation> <jdk>[11,)</jdk> </activation> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <!-- Exclude unit tests on jdk 11 for now --> - <excludes> - <exclude>**/GrizzlyHttpServiceFelixTest.java</exclude> - <exclude>**/JettyHttpServiceFelixTest.java</exclude> - </excludes> - </configuration> - </plugin> - </plugins> - </build> + <dependencies> + <dependency> + <groupId>com.sun.activation</groupId> + <artifactId>jakarta.activation</artifactId> + <version>${jakarta.activation.version}</version> + </dependency> + </dependencies> </profile> <profile> <id>jdk8</id>
diff --git a/examples/osgi-http-service/functional-test/src/test/java/org/glassfish/jersey/examples/osgihttpservice/test/AbstractHttpServiceTest.java b/examples/osgi-http-service/functional-test/src/test/java/org/glassfish/jersey/examples/osgihttpservice/test/AbstractHttpServiceTest.java index 824f6ce..2f3d18e 100644 --- a/examples/osgi-http-service/functional-test/src/test/java/org/glassfish/jersey/examples/osgihttpservice/test/AbstractHttpServiceTest.java +++ b/examples/osgi-http-service/functional-test/src/test/java/org/glassfish/jersey/examples/osgihttpservice/test/AbstractHttpServiceTest.java
@@ -30,6 +30,7 @@ import javax.inject.Inject; +import org.glassfish.jersey.internal.util.JdkVersion; import org.glassfish.jersey.internal.util.PropertiesHelper; import org.ops4j.pax.exam.Configuration; @@ -115,6 +116,7 @@ mavenBundle().groupId("jakarta.xml.bind").artifactId("jakarta.xml.bind-api").versionAsInProject(), //SUN JAXB IMPL OSGI mavenBundle().groupId("com.sun.xml.bind").artifactId("jaxb-osgi").versionAsInProject().versionAsInProject(), + getActivationBundle(), systemPackage("com.sun.source.tree"), systemPackage("com.sun.source.util"), @@ -256,4 +258,10 @@ result.put(EventConstants.EVENT_TOPIC, topics); return result; } + + private static Option getActivationBundle() { + return JdkVersion.getJdkVersion().getMajor() > 8 + ? mavenBundle().groupId("com.sun.activation").artifactId("jakarta.activation").versionAsInProject() + : null; + } }
diff --git a/pom.xml b/pom.xml index 65a7164..709de8e 100644 --- a/pom.xml +++ b/pom.xml
@@ -1914,13 +1914,6 @@ <dependency> <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam-container-native</artifactId> - <version>${pax.exam.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.ops4j.pax.exam</groupId> <artifactId>pax-exam-junit-extender-impl</artifactId> <version>1.2.4</version> <scope>test</scope> @@ -1995,22 +1988,21 @@ <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.framework</artifactId> - <!--5.2.0+ does not work with moxy osgi functional tests--> - <version>5.0.1</version> + <version>6.0.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.eventadmin</artifactId> - <version>1.2.2</version> + <version>1.5.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.framework.security</artifactId> - <version>2.2.0</version> + <version>2.6.1</version> <scope>test</scope> </dependency>
diff --git a/tests/osgi/functional/pom.xml b/tests/osgi/functional/pom.xml index 67cda5c..e41f405 100644 --- a/tests/osgi/functional/pom.xml +++ b/tests/osgi/functional/pom.xml
@@ -150,7 +150,7 @@ <dependency> <groupId>org.ops4j.pax.url</groupId> <artifactId>pax-url-aether</artifactId> - <version>1.6.0</version> + <version>2.6.2</version> <scope>test</scope> </dependency> <dependency> @@ -184,7 +184,7 @@ <groupId>org.ops4j.pax.logging</groupId> <artifactId>pax-logging-api</artifactId> <scope>test</scope> - <version>1.8.3</version> + <version>1.11.5</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> @@ -356,13 +356,6 @@ <artifactId>jakarta.xml.bind-api</artifactId> <scope>test</scope> </dependency> -<!-- <dependency>--> -<!-- Not needed since Jackson 2.10.1 --> -<!-- <groupId>com.sun.activation</groupId>--> -<!-- <artifactId>jakarta.activation</artifactId>--> -<!-- <version>${jakarta.activation.version}</version>--> -<!-- <scope>test</scope>--> -<!-- </dependency>--> <!-- logging --> <dependency> @@ -375,6 +368,19 @@ <profiles> <profile> + <id>jdk11dependency</id> + <activation> + <jdk>[11,)</jdk> + </activation> + <dependencies> + <dependency> + <groupId>com.sun.activation</groupId> + <artifactId>jakarta.activation</artifactId> + <version>${jakarta.activation.version}</version> + </dependency> + </dependencies> + </profile> + <profile> <id>testsSkipJdk8</id> <activation> <jdk>[1.8,11)</jdk> @@ -424,6 +430,7 @@ <exclude>org/glassfish/jersey/osgi/test/basic/BasicOsgiIntegrationTest.java</exclude> <exclude>org/glassfish/jersey/osgi/test/basic/BeanValidationTest.java</exclude> <exclude>org/glassfish/jersey/osgi/test/basic/JaxRsRiBundleTest.java</exclude> + <exclude>org/glassfish/jersey/osgi/test/basic/JsonJackson1Test.java</exclude> <exclude>org/glassfish/jersey/osgi/test/basic/JsonJacksonTest.java</exclude> <exclude>org/glassfish/jersey/osgi/test/basic/JsonJettisonTest.java</exclude> <exclude>org/glassfish/jersey/osgi/test/basic/JsonMoxyTest.java</exclude>
diff --git a/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/util/Helper.java b/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/util/Helper.java index 115c6a9..7811cbe 100644 --- a/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/util/Helper.java +++ b/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/util/Helper.java
@@ -21,6 +21,7 @@ import java.util.LinkedList; import java.util.List; +import org.glassfish.jersey.internal.util.JdkVersion; import org.glassfish.jersey.internal.util.PropertiesHelper; import org.glassfish.jersey.test.TestProperties; @@ -180,16 +181,21 @@ mavenBundle().groupId("org.glassfish.jersey.core").artifactId("jersey-client").versionAsInProject(), // Jersey Injection provider - mavenBundle().groupId("org.glassfish.jersey.inject").artifactId("jersey-hk2").versionAsInProject() + mavenBundle().groupId("org.glassfish.jersey.inject").artifactId("jersey-hk2").versionAsInProject(), // Jaxb - api - // not needed since Jackson 2.10.1 - // mavenBundle().groupId("com.sun.activation").artifactId("jakarta.activation").versionAsInProject() + getActivationBundle() )); } return addPaxExamMavenLocalRepositoryProperty(options); } + private static Option getActivationBundle() { + return JdkVersion.getJdkVersion().getMajor() > 8 + ? mavenBundle().groupId("com.sun.activation").artifactId("jakarta.activation").versionAsInProject() + : null; + } + /** * Create expanded options list from the supplied options. *