Search in sources :

Example 6 with XpathObjectQuery

use of com.adaptris.core.services.metadata.xpath.XpathObjectQuery in project interlok by adaptris.

the class XpathObjectMetadataServiceTest method testDoService_NotXML.

@Test
public void testDoService_NotXML() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("ABCDEFG");
    XpathObjectMetadataService service = new XpathObjectMetadataService();
    service.setXpathQueries(new ArrayList<XpathObjectQuery>(Arrays.asList(new ConfiguredXpathQuery("source", "//source-id"), new ConfiguredXpathQuery("destination", "//destination-id"))));
    try {
        execute(service, msg);
        fail();
    } catch (ServiceException expected) {
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) XpathObjectQuery(com.adaptris.core.services.metadata.xpath.XpathObjectQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) Test(org.junit.Test)

Example 7 with XpathObjectQuery

use of com.adaptris.core.services.metadata.xpath.XpathObjectQuery in project interlok by adaptris.

the class XpathObjectMetadataServiceTest method testDoService_UsingXpathQuery_WithNamespaceContext.

@Test
public void testDoService_UsingXpathQuery_WithNamespaceContext() throws CoreException {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_WITH_NAMESPACE);
    XpathObjectMetadataService service = new XpathObjectMetadataService();
    service.setXpathQueries(new ArrayList<XpathObjectQuery>(Arrays.asList(new ConfiguredXpathNodeQuery("failureCount", "/svrl:schematron-output/svrl:failed-assert"))));
    service.setNamespaceContext(createContextEntries());
    execute(service, msg);
    assertFalse(msg.containsKey("failureCount"));
    assertTrue(msg.getObjectHeaders().containsKey("failureCount"));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) XpathObjectQuery(com.adaptris.core.services.metadata.xpath.XpathObjectQuery) ConfiguredXpathNodeQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathNodeQuery) Test(org.junit.Test)

Aggregations

XpathObjectQuery (com.adaptris.core.services.metadata.xpath.XpathObjectQuery)7 Test (org.junit.Test)4 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 ConfiguredXpathNodeQuery (com.adaptris.core.services.metadata.xpath.ConfiguredXpathNodeQuery)3 ServiceException (com.adaptris.core.ServiceException)2 ConfiguredXpathQuery (com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery)2 CoreException (com.adaptris.core.CoreException)1 ConfiguredXpathNodeListQuery (com.adaptris.core.services.metadata.xpath.ConfiguredXpathNodeListQuery)1 MetadataXpathNodeListQuery (com.adaptris.core.services.metadata.xpath.MetadataXpathNodeListQuery)1 MetadataXpathNodeQuery (com.adaptris.core.services.metadata.xpath.MetadataXpathNodeQuery)1 XpathQuery (com.adaptris.core.services.metadata.xpath.XpathQuery)1 DocumentBuilderFactoryBuilder (com.adaptris.core.util.DocumentBuilderFactoryBuilder)1 SimpleNamespaceContext (com.adaptris.util.text.xml.SimpleNamespaceContext)1 XPath (com.adaptris.util.text.xml.XPath)1 ArrayList (java.util.ArrayList)1 NamespaceContext (javax.xml.namespace.NamespaceContext)1 Document (org.w3c.dom.Document)1