Examples of SemaphoreListener


Examples of org.jenkinsci.plugins.workflow.test.SemaphoreListener

    @Test public void basics() throws Exception {
        SemaphoreStep step = new SemaphoreStep();
        final AtomicReference<FlowExecution> exec = new AtomicReference<FlowExecution>();
        exec.set(new STMFlowDefinition(Collections.<State>singletonList(new StepState("run", null, step))).create(new OwnerImpl(exec, tmp), Collections.<Action>emptyList()));
        SemaphoreListener l = new SemaphoreListener();
        exec.get().addListener(l);
        exec.get().start();
        FlowNode n = l.next();
        assertTrue(String.valueOf(n), n instanceof FlowStartNode);
        n = l.next();
        assertTrue(n instanceof BlockStartNode);
        step.success(null);
        n = l.next();
        assertTrue(n instanceof AtomNode);
        // TODO check that it is finished now
        n = l.next();
        assertTrue(n instanceof BlockEndNode);
        // TODO check that it matches the BlockStartNode
        n = l.next();
        assertTrue(n instanceof FlowEndNode);
        // TODO check that it matches the FlowStartNode
        // TODO check that its parent list is the BlockEndNode
        assertTrue(exec.get().isComplete());
    }
View Full Code Here

Examples of org.jenkinsci.plugins.workflow.test.SemaphoreListener

    @Test public void blocks() throws Throwable {
        SemaphoreStep step = new SemaphoreStep();
        BlockSemaphoreStep block = new BlockSemaphoreStep();
        final AtomicReference<FlowExecution> exec = new AtomicReference<FlowExecution>();
        exec.set(new STMFlowDefinition(Arrays.<State>asList(new BlockState("block", STMExecution.END, block, "step"), new StepState("step", STMExecution.END, step))).create(new OwnerImpl(exec, tmp), Collections.<Action>emptyList()));
        SemaphoreListener l = new SemaphoreListener();
        exec.get().addListener(l);
        exec.get().start();
        FlowNode n = l.next();
        assertTrue(String.valueOf(n), n instanceof FlowStartNode);
        n = l.next();
        assertTrue(n instanceof BlockStartNode);
        n = l.next();
        assertTrue(n instanceof BlockStartNode);
        block.startBlock();
        step.success(null);
        n = l.next();
        assertTrue(n instanceof AtomNode);
        assertEquals(null, block.waitForBlock());
        block.finishSuccess(null);
        n = l.next();
        assertTrue(n instanceof BlockEndNode);
        n = l.next();
        assertTrue(n instanceof BlockEndNode);
        n = l.next();
        assertTrue(n instanceof FlowEndNode);
        assertTrue(exec.get().isComplete());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.