Message msg1 = createMessage(INPUT_1);
Message msg2 = createMessage(INPUT_2);
MessageContext mc = new MessageContext();
mc.setMessage(msg1);
SoapMessageContext soapCtx = MessageContextFactory.createSoapMessageContext(mc);
SOAPMessage m1 = soapCtx.getMessage();
SOAPMessage m2 = soapCtx.getMessage();
assertTrue("retrieval of message from SoapMessageContext twice in a row should result in same object", m1 == m2);
// let's change underlying message as
// HandlerChainProcessor.convertToFaultMessage() does
mc.setMessage(msg2);
SOAPMessage m3 = soapCtx.getMessage();
SOAPMessage m4 = soapCtx.getMessage();
assertTrue("retrieval of message from SoapMessageContext twice in a row should result in same object", m3 == m4);
// Soap messages from before and after must be different!
assertTrue("retrieval of message from SoapMessageContext after message has changed in the underlying context", m1 != m3);