diff --git a/final/ticket-service-acceptance-tests/src/test/java/com/training/epam/ticketservice/at/GenericCliProcessStepDefs.java b/final/ticket-service-acceptance-tests/src/test/java/com/training/epam/ticketservice/at/GenericCliProcessStepDefs.java index a09c625d..fad247cc 100644 --- a/final/ticket-service-acceptance-tests/src/test/java/com/training/epam/ticketservice/at/GenericCliProcessStepDefs.java +++ b/final/ticket-service-acceptance-tests/src/test/java/com/training/epam/ticketservice/at/GenericCliProcessStepDefs.java @@ -8,12 +8,15 @@ import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import java.io.IOException; +import java.io.File; +import java.io.FileNotFoundException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; public class GenericCliProcessStepDefs { private static final int OUTPUT_TIMEOUT = 30000; + private static final String jarFile = "../ticket-service/target/ticket-service-0.0.1-SNAPSHOT.jar"; private ProcessUnderTest cliProcess; @@ -23,6 +26,9 @@ public GenericCliProcessStepDefs(ProcessUnderTest cliProcess) { @Given("the application is started") public void applicationStarted() throws IOException, InterruptedException { + if (!(new File(jarFile)).isFile()){ + throw new FileNotFoundException("The path " + jarFile + " does not exist. It should be your built JAR file."); + } cliProcess.run("java -jar -Dspring.profiles.active=ci ../ticket-service/target/ticket-service-0.0.1-SNAPSHOT.jar"); } diff --git a/final/ticket-service-acceptance-tests/src/test/java/com/training/epam/ticketservice/at/ProcessUnderTest.java b/final/ticket-service-acceptance-tests/src/test/java/com/training/epam/ticketservice/at/ProcessUnderTest.java index 66cf8f1f..20a2c0d6 100644 --- a/final/ticket-service-acceptance-tests/src/test/java/com/training/epam/ticketservice/at/ProcessUnderTest.java +++ b/final/ticket-service-acceptance-tests/src/test/java/com/training/epam/ticketservice/at/ProcessUnderTest.java @@ -68,7 +68,11 @@ private void clearOutput(long delayBeforeCleaning) throws IOException { private Void readOutputUntil(String expectedOutput) throws IOException { String actualString = ""; do { - actualString += (char) output.read(); + int c = output.read(); + if (c == -1) { + throw new IOException("Reached EOF before receiving '" + expectedOutput + "'"); + } + actualString += (char) c; if (actualString.length() > expectedOutput.length()) { actualString = actualString.substring(1); }