use of com.google.template.soy.jbcsrc.runtime.DetachableSoyValueProvider in project closure-templates by google.
the class SoySauceTest method testExceptionRewriting.
@Test
public void testExceptionRewriting() {
SoySauce.Renderer tmpl = sauce.renderTemplate("strict_test.callsItself");
SoyValueProvider intProvider = new DetachableSoyValueProvider() {
@Override
protected RenderResult doResolve() {
resolvedValue = IntegerData.ZERO;
return RenderResult.done();
}
};
try {
tmpl.setData(ImmutableMap.of("depth", 10, "p", intProvider)).render();
fail();
} catch (ClassCastException cce) {
// we get an CCE because we passed an int but it expected a string
StackTraceElement[] stackTrace = cce.getStackTrace();
assertThat(stackTrace[0].toString()).isEqualTo("strict_test.callsItself.render(strict.soy:32)");
for (int i = 1; i < 11; i++) {
assertThat(stackTrace[i].toString()).isEqualTo("strict_test.callsItself.render(strict.soy:34)");
}
}
}
Aggregations