use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MetadataXpathQueryTest method testResolveXpath_NamespaceWithNamespaceContext.
// Invalid test
// Namedspaced document with non-namespace xpath never matches with SAXON
// public void testResolveXpath_NamespaceNoNamespaceContext() throws Exception {
// MetadataXpathQuery query = init(create());
// Document doc = XmlHelper.createDocument(XML_WITH_NAMESPACE);
// AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_WITH_NAMESPACE);
// msg.addMetadata("xpathMetadataKey", "count(/schematron-output/failed-assert)");
// MetadataElement result = query.resolveXpath(doc, null, query.createXpathQuery(msg));
// assertEquals("2", result.getValue());
// }
@Test
public void testResolveXpath_NamespaceWithNamespaceContext() throws Exception {
MetadataXpathQuery query = init(create());
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_WITH_NAMESPACE);
msg.addMetadata("xpathMetadataKey", "count(/svrl:schematron-output/svrl:failed-assert)");
StaticNamespaceContext ctx = new StaticNamespaceContext();
Document doc = XmlHelper.createDocument(XML_WITH_NAMESPACE, ctx);
MetadataElement result = query.resolveXpath(doc, new XPath(ctx), query.createXpathQuery(msg));
assertEquals("2", result.getValue());
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MetadataXpathQueryTest method testResolveXpath_Attribute.
@Test
public void testResolveXpath_Attribute() throws Exception {
MetadataXpathQuery query = init(create());
Document doc = XmlHelper.createDocument(XML);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
msg.addMetadata("xpathMetadataKey", "//@att");
MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg));
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MultiItemConfiguredXpathQueryTest method testResolveXpath.
@Test
public void testResolveXpath() throws Exception {
MultiItemConfiguredXpathQuery query = init(create(), "//extra[@att='multi']");
Document doc = XmlHelper.createDocument(XML);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg));
assertEquals("two|three", result.getValue());
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MultiItemConfiguredXpathQueryTest method testResolveXpath_EmptyResults_NotAllowed.
@Test
public void testResolveXpath_EmptyResults_NotAllowed() throws Exception {
MultiItemConfiguredXpathQuery query = init(create(), "//@MissingAttribute");
Document doc = XmlHelper.createDocument(XML);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
try {
MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg));
fail();
} catch (CoreException expected) {
}
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MultiItemConfiguredXpathQueryTest method testResolveXpath_EmptyResults_Allowed.
@Test
public void testResolveXpath_EmptyResults_Allowed() throws Exception {
MultiItemConfiguredXpathQuery query = init(create(), "//@MissingAttribute");
query.setAllowEmptyResults(Boolean.TRUE);
Document doc = XmlHelper.createDocument(XML);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg));
assertEquals("", result.getValue());
}
Aggregations