You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2019/05/22 14:59:56 UTC
[sling-org-apache-sling-testing-paxexam] branch master updated:
SLING-8432 - Provide support for running the Pax tests on Java 9 and higher
This is an automated email from the ASF dual-hosted git repository.
radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-paxexam.git
The following commit(s) were added to refs/heads/master by this push:
new 0e00509 SLING-8432 - Provide support for running the Pax tests on Java 9 and higher
0e00509 is described below
commit 0e00509be90f91c42450c7fcc0179c82f388676b
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Wed May 22 16:59:42 2019 +0200
SLING-8432 - Provide support for running the Pax tests on Java 9 and higher
---
pom.xml | 8 ++---
.../apache/sling/testing/paxexam/TestSupport.java | 34 ++++++++++++++++++++++
.../paxexam/it/SlingOptionsTestSupport.java | 3 ++
3 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index d57426b..75efa0a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,8 +23,8 @@
<parent>
<groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
- <version>34</version>
+ <artifactId>sling-bundle-parent</artifactId>
+ <version>35</version>
<relativePath />
</parent>
@@ -37,8 +37,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <sling.java.version>7</sling.java.version>
- <org.ops4j.pax.exam.version>4.13.0</org.ops4j.pax.exam.version>
+ <sling.java.version>8</sling.java.version>
+ <org.ops4j.pax.exam.version>4.13.1</org.ops4j.pax.exam.version>
</properties>
<scm>
diff --git a/src/main/java/org/apache/sling/testing/paxexam/TestSupport.java b/src/main/java/org/apache/sling/testing/paxexam/TestSupport.java
index d21eaf4..349476d 100644
--- a/src/main/java/org/apache/sling/testing/paxexam/TestSupport.java
+++ b/src/main/java/org/apache/sling/testing/paxexam/TestSupport.java
@@ -21,6 +21,7 @@ package org.apache.sling.testing.paxexam;
import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
+import java.util.Arrays;
import java.util.Dictionary;
import java.util.UUID;
@@ -32,21 +33,26 @@ import org.ops4j.pax.exam.options.ModifiableCompositeOption;
import org.ops4j.pax.exam.util.PathUtils;
import org.ops4j.pax.tinybundles.core.TinyBundle;
import org.osgi.service.cm.ConfigurationAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.apache.sling.testing.paxexam.SlingOptions.paxTinybundles;
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.keepCaches;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.repository;
import static org.ops4j.pax.exam.CoreOptions.streamBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
public abstract class TestSupport {
private final String workingDirectory = String.format("%s/target/paxexam/%s/%s", PathUtils.getBaseDir(), getClass().getSimpleName(), UUID.randomUUID());
+ private final Logger logger = LoggerFactory.getLogger(getClass());
@Inject
protected ConfigurationAdmin configurationAdmin;
@@ -110,4 +116,32 @@ public abstract class TestSupport {
).start();
}
+ public Option jvmSetup() {
+ Option[] configuration = new Option[0];
+ try {
+ int javaVersion = Integer.parseInt(System.getProperty("java.specification.version"));
+ if (javaVersion >= 9 && javaVersion < 11) {
+ configuration = Arrays.copyOf(configuration, configuration.length + 1);
+ configuration[configuration.length - 1] = vmOption("--add-modules=java.se.ee");
+ logger.info("Using the following options for Java {}:\n{}", javaVersion, configuration);
+ }
+ if (javaVersion >= 11) {
+ configuration = Arrays.copyOf(configuration, configuration.length + 1);
+ configuration[configuration.length -1] = composite(
+ frameworkProperty("org.osgi.framework.system.packages.extra")
+ .value("javax.xml.stream;version=\"1.1.0\",javax.xml.stream.events;" +
+ "version=\"1.1.0\""),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-annotation_1.3_spec", "1.1"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-activation_1.1_spec", "1.1"),
+ mavenBundle("org.apache.servicemix.specs", "org.apache.servicemix.specs.jaxb-api-2.2", "2.9.0"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.jaxb-impl", "2.2.11_1")
+ );
+ logger.info("Using the following options for Java {}:\n{}", javaVersion, configuration);
+ }
+ } catch (NumberFormatException e) {
+ logger.info("No special setup needed for Java 8.");
+ }
+ return CoreOptions.composite(configuration);
+ }
+
}
diff --git a/src/test/java/org/apache/sling/testing/paxexam/it/SlingOptionsTestSupport.java b/src/test/java/org/apache/sling/testing/paxexam/it/SlingOptionsTestSupport.java
index 02e8504..ee2aa74 100644
--- a/src/test/java/org/apache/sling/testing/paxexam/it/SlingOptionsTestSupport.java
+++ b/src/test/java/org/apache/sling/testing/paxexam/it/SlingOptionsTestSupport.java
@@ -21,6 +21,7 @@ package org.apache.sling.testing.paxexam.it;
import java.io.File;
import java.util.UUID;
+import org.apache.sling.testing.paxexam.TestSupport;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.util.PathUtils;
@@ -40,7 +41,9 @@ public abstract class SlingOptionsTestSupport {
}
protected Option baseConfiguration() {
+ TestSupport testSupport = new TestSupport() {};
return composite(
+ testSupport.jvmSetup(),
failOnUnresolvedBundles(),
keepCaches(),
localMavenRepo(),