Skip to content

Commit f45251b

Browse files
committed
Use the same JVM version for subprocesses in tests
1 parent 6f97929 commit f45251b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/test/kotlin/IntegrationTests.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ import java.nio.file.Path
1010
import java.nio.file.Paths
1111
import java.util.concurrent.TimeUnit
1212

13-
val resourcesPath: Path = Paths.get("src", "test", "resources")
13+
val resourcesPath = Paths.get("src", "test", "resources")!!
1414

1515
const val proxyHost = "127.0.0.1"
1616
val 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+
1821
val 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()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package tech.httptoolkit.testapp.cases;public class JettyClientCase {
2+
}

0 commit comments

Comments
 (0)