use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MultiItemConfiguredXpathQueryTest method testResolveXpath_EmptyResults_Allowed_EmptyValues.
@Test
public void testResolveXpath_EmptyResults_Allowed_EmptyValues() throws Exception {
MultiItemConfiguredXpathQuery query = init(create(), XPATH_EMPTY_NODES);
query.setAllowEmptyResults(Boolean.TRUE);
Document doc = XmlHelper.createDocument(XML_WITH_EMPTY_NODES);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_WITH_EMPTY_NODES);
MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg));
assertEquals("|||91/01|91/01|91/01", result.getValue());
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MultiItemConfiguredXpathQueryTest method testResolveNodesAsString.
@Test
public void testResolveNodesAsString() throws Exception {
MultiItemConfiguredXpathQuery query = new MultiItemConfiguredXpathQuery("result", "//PXREF1[string-length(text()) > 0]", "");
query.setAsXmlString(true);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_WITH_EMPTY_NODES);
MetadataElement result = query.resolveXpath(XmlHelper.createDocument(msg.getContent()), new XPath(), query.createXpathQuery(msg));
assertEquals("<PXREF1>91/01</PXREF1>\n" + "<PXREF1>91/01</PXREF1>\n" + "<PXREF1>91/01</PXREF1>", result.getValue().strip());
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MultiItemMetadataXpathQueryTest method testResolveXpath_EmptyResults_NotAllowed.
@Test
public void testResolveXpath_EmptyResults_NotAllowed() throws Exception {
MultiItemMetadataXpathQuery query = init(create());
Document doc = XmlHelper.createDocument(XML);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
msg.addMetadata("xpathMetadataKey", "//@MissingAttribute");
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 MultiItemMetadataXpathQueryTest method testResolveNodesAsString.
@Test
public void testResolveNodesAsString() throws Exception {
MultiItemMetadataXpathQuery query = new MultiItemMetadataXpathQuery("result", "xpathMetadataKey", "");
query.setAsXmlString(true);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(MultiItemConfiguredXpathQueryTest.XML_WITH_EMPTY_NODES);
msg.addMetadata("xpathMetadataKey", "//PXREF1[string-length(text()) > 0]");
MetadataElement result = query.resolveXpath(XmlHelper.createDocument(msg.getContent()), new XPath(), query.createXpathQuery(msg));
assertEquals("<PXREF1>91/01</PXREF1>\n" + "<PXREF1>91/01</PXREF1>\n" + "<PXREF1>91/01</PXREF1>", result.getValue().strip());
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MultiItemMetadataXpathQueryTest method testResolveXpath_EmptyResults_Allowed.
@Test
public void testResolveXpath_EmptyResults_Allowed() throws Exception {
MultiItemMetadataXpathQuery query = init(create());
query.setAllowEmptyResults(Boolean.TRUE);
Document doc = XmlHelper.createDocument(XML);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
msg.addMetadata("xpathMetadataKey", "//@MissingAttribute");
MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg));
assertEquals("", result.getValue());
}
Aggregations