use of com.adaptris.util.text.xml.ReplaceNode in project interlok by adaptris.
the class ExceptionReportServiceTest method testNoObjectMetadata.
@Test
public void testNoObjectMetadata() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
ExceptionReportService service = new ExceptionReportService(new ExceptionAsXml().withExceptionGenerator(new SimpleExceptionReport()).withDocumentMerge(new ReplaceNode(XPATH_ORIGINAL_NODE)));
execute(service, msg);
assertEquals(XML_PAYLOAD, msg.getContent());
XmlUtils xml = XmlHelper.createXmlUtils(msg);
assertEquals(RAW_DATA, xml.getSingleTextItem(XPATH_ORIGINAL_NODE));
}
use of com.adaptris.util.text.xml.ReplaceNode in project interlok by adaptris.
the class ExceptionReportServiceTest method testNonXml.
@Test
public void testNonXml() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(RAW_DATA);
msg.addObjectHeader(CoreConstants.OBJ_METADATA_EXCEPTION, new Exception("This is the exception"));
ExceptionReportService service = new ExceptionReportService(new ExceptionAsXml().withExceptionGenerator(new SimpleExceptionReport()).withDocumentMerge(new ReplaceNode(XPATH_ORIGINAL_NODE)));
try {
execute(service, msg);
fail("success with non-xml payload");
} catch (ServiceException expected) {
;
}
}
use of com.adaptris.util.text.xml.ReplaceNode in project interlok by adaptris.
the class ExceptionReportServiceTest method testReplaceNode.
@Test
public void testReplaceNode() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
msg.addObjectHeader(CoreConstants.OBJ_METADATA_EXCEPTION, new Exception("This is the exception"));
ExceptionReportService service = new ExceptionReportService(new ExceptionAsXml().withExceptionGenerator(new SimpleExceptionReport()).withDocumentMerge(new ReplaceNode(XPATH_ORIGINAL_NODE)).withDocumentFactoryConfig(DocumentBuilderFactoryBuilder.newInstance()));
execute(service, msg);
assertNotSame(XML_PAYLOAD, msg.getContent());
XmlUtils xml = XmlHelper.createXmlUtils(msg);
assertNotSame(RAW_DATA, xml.getSingleNode(XPATH_ORIGINAL_NODE));
assertEquals("UTF-8", msg.getContentEncoding());
}
Aggregations