use of com.adaptris.core.services.metadata.xpath.XpathQuery in project interlok by adaptris.
the class XpathMetadataServiceTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
XpathMetadataService service = new XpathMetadataService();
service.setXpathQueries(new ArrayList<XpathQuery>(Arrays.asList(new ConfiguredXpathQuery("key1", "//source-id"), new ConfiguredXpathQuery("key2", "//destination-id"), new MetadataXpathQuery("key3", "metadataKey_containing_an_XPath"), new MultiItemConfiguredXpathQuery("key4", "//xpath/that/resolves/to/multiple/items"), new MultiItemMetadataXpathQuery("key5", "metadata_containing_an_Xpath_that_resolves_to_multiple_items"), new ConfiguredXpathQuery("key6", "/svrl:output/svrl:value"))));
service.setNamespaceContext(createContextEntries());
return service;
}
use of com.adaptris.core.services.metadata.xpath.XpathQuery in project interlok by adaptris.
the class XpathMetadataServiceTest method testDoService_DocType_DefaultBehaviour.
@Test
public void testDoService_DocType_DefaultBehaviour() throws CoreException {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_WITH_DOCTYPE);
// Default document factory should disable doctyps.
XpathMetadataService service = new XpathMetadataService();
// Shouldn't matter what the query actually is.
service.setXpathQueries(new ArrayList<XpathQuery>(Arrays.asList(new ConfiguredXpathQuery("source", "//source-id"), new ConfiguredXpathQuery("destination", "//destination-id"))));
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
assertTrue(expected.getMessage().contains("DOCTYPE is disallowed"));
}
}
use of com.adaptris.core.services.metadata.xpath.XpathQuery in project interlok by adaptris.
the class XpathMetadataServiceTest method testDoService_DisableDocType.
@Test
public void testDoService_DisableDocType() throws CoreException {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_WITH_DOCTYPE);
XpathMetadataService service = new XpathMetadataService();
// Shouldn't matter what the query actually is.
service.setXpathQueries(new ArrayList<XpathQuery>(Arrays.asList(new ConfiguredXpathQuery("source", "//source-id"), new ConfiguredXpathQuery("destination", "//destination-id"))));
DocumentBuilderFactoryBuilder builder = new DocumentBuilderFactoryBuilder();
builder.getFeatures().add(new KeyValuePair("http://apache.org/xml/features/disallow-doctype-decl", "true"));
service.setXmlDocumentFactoryConfig(builder);
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
assertTrue(expected.getMessage().contains("DOCTYPE is disallowed"));
}
}
use of com.adaptris.core.services.metadata.xpath.XpathQuery in project interlok by adaptris.
the class XpathObjectMetadataServiceTest method testSetXpathQueryList.
@Test
public void testSetXpathQueryList() {
XpathObjectMetadataService service = new XpathObjectMetadataService();
assertEquals(0, service.getXpathQueries().size());
XpathQuery query = new ConfiguredXpathQuery("metadataKey", "//root");
List<XpathObjectQuery> list = new ArrayList<>();
list.add(query);
service.setXpathQueries(list);
assertEquals(list, service.getXpathQueries());
try {
service.setXpathQueries(null);
fail();
} catch (IllegalArgumentException e) {
}
assertEquals(list, service.getXpathQueries());
}
use of com.adaptris.core.services.metadata.xpath.XpathQuery in project interlok by adaptris.
the class XpathMetadataService method initService.
@Override
protected void initService() throws CoreException {
for (XpathQuery query : xpathQueries) {
query.verify();
}
queriesToExecute = new ArrayList<>();
queriesToExecute.addAll(getXpathQueries());
}
Aggregations