diff --git a/src/test/java/teetime/framework/exceptionHandling/ExceptionHandlingTest.java b/src/test/java/teetime/framework/exceptionHandling/ExceptionHandlingTest.java index c1b1de38e023806fc8f9571a67372f677817980c..5fb16e84997320f656e981a21d2d2eec4bfc4f39 100644 --- a/src/test/java/teetime/framework/exceptionHandling/ExceptionHandlingTest.java +++ b/src/test/java/teetime/framework/exceptionHandling/ExceptionHandlingTest.java @@ -16,9 +16,7 @@ package teetime.framework.exceptionHandling; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import org.junit.Ignore; import org.junit.Test; import teetime.framework.Execution; @@ -26,26 +24,6 @@ import teetime.framework.ExecutionException; public class ExceptionHandlingTest { - private Execution<ExceptionTestConfiguration> execution; - - public ExceptionTestConfiguration newInstances() { - ExceptionTestConfiguration configuration = new ExceptionTestConfiguration(); - execution = new Execution<ExceptionTestConfiguration>(configuration); - 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 testException() { boolean exceptionArised = false; @@ -58,25 +36,4 @@ public class ExceptionHandlingTest { assertTrue(exceptionArised); } - @Ignore - @Test - public void forAFewTimes() { - for (int i = 0; i < 100; i++) { - boolean exceptionArised = false; - try { - exceptionPassingAndTermination(); // listener did not kill thread too early; - } catch (ExecutionException e) { - exceptionArised = true; - } - assertTrue(exceptionArised); - - exceptionArised = false; - try { - terminatesAllStages(); - } catch (ExecutionException e) { - exceptionArised = true; - } - assertTrue(exceptionArised); - } - } } diff --git a/src/test/java/teetime/framework/exceptionHandling/ExceptionTestConfiguration.java b/src/test/java/teetime/framework/exceptionHandling/ExceptionTestConfiguration.java deleted file mode 100644 index 79f7ff1dd23f5ed9006ed4bd1d78f54e0b946c06..0000000000000000000000000000000000000000 --- a/src/test/java/teetime/framework/exceptionHandling/ExceptionTestConfiguration.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package teetime.framework.exceptionHandling; - -import teetime.framework.Configuration; - -public class ExceptionTestConfiguration extends Configuration { - - ExceptionTestProducerStage first; - ExceptionTestConsumerStage second; - ExceptionTestProducerStage third; - - public ExceptionTestConfiguration() { - super(new TestListenerFactory()); - - first = new ExceptionTestProducerStage(); - second = new ExceptionTestConsumerStage(); - third = new ExceptionTestProducerStage(); - - connectPorts(first.getOutputPort(), second.getInputPort()); - // this.addThreadableStage(new ExceptionTestStage()); - - second.declareActive(); - third.declareActive(); - } - -} diff --git a/src/test/java/teetime/framework/exceptionHandling/ExceptionTestConsumerStage.java b/src/test/java/teetime/framework/exceptionHandling/ExceptionTestConsumerStage.java deleted file mode 100644 index 0f2df92f2ab57d2afcca883f7bede09829b952fb..0000000000000000000000000000000000000000 --- a/src/test/java/teetime/framework/exceptionHandling/ExceptionTestConsumerStage.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package teetime.framework.exceptionHandling; - -import teetime.framework.AbstractConsumerStage; - -public class ExceptionTestConsumerStage extends AbstractConsumerStage<Object> { - - private int numberOfExecutions = 0; - - @Override - protected void execute(final Object element) { - if (numberOfExecutions % 1000 == 0) { - throw new IllegalStateException("1000 loops"); - } - numberOfExecutions++; - } - -} diff --git a/src/test/java/teetime/framework/exceptionHandling/ExceptionTestProducerStage.java b/src/test/java/teetime/framework/exceptionHandling/ExceptionTestProducerStage.java deleted file mode 100644 index 40bb6f5fa0ef18c6fc86288a3db32aeeb0b7d3d1..0000000000000000000000000000000000000000 --- a/src/test/java/teetime/framework/exceptionHandling/ExceptionTestProducerStage.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package teetime.framework.exceptionHandling; - -import teetime.framework.AbstractProducerStage; -import teetime.framework.InputPort; -import teetime.framework.TerminationStrategy; - -public class ExceptionTestProducerStage extends AbstractProducerStage<Object> { - - private static int instances = 0; - private TerminationStrategy strategy; - public int numberOfExecutions = 0; - private final InputPort<Object> input = createInputPort(); - - ExceptionTestProducerStage() { - switch (instances) { - case 0: { - strategy = TerminationStrategy.BY_SELF_DECISION; - break; - } - case 1: { - strategy = TerminationStrategy.BY_INTERRUPT; - break; - } - default: { - strategy = TerminationStrategy.BY_SELF_DECISION; - } - } - - instances++; - } - - @Override - protected void execute() { - getOutputPort().send(new Object()); - if (numberOfExecutions++ >= 10000 && strategy == TerminationStrategy.BY_SELF_DECISION) { - this.terminate(); - } - } - - @Override - public TerminationStrategy getTerminationStrategy() { - return strategy; - } - - @Override - public String getId() { - if (strategy == TerminationStrategy.BY_INTERRUPT) { - return "Infinite" + super.getId(); - } - return "Finite" + super.getId(); - } -}