Skip to content
Snippets Groups Projects
Commit 2077b402 authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

removed obsolete test configs

parent 037c58fc
Branches
Tags
No related merge requests found
...@@ -16,9 +16,7 @@ ...@@ -16,9 +16,7 @@
package teetime.framework.exceptionHandling; package teetime.framework.exceptionHandling;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import teetime.framework.Execution; import teetime.framework.Execution;
...@@ -26,26 +24,6 @@ import teetime.framework.ExecutionException; ...@@ -26,26 +24,6 @@ import teetime.framework.ExecutionException;
public class ExceptionHandlingTest { 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 @Test
public void testException() { public void testException() {
boolean exceptionArised = false; boolean exceptionArised = false;
...@@ -58,25 +36,4 @@ public class ExceptionHandlingTest { ...@@ -58,25 +36,4 @@ public class ExceptionHandlingTest {
assertTrue(exceptionArised); 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);
}
}
} }
/**
* 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();
}
}
/**
* 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++;
}
}
/**
* 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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment