From c38fc9b73c6e33bb3ca3fcb0e55582ed9a325641 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 30 Oct 2023 23:49:09 +1300 Subject: [PATCH] Test native-image with Process API --- .github/workflows/native-image.yml | 4 ++-- .../example/StartPostgresContainerTest.java | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/native-image.yml b/.github/workflows/native-image.yml index 6d8dcae..592b3f7 100644 --- a/.github/workflows/native-image.yml +++ b/.github/workflows/native-image.yml @@ -35,5 +35,5 @@ jobs: run: | mvn clean install -DskipTests cd test-native-image - mvn clean package -Pnative - ./target/test-native-image + mvn clean package -DskipTests -Pnative + mvn test diff --git a/test-native-image/src/test/java/org/example/StartPostgresContainerTest.java b/test-native-image/src/test/java/org/example/StartPostgresContainerTest.java index 01246da..631f0ae 100644 --- a/test-native-image/src/test/java/org/example/StartPostgresContainerTest.java +++ b/test-native-image/src/test/java/org/example/StartPostgresContainerTest.java @@ -3,6 +3,12 @@ import org.junit.jupiter.api.Test; import io.ebean.test.containers.*; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.util.List; + class StartPostgresContainerTest { @Test @@ -13,4 +19,20 @@ void test() { .build() .start(); } + + @Test + void run() throws Exception { + File out = new File("out"); + + Process process = new ProcessBuilder() + .command("./target/test-native-image") + .redirectErrorStream(true) + .redirectOutput(ProcessBuilder.Redirect.to(out)) + .start(); + + int code = process.waitFor(); + System.out.println("exit " + code); + + Files.lines(out.toPath()).forEach(System.out::println); + } }