Package barsuift.simLife.condition

Examples of barsuift.simLife.condition.BoundConditionState


public class ConditionalTaskStateFactoryTest extends TestCase {

    public void testCreateConditionalTaskState() {
        ConditionalTaskState taskState;
        CyclicConditionState executionCondition;
        BoundConditionState endingCondition;
        ConditionalTaskStateFactory factory = new ConditionalTaskStateFactory();

        // existing class in properties file
        taskState = factory.createConditionalTaskState(AbstractSplitConditionalTask.class);
        executionCondition = taskState.getExecutionCondition();
        assertEquals(5, executionCondition.getCycle());
        assertEquals(0, executionCondition.getCount());
        endingCondition = taskState.getEndingCondition();
        assertEquals(10, endingCondition.getBound());
        assertEquals(0, endingCondition.getCount());

        // existing class in properties file
        taskState = factory.createConditionalTaskState(AbstractConditionalTask.class);
        executionCondition = taskState.getExecutionCondition();
        assertEquals(2, executionCondition.getCycle());
        assertEquals(0, executionCondition.getCount());
        endingCondition = taskState.getEndingCondition();
        assertEquals(0, endingCondition.getBound());
        assertEquals(0, endingCondition.getCount());

        // non existing class in properties file
        taskState = factory.createConditionalTaskState(SplitConditionalTask.class);
        executionCondition = taskState.getExecutionCondition();
        assertEquals(1, executionCondition.getCycle());
        assertEquals(0, executionCondition.getCount());
        endingCondition = taskState.getEndingCondition();
        assertEquals(0, endingCondition.getBound());
        assertEquals(0, endingCondition.getCount());
    }
View Full Code Here


    public void testCreateSplitConditionalTaskState() {
        SplitConditionalTaskState splitTaskState;
        ConditionalTaskState taskState;
        CyclicConditionState executionCondition;
        BoundConditionState endingCondition;
        ConditionalTaskStateFactory factory = new ConditionalTaskStateFactory();

        // existing class in properties file
        splitTaskState = factory.createSplitConditionalTaskState(AbstractSplitConditionalTask.class);
        assertEquals(1, splitTaskState.getStepSize());
        taskState = splitTaskState.getConditionalTask();
        executionCondition = taskState.getExecutionCondition();
        assertEquals(5, executionCondition.getCycle());
        assertEquals(0, executionCondition.getCount());
        endingCondition = taskState.getEndingCondition();
        assertEquals(10, endingCondition.getBound());
        assertEquals(0, endingCondition.getCount());

        // existing class in properties file
        splitTaskState = factory.createSplitConditionalTaskState(AbstractConditionalTask.class);
        assertEquals(1, splitTaskState.getStepSize());
        taskState = splitTaskState.getConditionalTask();
        executionCondition = taskState.getExecutionCondition();
        assertEquals(2, executionCondition.getCycle());
        assertEquals(0, executionCondition.getCount());
        endingCondition = taskState.getEndingCondition();
        assertEquals(0, endingCondition.getBound());
        assertEquals(0, endingCondition.getCount());

        // non existing class in properties file
        splitTaskState = factory.createSplitConditionalTaskState(SplitConditionalTask.class);
        assertEquals(1, splitTaskState.getStepSize());
        taskState = splitTaskState.getConditionalTask();
        executionCondition = taskState.getExecutionCondition();
        assertEquals(1, executionCondition.getCycle());
        assertEquals(0, executionCondition.getCount());
        endingCondition = taskState.getEndingCondition();
        assertEquals(0, endingCondition.getBound());
        assertEquals(0, endingCondition.getCount());
    }
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();
        // make sure the barrier will block the process as long as the other mock process is not run
        CyclicBarrier barrier = new CyclicBarrier(2);
        CyclicConditionState executionCondition = new CyclicConditionState(3, 0);
        BoundConditionState endingCondition = new BoundConditionState(60, 6);
        ConditionalTaskState conditionalTaskState = new ConditionalTaskState(executionCondition, endingCondition);
        state = new SplitConditionalTaskState(conditionalTaskState, 2);
        barrierReleaser = new MockSingleSynchronizedTask();
        barrierReleaser.changeBarrier(barrier);
        splitTask = new MockSplitConditionalTask(state);
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();
        // make sure the barrier will block the process as long as the other mock process is not run
        CyclicBarrier barrier = new CyclicBarrier(2);
        CyclicConditionState executionConditionState = new CyclicConditionState(3, 0);
        BoundConditionState endingConditionState = new BoundConditionState(5, 0);
        state = new ConditionalTaskState(executionConditionState, endingConditionState);
        barrierReleaser = new MockSingleSynchronizedTask();
        barrierReleaser.changeBarrier(barrier);
        conditionalRun = new MockConditionalTask(state);
        conditionalRun.changeBarrier(barrier);
View Full Code Here

     * <li>bound=[3-10]</li>
     * <li>count=[0-2]</li>
     * </ul>
     */
    public static BoundConditionState createRandomBoundConditionState() {
        return new BoundConditionState(Randomizer.randomBetween(3, 10), Randomizer.randomBetween(0, 2));
    }
View Full Code Here

     * <li>bound=5</li>
     * <li>count=2</li>
     * </ul>
     */
    public static BoundConditionState createSpecificBoundConditionState() {
        return new BoundConditionState(5, 2);
    }
View Full Code Here

     * <li>endingCondition made through {@link #createRandomBoundConditionState()}</li>
     * </ul>
     */
    public static ConditionalTaskState createRandomConditionalTaskState() {
        CyclicConditionState executionCondition = createRandomCyclicConditionState();
        BoundConditionState endingCondition = createRandomBoundConditionState();
        return new ConditionalTaskState(executionCondition, endingCondition);
    }
View Full Code Here

     * <li>endingCondition made through {@link #createSpecificBoundConditionState()}</li>
     * </ul>
     */
    public static ConditionalTaskState createSpecificConditionalTaskState() {
        CyclicConditionState executionCondition = createSpecificCyclicConditionState();
        BoundConditionState endingCondition = createSpecificBoundConditionState();
        return new ConditionalTaskState(executionCondition, endingCondition);
    }
View Full Code Here

    private void setUpWithBound(int bound) {
        state = new SynchronizerCoreState(Speed.VERY_FAST);
        synchro = new BasicSynchronizerCore(state);
        task = new MockConditionalTask(new ConditionalTaskState(new CyclicConditionState(1, 0),
                new BoundConditionState(bound, 0)));
        synchro.schedule(task);

        CyclicBarrier barrier = new CyclicBarrier(2);
        synchro.setBarrier(barrier);
        barrierReleaser = new MockSingleSynchronizedTask();
View Full Code Here

    }

    public void testSchedule() throws Exception {
        // create mocks with no bound to be sure they won't stop before the end of the test
        ConditionalTaskState conditionalTaskState = new ConditionalTaskState(new CyclicConditionState(1, 0),
                new BoundConditionState(0, 0));
        MockConditionalTask mockRun1 = new MockConditionalTask(conditionalTaskState);
        MockConditionalTask mockRun2 = new MockConditionalTask(conditionalTaskState);
        MockConditionalTask mockRun3 = new MockConditionalTask(conditionalTaskState);

        try {
View Full Code Here

TOP

Related Classes of barsuift.simLife.condition.BoundConditionState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.