use of com.adaptris.core.util.DocumentBuilderFactoryBuilder 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.util.DocumentBuilderFactoryBuilder in project interlok by adaptris.
the class XpathQueryHelperTest method resolveSingleNode_Missing_AllowEmptyTrue.
@Test
public void resolveSingleNode_Missing_AllowEmptyTrue() throws Exception {
DocumentBuilderFactoryBuilder builder = DocumentBuilderFactoryBuilder.newInstance();
Document doc = XmlHelper.createDocument(XpathQueryCase.XML, builder);
XPath xpathToUse = XPath.newXPathInstance(builder, null);
assertNull(XpathQueryHelper.resolveSingleNode(doc, xpathToUse, "//@MissingAttribute", true));
}
use of com.adaptris.core.util.DocumentBuilderFactoryBuilder in project interlok by adaptris.
the class XpathQueryHelperTest method testResolveSingleTextItem_Missing_AllowEmptyFalse.
@Test(expected = CoreException.class)
public void testResolveSingleTextItem_Missing_AllowEmptyFalse() throws Exception {
DocumentBuilderFactoryBuilder builder = DocumentBuilderFactoryBuilder.newInstance();
Document doc = XmlHelper.createDocument(XpathQueryCase.XML, builder);
XPath xpathToUse = XPath.newXPathInstance(builder, null);
XpathQueryHelper.resolveSingleTextItem(doc, xpathToUse, "//@MissingAttribute", false);
}
use of com.adaptris.core.util.DocumentBuilderFactoryBuilder in project interlok by adaptris.
the class XpathQueryHelperTest method testResolveMultipleTextItems_Missing_AllowEmptyFalse.
@Test(expected = CoreException.class)
public void testResolveMultipleTextItems_Missing_AllowEmptyFalse() throws Exception {
DocumentBuilderFactoryBuilder builder = DocumentBuilderFactoryBuilder.newInstance();
Document doc = XmlHelper.createDocument(XpathQueryCase.XML, builder);
XPath xpathToUse = XPath.newXPathInstance(builder, null);
XpathQueryHelper.resolveMultipleTextItems(doc, xpathToUse, "//@MissingAttribute", false, "|");
}
use of com.adaptris.core.util.DocumentBuilderFactoryBuilder in project interlok by adaptris.
the class XpathQueryHelperTest method testResolveMultipleNode_Missing_AllowEmptyFalse.
@Test(expected = CoreException.class)
public void testResolveMultipleNode_Missing_AllowEmptyFalse() throws Exception {
DocumentBuilderFactoryBuilder builder = DocumentBuilderFactoryBuilder.newInstance();
Document doc = XmlHelper.createDocument(XpathQueryCase.XML, builder);
XPath xpathToUse = XPath.newXPathInstance(builder, null);
XpathQueryHelper.resolveNodeList(doc, xpathToUse, "//@MissingAttribute", false);
}
Aggregations