@Test public void testSetObjectWithNonSerializableThrowsJMSMFE() throws Exception { Map<String, Object> origMap = new HashMap<String, Object>(); origMap.put("key1", "value1"); origMap.put("notSerializable", new NotSerializable()); JmsObjectMessage objectMessage = factory.createObjectMessage(); try { objectMessage.setObject((Serializable) origMap); fail("Expected exception to be thrown"); } catch (MessageFormatException mfe) { } }
@Override public void setObject(Serializable newObject) throws JMSException { checkReadOnlyBody(); try { this.facade.setObject(newObject); } catch (Exception e) { MessageFormatException jmsEx = new MessageFormatException("Failed to serialize object:" + e.getMessage()); jmsEx.setLinkedException(e); jmsEx.initCause(e); throw jmsEx; } }
JmsObjectMessage extends JmsMessage implements ObjectMessage { @Override public void setObject(Serializable newObject) throws JMSException { checkReadOnlyBody(); try { this.facade.setObject(newObject); } catch (Exception e) { MessageFormatException jmsEx = new MessageFormatException("Failed to serialize object:" + e.getMessage()); jmsEx.setLinkedException(e); jmsEx.initCause(e); throw jmsEx; } } }
JmsObjectMessage extends JmsMessage implements ObjectMessage { @Override public void setObject(Serializable newObject) throws JMSException { checkReadOnlyBody(); try { this.facade.setObject(newObject); } catch (Exception e) { MessageFormatException jmsEx = new MessageFormatException("Failed to serialize object:" + e.getMessage()); jmsEx.setLinkedException(e); jmsEx.initCause(e); throw jmsEx; } } JmsObjectMessage(JmsObjectMessageFacade facade); }
JmsObjectMessage extends JmsMessage implements ObjectMessage { @Override public void setObject(Serializable newObject) throws JMSException { checkReadOnlyBody(); try { this.facade.setObject(newObject); } catch (Exception e) { MessageFormatException jmsEx = new MessageFormatException("Failed to serialize 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 void setObject(Serializable newObject) throws JMSException { checkReadOnlyBody(); try { this.facade.setObject(newObject); } catch (Exception e) { MessageFormatException jmsEx = new MessageFormatException("Failed to serialize 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();  }