@@ -10,11 +10,14 @@ import java.nio.file.Path
1010import java.nio.file.Paths
1111import java.util.concurrent.TimeUnit
1212
13- val resourcesPath: Path = Paths .get(" src" , " test" , " resources" )
13+ val resourcesPath = Paths .get(" src" , " test" , " resources" )!!
1414
1515const val proxyHost = " 127.0.0.1"
1616val certPath = resourcesPath.resolve(" cert.pem" ).toAbsolutePath().toString()
1717
18+ // We always launch subprocesses with the same Java that we're using ourselves
19+ val javaPath = Paths .get(System .getProperty(" java.home" ), " bin" , " java" ).toString()!!
20+
1821val wireMockServer = WireMockServer (options()
1922 .dynamicPort()
2023 .enableBrowserProxying(true )
@@ -30,7 +33,7 @@ class IntegrationTests : StringSpec({
3033 val agentArgs = " $proxyHost |${wireMockServer.port()} |$certPath "
3134
3235 val proc = ProcessBuilder (
33- "/usr/bin/java" ,
36+ javaPath ,
3437 "-javaagent:./build/libs/http-proxy-agent-1.0-SNAPSHOT -all.jar=$agentArgs",
3538 "-jar", "./test-app/build/libs/test-app-1.0-SNAPSHOT -all.jar"
3639 ).inheritIO().start()
@@ -45,7 +48,7 @@ class IntegrationTests : StringSpec({
4548 " Launching directly and attaching later should eventually intercept all clients" {
4649 // Start up the target:
4750 val targetProc = ProcessBuilder (
48- "/usr/bin/java" ,
51+ javaPath ,
4952 "-jar", "./test-app/build/libs/test-app-1.0-SNAPSHOT -all.jar"
5053 ).inheritIO().start()
5154 runningProcs.add(targetProc)
@@ -58,7 +61,7 @@ class IntegrationTests : StringSpec({
5861
5962 // Attach the agent:
6063 val agentAttachProc = ProcessBuilder (
61- "/usr/bin/java" ,
64+ javaPath ,
6265 "-jar", "./build/libs/http-proxy-agent-1.0-SNAPSHOT -all.jar",
6366 targetProc.pid().toString(), proxyHost, wireMockServer.port().toString(), certPath
6467 ).inheritIO().start()
0 commit comments