@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); }
@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"); }