예제 #1
0
  @Test
  public void testMultipleActions() {

    final Conditional conditionalAction = new Conditional();
    conditionalAction.setExpression("1 = 1");

    final TestAction action1 = EasyMock.createMock(TestAction.class);
    final TestAction action2 = EasyMock.createMock(TestAction.class);
    final TestAction action3 = EasyMock.createMock(TestAction.class);

    reset(action1, action2, action3);

    action1.execute(this.context);
    expectLastCall().once();
    action2.execute(this.context);
    expectLastCall().once();
    action3.execute(this.context);
    expectLastCall().once();

    replay(action1, action2, action3);

    final List<TestAction> actionList = new ArrayList<TestAction>();
    actionList.add(action1);
    actionList.add(action2);
    actionList.add(action3);

    conditionalAction.setActions(actionList);

    conditionalAction.execute(this.context);

    verify(action1, action2, action3);
  }
예제 #2
0
  @Test(expectedExceptions = CitrusRuntimeException.class)
  public void testFailingAction() {

    final Conditional conditionalAction = new Conditional();
    conditionalAction.setExpression("1 = 1");

    final TestAction action1 = EasyMock.createMock(TestAction.class);
    final TestAction action2 = EasyMock.createMock(TestAction.class);
    final TestAction action3 = EasyMock.createMock(TestAction.class);

    reset(action1, action2, action3);

    action1.execute(this.context);
    expectLastCall().once();

    replay(action1, action2, action3);

    final List<TestAction> actionList = new ArrayList<TestAction>();
    actionList.add(action1);
    actionList.add(new FailAction());
    actionList.add(action2);
    actionList.add(action3);

    conditionalAction.setActions(actionList);

    conditionalAction.execute(this.context);

    verify(action1, action2, action3);
  }
예제 #3
0
  @Test(expectedExceptions = IllegalStateException.class)
  public void testConditionFalse() {

    final Conditional conditionalAction = new Conditional();
    conditionalAction.setExpression("1 = 0");

    final TestAction action = EasyMock.createMock(TestAction.class);

    reset(action);

    action.execute(this.context);
    expectLastCall().once();

    replay(action);

    final List<TestAction> actionList = new ArrayList<TestAction>();
    actionList.add(action);
    conditionalAction.setActions(actionList);

    conditionalAction.execute(this.context);

    // must throw IllegalStateException, as the action should never be called
    expectLastCall().once();
  }