Exemplo n.º 1
0
  @Test
  public void testCustomScriptTemplate() {
    GroovyAction bean = new GroovyAction();

    bean.setScriptTemplateResource(
        new ClassPathResource("custom-script-template.groovy", GroovyActionTest.class));

    bean.setScript("Assert.assertEquals(context.getVariable('scriptTemplateVar'), 'It works!')");
    bean.execute(context);
  }
Exemplo n.º 2
0
  @Test
  public void testInvalidScriptTemplate() {
    GroovyAction bean = new GroovyAction();

    bean.setScriptTemplateResource(
        new ClassPathResource("invalid-script-template.groovy", GroovyActionTest.class));

    bean.setScript("println 'This should not work!'");

    try {
      bean.execute(context);
    } catch (CitrusRuntimeException e) {
      Assert.assertTrue(e.getMessage().startsWith("Invalid script template"));
      return;
    }

    Assert.fail("Missing exception because of invalid script template");
  }