diff --git a/containers/pax-exam-container-forked/pom.xml b/containers/pax-exam-container-forked/pom.xml
index 15ba03a72..4ea6abab8 100644
--- a/containers/pax-exam-container-forked/pom.xml
+++ b/containers/pax-exam-container-forked/pom.xml
@@ -169,6 +169,21 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+
+ test
+
+
+
diff --git a/containers/pax-exam-container-forked/src/main/java/org/ops4j/pax/exam/forked/ForkedFrameworkFactory.java b/containers/pax-exam-container-forked/src/main/java/org/ops4j/pax/exam/forked/ForkedFrameworkFactory.java
index 64df0b25e..e75fdfac2 100644
--- a/containers/pax-exam-container-forked/src/main/java/org/ops4j/pax/exam/forked/ForkedFrameworkFactory.java
+++ b/containers/pax-exam-container-forked/src/main/java/org/ops4j/pax/exam/forked/ForkedFrameworkFactory.java
@@ -103,7 +103,7 @@ public void setFrameworkFactory(FrameworkFactory frameworkFactory) {
*/
public RemoteFramework fork(List vmArgs, Map systemProperties,
Map frameworkProperties, List beforeFrameworkClasspath,
- List afterFrameworkClasspath) {
+ List afterFrameworkClasspath, String[] env) {
// TODO make port range configurable
FreePort freePort = new FreePort(21000, 21099);
port = freePort.getPort();
@@ -124,7 +124,7 @@ public RemoteFramework fork(List vmArgs, Map systemPrope
String[] args = buildFrameworkProperties(frameworkProperties);
javaRunner = new ExamJavaRunner(false);
javaRunner.exec(vmOptions, buildClasspath(beforeFrameworkClasspath, afterFrameworkClasspath),
- RemoteFrameworkImpl.class.getName(), args, getJavaHome(), null);
+ RemoteFrameworkImpl.class.getName(), args, getJavaHome(), null, env);
return findRemoteFramework(port, rmiName);
}
catch (RemoteException | ExecutionException | URISyntaxException exc) {
@@ -147,7 +147,7 @@ public RemoteFramework fork(List vmArgs, Map systemPrope
*/
public RemoteFramework fork(List vmArgs, Map systemProperties,
Map frameworkProperties) {
- return fork(vmArgs, systemProperties, frameworkProperties, null, null);
+ return fork(vmArgs, systemProperties, frameworkProperties, null, null, new String[0]);
}
private String[] buildSystemProperties(List vmArgs, Map systemProperties) {
diff --git a/containers/pax-exam-container-forked/src/main/java/org/ops4j/pax/exam/forked/ForkedTestContainer.java b/containers/pax-exam-container-forked/src/main/java/org/ops4j/pax/exam/forked/ForkedTestContainer.java
index 796068562..03f9d2254 100644
--- a/containers/pax-exam-container-forked/src/main/java/org/ops4j/pax/exam/forked/ForkedTestContainer.java
+++ b/containers/pax-exam-container-forked/src/main/java/org/ops4j/pax/exam/forked/ForkedTestContainer.java
@@ -55,6 +55,7 @@
import org.ops4j.pax.exam.options.SystemPropertyOption;
import org.ops4j.pax.exam.options.UrlReference;
import org.ops4j.pax.exam.options.ValueOption;
+import org.ops4j.pax.exam.options.extra.EnvironmentOption;
import org.ops4j.pax.exam.options.extra.RepositoryOption;
import org.ops4j.pax.exam.options.extra.VMOption;
import org.ops4j.pax.swissbox.framework.RemoteFramework;
@@ -159,8 +160,15 @@ public TestContainer start() {
}
}
+ List environment = new ArrayList<>();
+ EnvironmentOption[] environmentOptions = system.getOptions(EnvironmentOption.class);
+ for (EnvironmentOption environmentOption : environmentOptions) {
+ environment.add(environmentOption.getEnvironment());
+ }
+ String[] env = environment.toArray(new String[environment.size()]);
+
remoteFramework = frameworkFactory.fork(vmArgs, systemProperties, frameworkProperties,
- beforeFrameworkClasspath, afterFrameworkClasspath);
+ beforeFrameworkClasspath, afterFrameworkClasspath, env);
remoteFramework.init();
installAndStartBundles();
}
diff --git a/containers/pax-exam-container-forked/src/test/java/org/ops4j/pax/exam/forked/ForkedFrameworkFactoryTest.java b/containers/pax-exam-container-forked/src/test/java/org/ops4j/pax/exam/forked/ForkedFrameworkFactoryTest.java
index 2a7da1d64..fec4d1a0c 100644
--- a/containers/pax-exam-container-forked/src/test/java/org/ops4j/pax/exam/forked/ForkedFrameworkFactoryTest.java
+++ b/containers/pax-exam-container-forked/src/test/java/org/ops4j/pax/exam/forked/ForkedFrameworkFactoryTest.java
@@ -111,7 +111,7 @@ public void forkWithBootClasspath() throws BundleException, IOException, Interru
"org.kohsuke.metainf_services");
RemoteFramework framework = forkedFactory.fork(Collections. emptyList(),
Collections. emptyMap(), frameworkProperties, null,
- bootClasspath);
+ bootClasspath, new String[0]);
framework.start();
File testBundle = generateBundle();
@@ -146,7 +146,7 @@ public void forkWithInvalidBootClasspath() throws BundleException, IOException,
"org.kohsuke.metainf_services");
forkedFactory.fork(Collections. emptyList(),
Collections. emptyMap(), frameworkProperties, null,
- bootClasspath);
+ bootClasspath, new String[0]);
}
private File generateBundle() throws IOException {
diff --git a/containers/pax-exam-container-forked/src/test/java/org/ops4j/pax/exam/forked/ForkedTestContainerFactoryTest.java b/containers/pax-exam-container-forked/src/test/java/org/ops4j/pax/exam/forked/ForkedTestContainerFactoryTest.java
index a2d56d688..d3a15afa7 100644
--- a/containers/pax-exam-container-forked/src/test/java/org/ops4j/pax/exam/forked/ForkedTestContainerFactoryTest.java
+++ b/containers/pax-exam-container-forked/src/test/java/org/ops4j/pax/exam/forked/ForkedTestContainerFactoryTest.java
@@ -27,6 +27,9 @@
import java.util.List;
import org.apache.commons.io.FileUtils;
+import org.hamcrest.core.IsEqual;
+import org.hamcrest.core.IsInstanceOf;
+import org.hamcrest.core.StringStartsWith;
import org.junit.Assert;
import org.junit.Test;
import org.ops4j.pax.exam.CoreOptions;
@@ -36,6 +39,7 @@
import org.ops4j.pax.exam.TestContainerException;
import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
import org.ops4j.pax.exam.options.UrlReference;
+import org.ops4j.pax.exam.options.extra.EnvironmentOption;
import org.ops4j.pax.exam.spi.PaxExamRuntime;
import org.ops4j.pax.tinybundles.TinyBundles;
import org.osgi.framework.BundleActivator;
@@ -156,4 +160,127 @@ public void start(BundleContext bc) throws Exception {
@Override
public void stop(BundleContext bc) throws Exception {}
}
+
+ @Test
+ public void withEnvironmentPassthrough() throws IOException {
+ // This test only works if the environment variable 'PROPAGATE' is set externally to 'test'
+ Assert.assertTrue(System.getenv().containsKey("PROPAGATE"));
+ Assert.assertThat(System.getenv().get("PROPAGATE"), IsEqual.equalTo("test"));
+
+ List