@Test(expected=MessageFormatException.class) public void testGetObjectWithFailedDeserialisationThrowsJMSMFE() throws Exception { JmsObjectMessageFacade facade = Mockito.mock(JmsTestObjectMessageFacade.class); Mockito.when(facade.getObject()).thenThrow(new ClassCastException("Failed to get object")); JmsObjectMessage objectMessage = new JmsObjectMessage(facade); objectMessage.getObject(); }
@Override public Serializable getObject() throws JMSException { try { return this.facade.getObject(); } catch (Exception e) { MessageFormatException jmsEx = new MessageFormatException("Failed to read object: " + e.getMessage()); jmsEx.setLinkedException(e); jmsEx.initCause(e); throw jmsEx; } }
JmsObjectMessage extends JmsMessage implements ObjectMessage { @Override public Serializable getObject() throws JMSException { try { return this.facade.getObject(); } catch (Exception e) { MessageFormatException jmsEx = new MessageFormatException("Failed to read object: " + e.getMessage()); jmsEx.setLinkedException(e); jmsEx.initCause(e); throw jmsEx; } } }
JmsObjectMessage extends JmsMessage implements ObjectMessage { @Override public Serializable getObject() throws JMSException { try { return this.facade.getObject(); } catch (Exception e) { MessageFormatException jmsEx = new MessageFormatException("Failed to read object: " + e.getMessage()); jmsEx.setLinkedException(e); jmsEx.initCause(e); throw jmsEx; } } JmsObjectMessage(JmsObjectMessageFacade facade); }
JmsObjectMessage extends JmsMessage implements ObjectMessage { @Override public Serializable getObject() throws JMSException { try { return this.facade.getObject(); } catch (Exception e) { MessageFormatException jmsEx = new MessageFormatException("Failed to read object: " + e.getMessage()); jmsEx.setLinkedException(e); jmsEx.initCause(e); throw jmsEx; } } JmsObjectMessage(JmsObjectMessageFacade facade); @Override JmsObjectMessage copy(); @Override void setObject(Serializable newObject); @Override Serializable getObject(); @Override boolean isBodyAssignableTo(@SuppressWarnings("rawtypes") Class target); @Override String toString(); }
JmsObjectMessage extends JmsMessage implements ObjectMessage { @Override public Serializable getObject() throws JMSException { try { return this.facade.getObject(); } catch (Exception e) { MessageFormatException jmsEx = new MessageFormatException("Failed to read object: " + e.getMessage()); jmsEx.setLinkedException(e); jmsEx.initCause(e); throw jmsEx; } } JmsObjectMessage(JmsObjectMessageFacade facade); @Override JmsObjectMessage copy(); @Override void setObject(Serializable newObject); @Override Serializable getObject(); @Override boolean isBodyAssignableTo(@SuppressWarnings("rawtypes") Class target); @Override String toString();  }