### Question:
MessageEndpointProxy implements MessageListener, MessageEndpoint { public void onMessage(Message message) { LOG.trace("Invoking MessageEndpoint.onMethod()"); state.onMessage(this, message); } MessageEndpointProxy(MessageEndpoint endpoint); void beforeDelivery(Method method); void onMessage(Message message); void afterDelivery(); void release(); String toString();  }### Answer:
@Test(timeout = 60000) public void testOnMessageFailure() throws Exception { setupBeforeDeliverySuccessful(); context.checking(new Expectations() {{ oneOf (mockEndpointAndListener).onMessage(with(same(stubMessage))); will(throwException(new RuntimeException())); }}); setupAfterDeliverySuccessful(); doBeforeDeliveryExpectSuccess(); try { endpointProxy.onMessage(stubMessage); fail("An exception should have been thrown"); } catch (Exception e) { assertTrue(true); } doAfterDeliveryExpectSuccess(); }