From ac23e617801346d9758ab5bd2d4f879afb1133a9 Mon Sep 17 00:00:00 2001 From: Nelson Tavares de Sousa <stu103017@mail.uni-kiel.de> Date: Tue, 7 Jul 2015 10:53:01 +0200 Subject: [PATCH] fixes #199 The assertions must never be executed, therefore replacing with fail() --- .../ExceptionHandlingTest.java | 52 ++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/test/java/teetime/framework/exceptionHandling/ExceptionHandlingTest.java b/src/test/java/teetime/framework/exceptionHandling/ExceptionHandlingTest.java index 8b8e93d4..37d142f4 100644 --- a/src/test/java/teetime/framework/exceptionHandling/ExceptionHandlingTest.java +++ b/src/test/java/teetime/framework/exceptionHandling/ExceptionHandlingTest.java @@ -25,12 +25,33 @@ import teetime.framework.ExecutionException; public class ExceptionHandlingTest { + private Execution<ExceptionTestConfiguration> execution; + + public ExceptionTestConfiguration newInstances() { + ExceptionTestConfiguration configuration = new ExceptionTestConfiguration(); + execution = new Execution<ExceptionTestConfiguration>(configuration, new TestListenerFactory()); + return configuration; + } + + public void exceptionPassingAndTermination() { + newInstances(); + execution.executeBlocking(); + fail(); // Should never be executed + } + + public void terminatesAllStages() { + ExceptionTestConfiguration config = newInstances(); + execution.executeBlocking(); + fail(); // Should never be executed + } + @Test public void forAFewTimes() { for (int i = 0; i < 100; i++) { boolean exceptionArised = false; try { - exceptionPassingAndTermination(); + + exceptionPassingAndTermination(); // listener did not kill thread too early; } catch (ExecutionException e) { exceptionArised = true; } @@ -45,33 +66,4 @@ public class ExceptionHandlingTest { assertTrue(exceptionArised); } } - - public void exceptionPassingAndTermination() { - Execution<ExceptionTestConfiguration> execution = newInstances(); - - execution.executeBlocking(); - - fail(); - // TestListenerFactory factory = (TestListenerFactory) execution.getFactory(); - // assertThat(factory.getInstances(), hasSize(2)); - // assertEquals(factory.getInstances().get(0).getNumExceptionsInvoked(), 2); // listener did not kill thread too early - } - - public Execution<ExceptionTestConfiguration> newInstances() { - ExceptionTestConfiguration configuration = new ExceptionTestConfiguration(); - TestListenerFactory factory = new TestListenerFactory(); - return new Execution<ExceptionTestConfiguration>(configuration, factory); - } - - public void terminatesAllStages() { - Execution<ExceptionTestConfiguration> execution = newInstances(); - - execution.executeBlocking(); - - fail(); - // ExceptionTestConfiguration config = execution.getConfiguration(); - // assertThat(config.first.getCurrentState(), is(StageState.TERMINATED)); - // assertThat(config.second.getCurrentState(), is(StageState.TERMINATED)); - // assertThat(config.third.getCurrentState(), is(StageState.TERMINATED)); - } } -- GitLab