JmsResponseMessageCreator implements MessageCreator { @Override public Message createMessage(final Session session) throws JMSException { ObjectMessage message = session.createObjectMessage(); message.setObject(wilmaHttpResponse); message.setBooleanProperty("bodyDecompressed", bodyDecompressed); return message; } JmsResponseMessageCreator(final WilmaHttpResponse wilmaHttpResponse, final boolean bodyDecompressed); @Override Message createMessage(final Session session);  }
@Test(expectedExceptions = JMSException.class) public void testCreateMessageShouldThrowJmsExceptionWhenCanNotCreateObjectMessageFromSession() throws JMSException { given(session.createObjectMessage()).willThrow(new JMSException(NO_WILMA_LOGGER_ID)); underTest.createMessage(session); }
@Test(expectedExceptions = JMSException.class) public void testCreateMessageShouldThrowJmsExceptionWhenSetObjectThrowsJMSException() throws JMSException { given(session.createObjectMessage()).willReturn(objectMessage); willThrow(new JMSException(NO_WILMA_LOGGER_ID)).given(objectMessage).setObject(response); underTest.createMessage(session); }
@Test(expectedExceptions = JMSException.class) public void testCreateMessageShouldThrowJmsExceptionWhenSetBooleanPropertyThrowsJMSException() throws JMSException { given(session.createObjectMessage()).willReturn(objectMessage); willThrow(new JMSException(NO_WILMA_LOGGER_ID)).given(objectMessage).setBooleanProperty("bodyDecompressed", true); underTest.createMessage(session); }
@Test public void testCreateMessageShouldProperly() throws JMSException { given(session.createObjectMessage()).willReturn(objectMessage); Message result = underTest.createMessage(session); verify(objectMessage).setObject(response); assertEquals(result, objectMessage); }