use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class ExceptionReportServiceTest method testDefaults.
@Override
public void testDefaults() 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());
execute(service, msg);
assertNotSame(XML_PAYLOAD, msg.getContent());
XmlUtils xml = XmlHelper.createXmlUtils(msg);
assertNotNull(RAW_DATA, xml.getSingleNode("/Exception"));
assertEquals("UTF-8", msg.getContentEncoding());
}
use of com.adaptris.util.XmlUtils 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.XmlUtils in project interlok by adaptris.
the class ExceptionReportServiceTest method testBug2356.
@Test
public void testBug2356() throws Exception {
ServiceImp failingService = new ThrowExceptionService(new ConfiguredException("Fail"));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
ExceptionReportService service = new ExceptionReportService(new ExceptionAsXml().withExceptionGenerator(new SimpleExceptionReport()).withDocumentMerge(new InsertNode(XPATH_ROOT)));
MockMessageProducer mockProducer = new MockMessageProducer();
StandardProcessingExceptionHandler speh = new StandardProcessingExceptionHandler(new ServiceList(new Service[] { service, new StandaloneProducer(mockProducer) }));
MockChannel channel = new MockChannel();
MockMessageConsumer consumer = new MockMessageConsumer();
StandardWorkflow wf = new StandardWorkflow();
wf.getServiceCollection().add(failingService);
wf.setConsumer(consumer);
channel.setMessageErrorHandler(speh);
channel.getWorkflowList().add(wf);
try {
channel.prepare();
channel.requestStart();
consumer.submitMessage(msg);
assertEquals(1, mockProducer.getMessages().size());
AdaptrisMessage failedMessage = mockProducer.getMessages().get(0);
assertNotSame(XML_PAYLOAD, failedMessage.getContent());
XmlUtils xml = XmlHelper.createXmlUtils(failedMessage);
assertEquals(RAW_DATA, xml.getSingleTextItem(XPATH_ORIGINAL_NODE));
assertNotNull(xml.getSingleNode(XPATH_ROOT + "/Exception"));
String xmlElement = xml.getSingleTextItem(XPATH_ROOT + "/Exception");
assertTrue(xmlElement.contains("com.adaptris.core.services.exception.ThrowExceptionService.doService"));
} finally {
channel.requestClose();
}
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class ExceptionReportServiceTest method testBug2220.
@Test
public void testBug2220() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD, "UTF-8");
msg.addObjectHeader(CoreConstants.OBJ_METADATA_EXCEPTION, new Exception("I had problems parsing <ABCDE>"));
ExceptionReportService service = new ExceptionReportService(new ExceptionAsXml().withExceptionGenerator(new SimpleExceptionReport("Exception")).withDocumentMerge(new InsertNode(XPATH_ROOT)));
execute(service, msg);
assertNotSame(XML_PAYLOAD, msg.getContent());
XmlUtils xml = XmlHelper.createXmlUtils(msg);
assertEquals(RAW_DATA, xml.getSingleTextItem(XPATH_ORIGINAL_NODE));
assertNotNull(xml.getSingleNode(XPATH_ROOT + "/Exception"));
assertEquals("UTF-8", msg.getContentEncoding());
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class XmlExceptionReportTest method testWithStacktrace.
@Test
public void testWithStacktrace() throws Exception {
XmlReportWithStacktrace reporter = new XmlReportWithStacktrace();
Document d = reporter.create(new Exception("testWithStacktrace"), "myWorkflow", "ThrowExceptionService");
assertNotNull(d);
new XmlUtils().writeDocument(d, System.err);
}
Aggregations