Example #1
0
  @Test(expectedExceptions = CitrusRuntimeException.class)
  @SuppressWarnings({"unchecked", "rawtypes"})
  public void testAssertExceptionWrongMessageCheck() {
    Assert assertAction = new Assert();

    FailAction fail = new FailAction();
    fail.setMessage("This went wrong!");

    assertAction.setAction(fail);

    Class exceptionClass = CitrusRuntimeException.class;
    assertAction.setException(exceptionClass);
    assertAction.setMessage("Excpected error is something else");

    assertAction.execute(context);
  }
  @Test
  public void testFailBuilder() {
    MockTestDesigner builder =
        new MockTestDesigner(applicationContext) {
          @Override
          public void configure() {
            fail("This test will fail.");
          }
        };

    builder.configure();

    TestCase test = builder.build();
    Assert.assertEquals(test.getActionCount(), 1);
    Assert.assertEquals(test.getActions().get(0).getClass(), FailAction.class);

    FailAction action = (FailAction) test.getActions().get(0);
    Assert.assertEquals(action.getName(), "fail");
    Assert.assertEquals(action.getMessage(), "This test will fail.");
  }