Search in sources :

Example 11 with ConfiguredXpathQuery

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

the class XpathObjectMetadataServiceTest method testAddXpathQuery.

@Test
public void testAddXpathQuery() {
    XpathObjectMetadataService service = new XpathObjectMetadataService();
    service.setXmlDocumentFactoryConfig(null);
    ConfiguredXpathQuery query = new ConfiguredXpathQuery("failureCount", "count(/svrl:schematron-output/svrl:failed-assert)");
    service.addXpathQuery(query);
    assertEquals(1, service.getXpathQueries().size());
    assertEquals(query, service.getXpathQueries().get(0));
    try {
        service.addXpathQuery(null);
        fail();
    } catch (IllegalArgumentException expected) {
    }
    assertEquals(1, service.getXpathQueries().size());
    assertEquals(query, service.getXpathQueries().get(0));
}
Also used : ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) Test(org.junit.Test)

Example 12 with ConfiguredXpathQuery

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

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

the class XpathMetadataServiceTest method testAddXpathQuery.

@Test
public void testAddXpathQuery() {
    XpathMetadataService service = new XpathMetadataService();
    ConfiguredXpathQuery query = new ConfiguredXpathQuery("failureCount", "count(/svrl:schematron-output/svrl:failed-assert)");
    service.addXpathQuery(query);
    assertEquals(1, service.getXpathQueries().size());
    assertEquals(query, service.getXpathQueries().get(0));
    try {
        service.addXpathQuery(null);
        fail();
    } catch (IllegalArgumentException expected) {
    }
    assertEquals(1, service.getXpathQueries().size());
    assertEquals(query, service.getXpathQueries().get(0));
}
Also used : MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) Test(org.junit.Test)

Example 14 with ConfiguredXpathQuery

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

the class XpathMetadataServiceTest method testDoService_UsingXpathQuery.

@Test
public void testDoService_UsingXpathQuery() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
    XpathMetadataService service = new XpathMetadataService();
    service.setXpathQueries(new ArrayList<XpathQuery>(Arrays.asList(new ConfiguredXpathQuery("source", "//source-id"), new ConfiguredXpathQuery("destination", "//destination-id"))));
    execute(service, msg);
    assertEquals("partnera", msg.getMetadataValue("source"));
    assertEquals("partnerb", msg.getMetadataValue("destination"));
}
Also used : XpathQuery(com.adaptris.core.services.metadata.xpath.XpathQuery) MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) MetadataXpathQuery(com.adaptris.core.services.metadata.xpath.MetadataXpathQuery) MultiItemMetadataXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemMetadataXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) Test(org.junit.Test)

Aggregations

ConfiguredXpathQuery (com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery)14 Test (org.junit.Test)12 MultiItemConfiguredXpathQuery (com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery)10 XpathQuery (com.adaptris.core.services.metadata.xpath.XpathQuery)10 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)8 MetadataXpathQuery (com.adaptris.core.services.metadata.xpath.MetadataXpathQuery)8 MultiItemMetadataXpathQuery (com.adaptris.core.services.metadata.xpath.MultiItemMetadataXpathQuery)8 ServiceException (com.adaptris.core.ServiceException)4 XpathObjectQuery (com.adaptris.core.services.metadata.xpath.XpathObjectQuery)2 DocumentBuilderFactoryBuilder (com.adaptris.core.util.DocumentBuilderFactoryBuilder)2 ArrayList (java.util.ArrayList)2 LogMessageService (com.adaptris.core.services.LogMessageService)1 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)1 XpathMetadataService (com.adaptris.core.services.metadata.XpathMetadataService)1 TruncateMetadata (com.adaptris.core.util.TruncateMetadata)1 KeyValuePair (com.adaptris.util.KeyValuePair)1