Search in sources :

Example 1 with BlockingBusyWaitingRoundRobinMergerStrategy

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));
    }
}
Also used : Counter(teetime.stage.Counter) BlockingBusyWaitingRoundRobinMergerStrategy(teetime.stage.basic.merger.strategy.BlockingBusyWaitingRoundRobinMergerStrategy) ArrayList(java.util.ArrayList) ArrayCreator(teetime.testutil.ArrayCreator) BlockingBusyWaitingRoundRobinDistributorStrategy(teetime.stage.basic.distributor.strategy.BlockingBusyWaitingRoundRobinDistributorStrategy) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Counter (teetime.stage.Counter)1 BlockingBusyWaitingRoundRobinDistributorStrategy (teetime.stage.basic.distributor.strategy.BlockingBusyWaitingRoundRobinDistributorStrategy)1 BlockingBusyWaitingRoundRobinMergerStrategy (teetime.stage.basic.merger.strategy.BlockingBusyWaitingRoundRobinMergerStrategy)1 ArrayCreator (teetime.testutil.ArrayCreator)1