Commit f0d9e73d authored by Stein Eldar Johnsen's avatar Stein Eldar Johnsen 💬

Clean up ProcessExecutor exception handling.

So that all exceptions are handled for. The first exception is the
"thrown" one, all others are added as suppressed.

And nit in integrationExecutor to make missing line coverage more
visible. And add test for not finding the jar (and constructor).
parent 40f57b41
......@@ -48,7 +48,9 @@ public class IntegrationExecutor {
* @return The programs stdout content.
*/
public String getOutput() {
if (executor == null) return "";
if (executor == null) {
return "";
}
return executor.getOutput();
}
......@@ -56,7 +58,9 @@ public class IntegrationExecutor {
* @return The programs stderr content.
*/
public String getError() {
if (executor == null) return "";
if (executor == null) {
return "";
}
return executor.getError();
}
......
......@@ -16,7 +16,9 @@ import java.time.Clock;
import java.util.concurrent.ExecutorService;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
......@@ -101,4 +103,14 @@ public class IntegrationExecutorTest {
"one step ahead ;)\n" +
"+ cat\n", sut.getOutput());
}
@Test
public void testFindMavenTargetJar() {
try {
new IntegrationExecutor("src", "does-not-exist.1234567890.jar");
fail("No exception");
} catch (IOException e) {
assertThat(e.getMessage(), is("No such jar file: does-not-exist.1234567890.jar"));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment