MultiItemMetadataXpathQuery extends MetadataXpathQueryImpl implements XpathQuery { @Override public MetadataElement resolveXpath(Document doc, XPath xpath, String expr) throws CoreException { return new MetadataElement(getMetadataKey(), XpathQueryHelper.resolveMultipleTextItems(doc, xpath, expr, allowEmptyResults(), getSeparator())); } MultiItemMetadataXpathQuery();  MultiItemMetadataXpathQuery(String metadataKey, String xpathMetadataKey);  MultiItemMetadataXpathQuery(String metadataKey, String xpathMetadataKey, String separator); @Override MetadataElement resolveXpath(Document doc, XPath xpath, String expr); String getSeparator(); void setSeparator(String s);  }
@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", " try { MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg)); fail(); } catch (CoreException expected) { } }
@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", " MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg)); assertEquals("", result.getValue()); }
@Test public void testResolveXpath() throws Exception { MultiItemMetadataXpathQuery query = init(create()); Document doc = XmlHelper.createDocument(XML); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML); msg.addMetadata("xpathMetadataKey", " MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg)); assertEquals("two|three", result.getValue()); }