use of teetime.stage.basic.merger.strategy.BlockingBusyWaitingRoundRobinMergerStrategy in project TeeTime by teetime-framework.
the class StaticTaskFarmStageTest method testOrderedStaticTaskFarmStageWithMultipleStage.
@Test
public void testOrderedStaticTaskFarmStageWithMultipleStage() throws Exception {
ArrayCreator creator = new ArrayCreator(SEED);
List<Integer> randomNumbers = creator.createFilledList(1024);
TestTuple[] testInputTuples = { // expect in correct order
TestTuple.use(2, randomNumbers).expect(randomNumbers), // expect in correct order
TestTuple.use(3, randomNumbers).expect(randomNumbers) };
for (TestTuple testTuple : testInputTuples) {
StaticTaskFarmStage<Integer, Integer, Counter<Integer>> taskFarmStage = createTaskFarm(testTuple.numWorkerStages);
// ordered element passing
taskFarmStage.getDistributor().setStrategy(new BlockingBusyWaitingRoundRobinDistributorStrategy());
taskFarmStage.getMerger().setStrategy(new BlockingBusyWaitingRoundRobinMergerStrategy());
List<Integer> outputElements = new ArrayList<Integer>();
test(taskFarmStage).and().send(testTuple.inputElements).to(taskFarmStage.getInputPort()).and().receive(outputElements).from(taskFarmStage.getOutputPort()).start();
assertThat(outputElements, contains(testTuple.expectedOutputElements));
}
}
Aggregations