* @throws Exception
*/
public void testGetAndSetFaultPayloadAsSource() throws Exception {
LogicalMessageContext lmc = createSampleFaultContext();
LogicalMessage msg = lmc.getMessage();
assertTrue("The returned LogicalMessage was null", msg != null);
Source payload = msg.getPayload();
assertTrue("The returned payload (Source) was null", payload != null);
String resultContent = _getStringFromSource(payload);
assertTrue("The content returned was null", resultContent != null);
assertTrue("The content returned was incorrect", resultContent.indexOf(FAULT_INPUT) > 0);
assertTrue("The content returned was incorrect, no fault found", resultContent.indexOf("Fault") > 0);
// Now manipluate the content and set it back on the message.
int start = resultContent.indexOf(FAULT_INPUT);
int end = start + FAULT_INPUT.length();
String newFaultInput = "new fault content goes here";
String newContent = resultContent.substring(0, start) + newFaultInput + resultContent.substring(end);
ByteArrayInputStream bais = new ByteArrayInputStream(newContent.getBytes());
StreamSource newPayload = new StreamSource(bais);
msg.setPayload(newPayload);
// Check the payload to make sure the new content that we added
// was insterted correctly.
Source payload2 = msg.getPayload();
assertTrue("The returned payload (Source) was null", payload2 != null);
String resultContent2 = _getStringFromSource(payload2);
assertTrue("The updated content returned was null", resultContent2 != null);
assertTrue("The updated content returned was incorrect, old content found", resultContent2.indexOf(FAULT_INPUT) < 0);