Search in sources :

Example 21 with XmlUtils

use of com.adaptris.util.XmlUtils in project interlok by adaptris.

the class ExceptionReportServiceTest method testInsertNode.

@Test
public void testInsertNode() 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 InsertNode(XPATH_ROOT)).withXmlEncoding("UTF-8"));
    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());
}
Also used : XmlUtils(com.adaptris.util.XmlUtils) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceException(com.adaptris.core.ServiceException) CoreException(com.adaptris.core.CoreException) InsertNode(com.adaptris.util.text.xml.InsertNode) Test(org.junit.Test)

Example 22 with XmlUtils

use of com.adaptris.util.XmlUtils in project interlok by adaptris.

the class XmlExceptionReportTest method testNoStacktrace.

@Test
public void testNoStacktrace() throws Exception {
    XmlExceptionReport reporter = new XmlExceptionReport();
    Document d = reporter.create(new Exception("testNoStacktrace"), "myWorkflow", "ThrowExceptionService");
    assertNotNull(d);
    new XmlUtils().writeDocument(d, System.err);
}
Also used : XmlUtils(com.adaptris.util.XmlUtils) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 23 with XmlUtils

use of com.adaptris.util.XmlUtils in project interlok by adaptris.

the class XmlExceptionReportTest method testNoStacktraceNoWorkflow.

@Test
public void testNoStacktraceNoWorkflow() throws Exception {
    XmlExceptionReport reporter = new XmlExceptionReport();
    Document d = reporter.create(new Exception("testNoStacktraceNoWorkflow"), null, "ThrowExceptionService");
    assertNotNull(d);
    new XmlUtils().writeDocument(d, System.err);
}
Also used : XmlUtils(com.adaptris.util.XmlUtils) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 24 with XmlUtils

use of com.adaptris.util.XmlUtils in project interlok by adaptris.

the class XmlExceptionReportTest method testWithStacktraceNoWorkflow.

@Test
public void testWithStacktraceNoWorkflow() throws Exception {
    XmlReportWithStacktrace reporter = new XmlReportWithStacktrace();
    Document d = reporter.create(new Exception("testWithStacktraceNoWorkflow"), null, "ThrowExceptionService");
    assertNotNull(d);
    new XmlUtils().writeDocument(d, System.err);
}
Also used : XmlUtils(com.adaptris.util.XmlUtils) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 25 with XmlUtils

use of com.adaptris.util.XmlUtils in project interlok by adaptris.

the class ReplaceOriginalTest method testReplaceOriginal.

@Test
public void testReplaceOriginal() throws Exception {
    ReplaceOriginal rn = new ReplaceOriginal();
    Document merged = rn.merge(XmlHelper.createDocument(ORIGINAL), XmlHelper.createDocument(REPLACEMENT));
    XmlUtils xml = new XmlUtils();
    xml.setSource(merged);
    assertNull(xml.getSingleNode(XPATH_ORIGINAL_NODE));
    assertEquals(DATA_B, xml.getSingleTextItem(XPATH_NEW_NODE));
}
Also used : XmlUtils(com.adaptris.util.XmlUtils) Document(org.w3c.dom.Document) Test(org.junit.Test)

Aggregations

XmlUtils (com.adaptris.util.XmlUtils)41 Test (org.junit.Test)32 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)23 Document (org.w3c.dom.Document)13 InsertNode (com.adaptris.util.text.xml.InsertNode)8 CoreException (com.adaptris.core.CoreException)7 ServiceException (com.adaptris.core.ServiceException)4 Notification (javax.management.Notification)4 NamespaceContext (javax.xml.namespace.NamespaceContext)3 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)2 DocumentBuilderFactoryBuilder (com.adaptris.core.util.DocumentBuilderFactoryBuilder)2 ReplaceNode (com.adaptris.util.text.xml.ReplaceNode)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Element (org.w3c.dom.Element)2 Node (org.w3c.dom.Node)2 AdaptrisMessageFactory (com.adaptris.core.AdaptrisMessageFactory)1 Service (com.adaptris.core.Service)1 ServiceImp (com.adaptris.core.ServiceImp)1 ServiceList (com.adaptris.core.ServiceList)1