diff --git a/pom.xml b/pom.xml index d2e664f3470be5ec5fe6390dfac69ccbc6265141..e40e11d5600f3342b84e90c083e40ffc8d27a63e 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <javadocOutputDir>apidocs</javadocOutputDir> - + <java.version>1.6</java.version> <checkstyle.version>2.16</checkstyle.version> <findbugs.version>3.0.1</findbugs.version> diff --git a/src/main/java/teetime/framework/Execution.java b/src/main/java/teetime/framework/Execution.java index 5ba331da26b2c7b45b9110811bbc233d0b772140..2c0b7be700f95cff221d106cd4338666e32536fb 100644 --- a/src/main/java/teetime/framework/Execution.java +++ b/src/main/java/teetime/framework/Execution.java @@ -118,7 +118,7 @@ public final class Execution<T extends Configuration> { } // TODO: implement - private void abortEventually() { + public void abortEventually() { configurationContext.abortConfigurationRun(); waitForTermination(); } diff --git a/src/test/java/teetime/framework/TerminationTest.java b/src/test/java/teetime/framework/TerminationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ce339f90870866cbda5c89ba4801d14f70b1c828 --- /dev/null +++ b/src/test/java/teetime/framework/TerminationTest.java @@ -0,0 +1,48 @@ +package teetime.framework; + +import org.junit.Test; + +import teetime.stage.InitialElementProducer; + +public class TerminationTest { + + @Test(timeout = 2000) + public void doesNotGetStuckInAdd() throws InterruptedException { + Execution<TerminationConfig> execution = new Execution<TerminationConfig>(new TerminationConfig()); + execution.executeNonBlocking(); + Thread.sleep(1000); + execution.abortEventually(); + } + + private class TerminationConfig extends Configuration { + InitialElementProducer<Integer> init = new InitialElementProducer<Integer>(1, 2, 3, 4, 5, 6); + DoesNotRetrieveElements sinkStage = new DoesNotRetrieveElements(); + + public TerminationConfig() { + connectPorts(init.getOutputPort(), sinkStage.getInputPort(), 1); + addThreadableStage(sinkStage); + } + + } + + private class DoesNotRetrieveElements extends AbstractConsumerStage<Integer> { + + @Override + protected void execute(final Integer element) { + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + // Will happen in this test + } + + } + + @Override + protected void terminate() { + Thread.currentThread().interrupt(); + System.out.println("TADA " + this.shouldBeTerminated()); + } + + } + +}