@Test(timeout = 60000)
public void testAfterDeliveryFailure() throws Exception {

    setupBeforeDeliverySuccessful();
    setupOnMessageSuccessful();
    context.checking(new Expectations() {{
        oneOf (mockEndpointAndListener).afterDelivery(); will(throwException(new ResourceException()));
    }});
    setupExpectRelease();
    doBeforeDeliveryExpectSuccess();
    doOnMessageExpectSuccess();
    try {
        endpointProxy.afterDelivery();
        fail("An exception should have been thrown");
    } catch (Exception e) {
        assertTrue(true);
    }
    doFullyDeadCheck();
}