*
* ComponentImpl just makes render() call on the RenderDef object. All exceptions should be wrapped in
* AuraExecutionException, while errors and quickfix exceptions are passed through.
*/
public void testExceptionThrownByComponentRendererHandled() throws Exception {
JavaRendererDef def = createRenderer("java://org.auraframework.impl.renderer.sampleJavaRenderers.TestSimpleRenderer");
IOException ioe = new IOException();
AuraError err = new AuraError("expected");
RuntimeException re = new RuntimeException("expected");
try {
def.render(null, new AppendableThrower(ioe));
fail("no exception on a throwing appendable");
} catch (AuraExecutionException expected) {
assertEquals("Did not throw wrapped IOException", ioe, expected.getCause());
}
try {
def.render(null, new AppendableThrower(err));
fail("No exception on a throwing appendable.");
} catch (AuraError expected) {
assertEquals("Did not throw error", err, expected);
}
try {
def.render(null, new AppendableThrower(re));
fail("no exception on a throwing appendable");
} catch (AuraExecutionException expected) {
assertEquals("Did not throw error", re, expected.getCause());
}
// Make sure ArithmeticExceptions are wrapped and sent up the chain
def = createRenderer("java://org.auraframework.impl.renderer.sampleJavaRenderers.TestRendererThrowingException");
try {
def.render(dummyCmp, sw);
fail("Should be able to catch exceptions during rendering.");
} catch (AuraExecutionException e) {
// The thrown Exception should be AuraExecutionException, but we should still have the ArithemeticException
// with the correct message for the cause
checkExceptionFull(e.getCause(), ArithmeticException.class, "From TestRendererThrowingException");
}
// Make sure QuickFixExceptions are not swallowed
def = createRenderer("java://org.auraframework.impl.renderer.sampleJavaRenderers.TestRendererThrowsQFEDuringRender");
try {
def.render(dummyCmp, sw);
fail("Should be able to catch QuickFixExceptions during rendering.");
} catch (Exception e) {
checkExceptionFull(e, InvalidDefinitionException.class, "From TestRendererThrowsQFEDuringRender");
}
}