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

migrated everywhere from Analysis.start() to Analysis.executeBlocking()

parent e4492868
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,6 @@ package teetime.framework.test; ...@@ -17,7 +17,6 @@ package teetime.framework.test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import teetime.framework.Analysis; import teetime.framework.Analysis;
...@@ -29,7 +28,6 @@ import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering; ...@@ -29,7 +28,6 @@ import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
import teetime.stage.CollectorSink; import teetime.stage.CollectorSink;
import teetime.stage.IterableProducer; import teetime.stage.IterableProducer;
import teetime.util.Pair;
/** /**
* This class can be used to test single stages in JUnit test cases. * This class can be used to test single stages in JUnit test cases.
...@@ -73,10 +71,10 @@ public final class StageTester { ...@@ -73,10 +71,10 @@ public final class StageTester {
return this; return this;
} }
public Collection<Pair<Thread, Throwable>> start() { public void start() {
final AnalysisConfiguration configuration = new Configuration(inputHolders, stage, outputHolders); final AnalysisConfiguration configuration = new Configuration(inputHolders, stage, outputHolders);
final Analysis analysis = new Analysis(configuration); final Analysis analysis = new Analysis(configuration);
return analysis.start(); analysis.executeBlocking();
} }
private final class Configuration extends AnalysisConfiguration { private final class Configuration extends AnalysisConfiguration {
......
...@@ -92,11 +92,10 @@ public class MethodCallThoughputTimestampAnalysis16Test extends PerformanceTest ...@@ -92,11 +92,10 @@ public class MethodCallThoughputTimestampAnalysis16Test extends PerformanceTest
configuration.build(); configuration.build();
final Analysis analysis = new Analysis(configuration); final Analysis analysis = new Analysis(configuration);
analysis.init();
this.stopWatch.start(); this.stopWatch.start();
try { try {
analysis.start(); analysis.executeBlocking();
} finally { } finally {
this.stopWatch.end(); this.stopWatch.end();
} }
......
...@@ -77,11 +77,10 @@ public class MethodCallThoughputTimestampAnalysis19Test extends PerformanceTest ...@@ -77,11 +77,10 @@ public class MethodCallThoughputTimestampAnalysis19Test extends PerformanceTest
configuration.build(); configuration.build();
final Analysis analysis = new Analysis(configuration); final Analysis analysis = new Analysis(configuration);
analysis.init();
this.stopWatch.start(); this.stopWatch.start();
try { try {
analysis.start(); analysis.executeBlocking();
} finally { } finally {
this.stopWatch.end(); this.stopWatch.end();
} }
......
...@@ -29,9 +29,8 @@ public class FiniteSignalPassingTest { ...@@ -29,9 +29,8 @@ public class FiniteSignalPassingTest {
boolean exceptionsOccured = false; boolean exceptionsOccured = false;
LoopStageAnalysisConfiguration configuration = new LoopStageAnalysisConfiguration(); LoopStageAnalysisConfiguration configuration = new LoopStageAnalysisConfiguration();
Analysis analysis = new Analysis(configuration); Analysis analysis = new Analysis(configuration);
analysis.init();
try { try {
analysis.start(); analysis.executeBlocking();
} catch (RuntimeException e) { } catch (RuntimeException e) {
exceptionsOccured = true; exceptionsOccured = true;
} }
......
...@@ -45,7 +45,7 @@ public class CipherTest { ...@@ -45,7 +45,7 @@ public class CipherTest {
final AnalysisConfiguration configuration = new CipherConfiguration(inputFile, outputFile, password); final AnalysisConfiguration configuration = new CipherConfiguration(inputFile, outputFile, password);
final Analysis analysis = new Analysis(configuration); final Analysis analysis = new Analysis(configuration);
analysis.start(); analysis.executeBlocking();
Assert.assertTrue(Files.equal(new File(inputFile), new File(outputFile))); Assert.assertTrue(Files.equal(new File(inputFile), new File(outputFile)));
} }
......
...@@ -44,7 +44,7 @@ public class TokenizerTest { ...@@ -44,7 +44,7 @@ public class TokenizerTest {
final TokenizerConfiguration configuration = new TokenizerConfiguration(inputFile, password); final TokenizerConfiguration configuration = new TokenizerConfiguration(inputFile, password);
final Analysis analysis = new Analysis(configuration); final Analysis analysis = new Analysis(configuration);
analysis.start(); analysis.executeBlocking();
final String string = Files.toString(new File("src/test/resources/data/input.txt"), Charset.forName("UTF-8")); final String string = Files.toString(new File("src/test/resources/data/input.txt"), Charset.forName("UTF-8"));
......
...@@ -18,6 +18,7 @@ package teetime.framework; ...@@ -18,6 +18,7 @@ package teetime.framework;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.lang.Thread.State; import java.lang.Thread.State;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import org.junit.Ignore; import org.junit.Ignore;
...@@ -117,7 +118,12 @@ public class RunnableConsumerStageTest { ...@@ -117,7 +118,12 @@ public class RunnableConsumerStageTest {
} }
private void start(final Analysis analysis) { private void start(final Analysis analysis) {
Collection<Pair<Thread, Throwable>> exceptions = analysis.start(); Collection<Pair<Thread, Throwable>> exceptions = new ArrayList<Pair<Thread, Throwable>>();
try {
analysis.executeBlocking();
} catch (AnalysisException e) {
exceptions = e.getThrownExceptions();
}
for (Pair<Thread, Throwable> pair : exceptions) { for (Pair<Thread, Throwable> pair : exceptions) {
System.err.println(pair.getSecond()); System.err.println(pair.getSecond());
System.err.println(Joiner.on("\n").join(pair.getSecond().getStackTrace())); System.err.println(Joiner.on("\n").join(pair.getSecond().getStackTrace()));
......
...@@ -23,7 +23,6 @@ import static org.junit.Assert.assertThat; ...@@ -23,7 +23,6 @@ import static org.junit.Assert.assertThat;
import static teetime.framework.test.StageTester.test; import static teetime.framework.test.StageTester.test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.junit.Before; import org.junit.Before;
...@@ -33,7 +32,6 @@ import teetime.framework.pipe.IPipeFactory; ...@@ -33,7 +32,6 @@ import teetime.framework.pipe.IPipeFactory;
import teetime.framework.pipe.SingleElementPipeFactory; import teetime.framework.pipe.SingleElementPipeFactory;
import teetime.stage.CollectorSink; import teetime.stage.CollectorSink;
import teetime.stage.InitialElementProducer; import teetime.stage.InitialElementProducer;
import teetime.util.Pair;
/** /**
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
...@@ -86,13 +84,12 @@ public class MergerTest { ...@@ -86,13 +84,12 @@ public class MergerTest {
mergerUnderTest = new Merger<Integer>(new RoundRobinStrategy()); mergerUnderTest = new Merger<Integer>(new RoundRobinStrategy());
List<Integer> outputList = new ArrayList<Integer>(); List<Integer> outputList = new ArrayList<Integer>();
Collection<Pair<Thread, Throwable>> exceptions = test(mergerUnderTest) test(mergerUnderTest)
.and().send(1, 2, 3).to(mergerUnderTest.getNewInputPort()) .and().send(1, 2, 3).to(mergerUnderTest.getNewInputPort())
.and().send(4, 5, 6).to(mergerUnderTest.getNewInputPort()) .and().send(4, 5, 6).to(mergerUnderTest.getNewInputPort())
.and().receive(outputList).from(mergerUnderTest.getOutputPort()) .and().receive(outputList).from(mergerUnderTest.getOutputPort())
.start(); .start();
assertThat(exceptions, is(empty()));
assertThat(outputList, is(not(empty()))); assertThat(outputList, is(not(empty())));
assertThat(outputList, contains(1, 4, 2, 5, 3, 6)); assertThat(outputList, contains(1, 4, 2, 5, 3, 6));
} }
......
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