XpathMetadataService extends MetadataServiceImpl { public void setXpathQueries(List<XpathQuery> xql) { xpathQueries = Args.notNull(xql, "xpathQueries"); } XpathMetadataService(); @Override void doService(AdaptrisMessage msg); KeyValuePairSet getNamespaceContext(); void setNamespaceContext(KeyValuePairSet namespaceContext); List<XpathQuery> getXpathQueries(); void setXpathQueries(List<XpathQuery> xql); void addXpathQuery(XpathQuery query); DocumentBuilderFactoryBuilder getXmlDocumentFactoryConfig(); void setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml);  }
@Test public void testDoService_NotXML() throws Exception { AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("ABCDEFG"); XpathMetadataService service = new XpathMetadataService().withMetadataLogger(new TruncateMetadata(20)); service.setXpathQueries(new ArrayList<XpathQuery>(Arrays.asList(new ConfiguredXpathQuery("source", " try { execute(service, msg); fail(); } catch (ServiceException expected) { } }
@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", " execute(service, msg); assertEquals("partnera", msg.getMetadataValue("source")); assertEquals("partnerb", msg.getMetadataValue("destination")); }