use of com.adaptris.util.text.xml.XPath 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.util.text.xml.XPath 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.util.text.xml.XPath 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.util.text.xml.XPath 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());
}
use of com.adaptris.util.text.xml.XPath in project interlok by adaptris.
the class MultiItemMetadataXpathQueryTest method testResolveXpath.
@Test
public void testResolveXpath() throws Exception {
MultiItemMetadataXpathQuery query = init(create());
Document doc = XmlHelper.createDocument(XML);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
msg.addMetadata("xpathMetadataKey", "//extra[@att='multi']");
MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg));
assertEquals("two|three", result.getValue());
}
Aggregations