Search in sources :

Example 21 with DocumentBuilderFactoryBuilder

use of com.adaptris.core.util.DocumentBuilderFactoryBuilder in project interlok by adaptris.

the class XpathQueryHelperTest method testResolveSingleNode_Missing_AllowEmptyFalse.

@Test(expected = CoreException.class)
public void testResolveSingleNode_Missing_AllowEmptyFalse() throws Exception {
    DocumentBuilderFactoryBuilder builder = DocumentBuilderFactoryBuilder.newInstance();
    Document doc = XmlHelper.createDocument(XpathQueryCase.XML, builder);
    XPath xpathToUse = XPath.newXPathInstance(builder, null);
    XpathQueryHelper.resolveSingleNode(doc, xpathToUse, "//@MissingAttribute", false);
}
Also used : XPath(com.adaptris.util.text.xml.XPath) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 22 with DocumentBuilderFactoryBuilder

use of com.adaptris.core.util.DocumentBuilderFactoryBuilder in project interlok by adaptris.

the class XpathQueryHelperTest method testResolveSingleTextItem_Missing_AllowEmptyTrue.

@Test
public void testResolveSingleTextItem_Missing_AllowEmptyTrue() throws Exception {
    DocumentBuilderFactoryBuilder builder = DocumentBuilderFactoryBuilder.newInstance();
    Document doc = XmlHelper.createDocument(XpathQueryCase.XML, builder);
    XPath xpathToUse = XPath.newXPathInstance(builder, null);
    assertEquals("", XpathQueryHelper.resolveSingleTextItem(doc, xpathToUse, "//@MissingAttribute", true));
}
Also used : XPath(com.adaptris.util.text.xml.XPath) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 23 with DocumentBuilderFactoryBuilder

use of com.adaptris.core.util.DocumentBuilderFactoryBuilder in project interlok by adaptris.

the class XpathQueryHelperTest method resolveMultipleTextItems_Missing_AllowEmptyTrue.

@Test
public void resolveMultipleTextItems_Missing_AllowEmptyTrue() throws Exception {
    DocumentBuilderFactoryBuilder builder = DocumentBuilderFactoryBuilder.newInstance();
    Document doc = XmlHelper.createDocument(XpathQueryCase.XML, builder);
    XPath xpathToUse = XPath.newXPathInstance(builder, null);
    assertEquals("", XpathQueryHelper.resolveMultipleTextItems(doc, xpathToUse, "//@MissingAttribute", true, "|"));
}
Also used : XPath(com.adaptris.util.text.xml.XPath) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 24 with DocumentBuilderFactoryBuilder

use of com.adaptris.core.util.DocumentBuilderFactoryBuilder in project interlok by adaptris.

the class XpathQueryHelperTest method testResolveMultipleNode_Missing_AllowEmptyTrue.

@Test
public void testResolveMultipleNode_Missing_AllowEmptyTrue() throws Exception {
    DocumentBuilderFactoryBuilder builder = DocumentBuilderFactoryBuilder.newInstance();
    Document doc = XmlHelper.createDocument(XpathQueryCase.XML, builder);
    XPath xpathToUse = XPath.newXPathInstance(builder, null);
    NodeList nodelist = XpathQueryHelper.resolveNodeList(doc, xpathToUse, "//@MissingAttribute", true);
    assertNotNull(nodelist);
    assertEquals(0, nodelist.getLength());
}
Also used : XPath(com.adaptris.util.text.xml.XPath) NodeList(org.w3c.dom.NodeList) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 25 with DocumentBuilderFactoryBuilder

use of com.adaptris.core.util.DocumentBuilderFactoryBuilder in project interlok by adaptris.

the class XpathQueryHelperTest method testResolveSingleNode.

@Test
public void testResolveSingleNode() throws Exception {
    DocumentBuilderFactoryBuilder builder = DocumentBuilderFactoryBuilder.newInstance();
    Document doc = XmlHelper.createDocument(XpathQueryCase.XML, builder);
    XPath xpathToUse = XPath.newXPathInstance(builder, null);
    assertNotNull(XpathQueryHelper.resolveSingleNode(doc, xpathToUse, "//source-id", false));
}
Also used : XPath(com.adaptris.util.text.xml.XPath) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Document(org.w3c.dom.Document) Test(org.junit.Test)

Aggregations

DocumentBuilderFactoryBuilder (com.adaptris.core.util.DocumentBuilderFactoryBuilder)32 XPath (com.adaptris.util.text.xml.XPath)21 Document (org.w3c.dom.Document)21 Test (org.junit.Test)18 NamespaceContext (javax.xml.namespace.NamespaceContext)12 CoreException (com.adaptris.core.CoreException)10 SimpleNamespaceContext (com.adaptris.util.text.xml.SimpleNamespaceContext)10 ServiceException (com.adaptris.core.ServiceException)8 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)6 KeyValuePair (com.adaptris.util.KeyValuePair)4 NodeList (org.w3c.dom.NodeList)4 XpathQuery (com.adaptris.core.services.metadata.xpath.XpathQuery)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 Node (org.w3c.dom.Node)3 XpathMetadataServiceTest (com.adaptris.core.services.metadata.XpathMetadataServiceTest)2 ConfiguredXpathQuery (com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery)2 MetadataXpathQuery (com.adaptris.core.services.metadata.xpath.MetadataXpathQuery)2 MultiItemConfiguredXpathQuery (com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery)2 MultiItemMetadataXpathQuery (com.adaptris.core.services.metadata.xpath.MultiItemMetadataXpathQuery)2 XmlHelper.createDocument (com.adaptris.core.util.XmlHelper.createDocument)2