use of com.disney.groovity.GroovityBuilder in project groovity by disney.
the class TestCyclicGroovity method testNormalCode.
@Test
public void testNormalCode() throws Exception {
groovity = new GroovityBuilder().setSourceLocations(Arrays.asList(new File("src/test/resources/static").toURI())).setSourcePhases(EnumSet.of(GroovityPhase.STARTUP)).build();
Exception e = null;
Binding binding = new Binding();
StringWriter writer = new StringWriter();
binding.setVariable("out", writer);
binding.setVariable("request", "someRuntimeRequest");
groovity.run("/static", binding);
System.out.println("Result for /static is " + writer.toString());
Assert.assertEquals("static|runtime", writer.toString());
}
use of com.disney.groovity.GroovityBuilder in project groovity by disney.
the class TestCyclicGroovity method testCyclicLoadChecking.
@Test
public void testCyclicLoadChecking() throws Exception {
groovity = new GroovityBuilder().setSourceLocations(Arrays.asList(new File("src/test/resources/cyclic").toURI())).setSourcePhases(EnumSet.of(GroovityPhase.STARTUP)).build();
Binding binding = new Binding();
StringWriter writer = new StringWriter();
binding.setVariable("out", writer);
Throwable e = null;
try {
groovity.run("/top", binding);
} catch (Exception x) {
e = x;
}
while (e != null && !(e instanceof InstantiationException)) {
e = e.getCause();
}
Assert.assertNotNull("Expected InstantiationException", e);
Assert.assertEquals("Expected InstantiationException", InstantiationException.class, e.getClass());
}
Aggregations