Package org.hive2hive.core.processes.util

Examples of org.hive2hive.core.processes.util.FailingSequentialProcess


  @Test
  public void syncFailTest() throws InvalidProcessStateException {

    // empty
    SequentialProcess process = new FailingSequentialProcess();
    process.start();
    assertTrue(process.getState() == ProcessState.FAILED);

    // sync components
    process = new SequentialProcess();
    ProcessStep step = new FailingProcessStep();
    process.add(step);
    process.start();
    assertTrue(process.getState() == ProcessState.FAILED);
    assertTrue(step.getState() == ProcessState.FAILED);

    // async components
    process = new SequentialProcess();
    ProcessComponent asyncStep = new AsyncComponent(new BusyFailingStep());
    process.add(asyncStep);
    process.start();
    assertTrue(process.getState() == ProcessState.FAILED);
    assertTrue(asyncStep.getState() == ProcessState.FAILED);
  }
View Full Code Here


  @Test
  public void asyncFailTest() throws InvalidProcessStateException {

    // empty
    SequentialProcess process = new FailingSequentialProcess();
    AsyncComponent asyncProcess = new AsyncComponent(process);
    asyncProcess.start();

    TestUtil.wait(WAIT_FOR_ASYNC);
    assertTrue(asyncProcess.getState() == ProcessState.FAILED);
    assertTrue(process.getState() == ProcessState.FAILED);

    // sync components
    process = new SequentialProcess();
    process.add(new BusyFailingStep());
    asyncProcess = new AsyncComponent(process);
    asyncProcess.start();

    TestUtil.wait(WAIT_FOR_ASYNC);
    assertTrue(asyncProcess.getState() == ProcessState.FAILED);
    assertTrue(process.getState() == ProcessState.FAILED);

    // async components
    process = new SequentialProcess();
    process.add(new AsyncComponent(new BusyFailingStep()));
    asyncProcess = new AsyncComponent(process);
    asyncProcess.start();

    TestUtil.wait(WAIT_FOR_ASYNC);
    assertTrue(asyncProcess.getState() == ProcessState.FAILED);
    assertTrue(process.getState() == ProcessState.FAILED);
  }
View Full Code Here

  public void syncListenerFailTest() throws InvalidProcessStateException {

    TestProcessComponentListener listener = new TestProcessComponentListener();

    // test fail
    SequentialProcess failProcess = new FailingSequentialProcess();
    failProcess.attachListener(listener);
    failProcess.start();

    assertFalse(listener.hasSucceeded());
    assertTrue(listener.hasFailed());
    assertTrue(listener.hasFinished());

    listener.reset();

    // test fail (1-layer, steps only)
    SequentialProcess failProcess2 = new SequentialProcess();
    failProcess2.add(new SucceedingProcessStep());
    failProcess2.add(new FailingProcessStep());
    failProcess2.attachListener(listener);
    failProcess2.start();

    assertFalse(listener.hasSucceeded());
    assertTrue(listener.hasFailed());
    assertTrue(listener.hasFinished());

    listener.reset();

    // test fail (1-layer, step and sub-process (failing) without children)
    SequentialProcess failProcess3 = new SequentialProcess();
    failProcess3.add(new SucceedingProcessStep());
    failProcess3.add(new FailingSequentialProcess());
    failProcess3.attachListener(listener);
    failProcess3.start();

    assertFalse(listener.hasSucceeded());
    assertTrue(listener.hasFailed());
    assertTrue(listener.hasFinished());

    listener.reset();

    // test fail (2-layer, steps (failing) and sub-process with children)
    SequentialProcess failProcess4 = new SequentialProcess();
    SequentialProcess successSubProcess = new SequentialProcess();
    successSubProcess.add(new SucceedingProcessStep());
    successSubProcess.add(new SucceedingProcessStep());

    failProcess4.add(new SucceedingProcessStep());
    failProcess4.add(successSubProcess);
    failProcess4.add(new FailingProcessStep());
    failProcess4.attachListener(listener);
    failProcess4.start();

    assertFalse(listener.hasSucceeded());
    assertTrue(listener.hasFailed());
    assertTrue(listener.hasFinished());

    listener.reset();

    // test fail (2-layer, steps and sub-process (failing) with children)
    SequentialProcess failProcess5 = new SequentialProcess();
    SequentialProcess failSubProcess = new FailingSequentialProcess();

    failProcess5.add(new SucceedingProcessStep());
    failProcess5.add(failSubProcess);
    failProcess5.add(new SucceedingProcessStep());
    failProcess5.attachListener(listener);
View Full Code Here

  public void asyncListenerFailTest() throws InvalidProcessStateException {

    TestProcessComponentListener listener = new TestProcessComponentListener();

    // test fail
    AsyncComponent failProcess = new AsyncComponent(new FailingSequentialProcess());
    failProcess.attachListener(listener);
    failProcess.start();

    UseCaseTestUtil.waitTillFailed(listener, MAX_ASYNC_WAIT);

    assertFalse(listener.hasSucceeded());
    assertTrue(listener.hasFailed());
    assertTrue(listener.hasFinished());

    listener.reset();

    // test fail (1-layer, steps only)
    SequentialProcess failProcess2 = new SequentialProcess();
    failProcess2.add(new SucceedingProcessStep());
    failProcess2.add(new FailingProcessStep());

    AsyncComponent asyncProcess2 = new AsyncComponent(failProcess2);
    asyncProcess2.attachListener(listener);
    asyncProcess2.start();

    UseCaseTestUtil.waitTillFailed(listener, MAX_ASYNC_WAIT);

    assertFalse(listener.hasSucceeded());
    assertTrue(listener.hasFailed());
    assertTrue(listener.hasFinished());

    listener.reset();

    // test fail (1-layer, step and sub-process (failing) without children)
    SequentialProcess failProcess3 = new SequentialProcess();
    failProcess3.add(new SucceedingProcessStep());
    failProcess3.add(new FailingSequentialProcess());

    AsyncComponent asyncProcess3 = new AsyncComponent(failProcess3);
    asyncProcess3.attachListener(listener);
    asyncProcess3.start();

    UseCaseTestUtil.waitTillFailed(listener, MAX_ASYNC_WAIT);

    assertFalse(listener.hasSucceeded());
    assertTrue(listener.hasFailed());
    assertTrue(listener.hasFinished());

    listener.reset();

    // test fail (2-layer, steps (failing) and sub-process with children)
    SequentialProcess failProcess4 = new SequentialProcess();
    SequentialProcess successSubProcess = new SequentialProcess();
    successSubProcess.add(new SucceedingProcessStep());
    successSubProcess.add(new SucceedingProcessStep());

    failProcess4.add(new SucceedingProcessStep());
    failProcess4.add(successSubProcess);
    failProcess4.add(new FailingProcessStep());

    AsyncComponent asyncProcess4 = new AsyncComponent(failProcess4);
    asyncProcess4.attachListener(listener);
    asyncProcess4.start();

    UseCaseTestUtil.waitTillFailed(listener, MAX_ASYNC_WAIT);

    assertFalse(listener.hasSucceeded());
    assertTrue(listener.hasFailed());
    assertTrue(listener.hasFinished());

    listener.reset();

    // test fail (2-layer, steps and sub-process (failing) with children)
    SequentialProcess failProcess5 = new SequentialProcess();
    SequentialProcess failSubProcess = new FailingSequentialProcess();

    failProcess5.add(new SucceedingProcessStep());
    failProcess5.add(failSubProcess);
    failProcess5.add(new SucceedingProcessStep());
View Full Code Here

TOP

Related Classes of org.hive2hive.core.processes.util.FailingSequentialProcess

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.