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; package teetime.framework;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import org.junit.Test; import org.junit.Test;
import teetime.framework.exceptionHandling.TestListener;
public class ExceptionHandling { public class ExceptionHandling {
@Test @Test
public void test() { public void exceptionPassingAndTermination() {
fail("Not yet implemented"); 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; ...@@ -4,10 +4,16 @@ import teetime.framework.Stage;
public class TestListener extends StageExceptionListener { public class TestListener extends StageExceptionListener {
public static int exceptionInvoked = 0;
@Override @Override
public FurtherExecution onStageException(Exception e, Stage throwingStage) { public FurtherExecution onStageException(final Exception e, final Stage throwingStage) {
// TODO Auto-generated method stub exceptionInvoked++;
return null; 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.
Please register or to comment