### Question:
MessageEndpointProxy implements MessageListener, MessageEndpoint { public void afterDelivery() throws ResourceException { LOG.trace("Invoking MessageEndpoint.afterDelivery()"); state.afterDelivery(this); } MessageEndpointProxy(MessageEndpoint endpoint); void beforeDelivery(Method method); void onMessage(Message message); void afterDelivery(); void release(); String toString();  }### Answer:
@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(); }