Skip to content

Commit

Permalink
use exec util instead of raw ProcessBuilder in GradleRunIntegrationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Apr 11, 2019
1 parent 8858104 commit cb3092f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
11 changes: 11 additions & 0 deletions devtools/gradle-it-run/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.vorburger.exec</groupId>
<artifactId>exec</artifactId>
<version>3.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;

import java.io.IOException;

import org.junit.jupiter.api.Test;

import ch.vorburger.exec.ManagedProcess;
import ch.vorburger.exec.ManagedProcessBuilder;
import ch.vorburger.exec.ManagedProcessException;

/**
* Integration Test which runs the sample app built by Gradle.
*
Expand All @@ -31,11 +33,11 @@ public class GradleRunIntegrationTest {
// do not rename this to *IT because we want it to run on regular mvn test without requiring failsafe

@Test
public void testHelloEndpoint() throws IOException {
Process process = new ProcessBuilder()
// .directory("../")
.command("java", "-jar", "../gradle-it/build/gradle-it-runner.jar")
.start();
public void testHelloEndpoint() throws ManagedProcessException {
ManagedProcess process = new ManagedProcessBuilder("java")
.addArgument("-jar").addArgument("../gradle-it/build/gradle-it-runner.jar").build();
process.start();

try {
given()
.when().get("/hello")
Expand Down

0 comments on commit cb3092f

Please sign in to comment.