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

first simple test

parent bddf4b48
No related branches found
No related tags found
No related merge requests found
package teetime.framework;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import teetime.framework.exceptionHandling.TestListener;
public class ExceptionHandling {
@Test
public void test() {
fail("Not yet implemented");
public void exceptionPassingAndTermination() {
TestListener listener = new TestListener();
Analysis analysis = new Analysis(new ExceptionTestConfiguration(), listener);
analysis.init();
analysis.start();
assertEquals(TestListener.exceptionInvoked, 2);
}
}
package teetime.framework;
public class ExceptionTestConfiguration extends AnalysisConfiguration {
public ExceptionTestConfiguration() {
this.addThreadableStage(new ExceptionTestStage());
}
}
package teetime.framework;
public class ExceptionTestStage extends AbstractProducerStage {
public int loops = 0;
@Override
protected void execute() {
if (loops % 1000 == 0) {
throw new IllegalStateException("1000 loops");
}
loops++;
}
}
......@@ -4,10 +4,16 @@ import teetime.framework.Stage;
public class TestListener extends StageExceptionListener {
public static int exceptionInvoked = 0;
@Override
public FurtherExecution onStageException(Exception e, Stage throwingStage) {
// TODO Auto-generated method stub
return null;
public FurtherExecution onStageException(final Exception e, final Stage throwingStage) {
exceptionInvoked++;
if (exceptionInvoked == 2) {
return FurtherExecution.TERMINATE;
} else {
return FurtherExecution.CONTINUE;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment