Search in sources :

Example 1 with ConfiguredXpathNodeQuery

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

the class XpathObjectMetadataServiceTest method testDoService_UsingXpathQuery.

@Test
public void testDoService_UsingXpathQuery() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
    XpathObjectMetadataService service = new XpathObjectMetadataService();
    service.setXpathQueries(new ArrayList<XpathObjectQuery>(Arrays.asList(new ConfiguredXpathNodeQuery("source", "//source-id"), new ConfiguredXpathNodeQuery("destination", "//destination-id"))));
    execute(service, msg);
    assertFalse(msg.containsKey("source"));
    assertFalse(msg.containsKey("destination"));
    assertTrue(msg.getObjectHeaders().containsKey("source"));
    assertTrue(msg.getObjectHeaders().containsKey("destination"));
}
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)

Example 2 with ConfiguredXpathNodeQuery

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

the class XpathObjectMetadataServiceTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    XpathObjectMetadataService service = new XpathObjectMetadataService();
    service.setXpathQueries(new ArrayList<XpathObjectQuery>(Arrays.asList(new ConfiguredXpathNodeQuery("key1", "//source-id"), new ConfiguredXpathNodeListQuery("key3", "//xpath/that/resolves/to/multiple/items"), new MetadataXpathNodeQuery("key4", "metadata_containing_an_xpath"), new MetadataXpathNodeListQuery("key5", "metadata_containing_a_nodelist_xpath"))));
    service.setNamespaceContext(createContextEntries());
    return service;
}
Also used : XpathObjectQuery(com.adaptris.core.services.metadata.xpath.XpathObjectQuery) MetadataXpathNodeListQuery(com.adaptris.core.services.metadata.xpath.MetadataXpathNodeListQuery) ConfiguredXpathNodeListQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathNodeListQuery) MetadataXpathNodeQuery(com.adaptris.core.services.metadata.xpath.MetadataXpathNodeQuery) ConfiguredXpathNodeQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathNodeQuery)

Example 3 with ConfiguredXpathNodeQuery

use of com.adaptris.core.services.metadata.xpath.ConfiguredXpathNodeQuery 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

ConfiguredXpathNodeQuery (com.adaptris.core.services.metadata.xpath.ConfiguredXpathNodeQuery)3 XpathObjectQuery (com.adaptris.core.services.metadata.xpath.XpathObjectQuery)3 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 Test (org.junit.Test)2 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