Search in sources :

Example 66 with DOMException

use of org.w3c.dom.DOMException in project webservices-axiom by apache.

the class TestAppendChildForeignImplementation method runTest.

@Override
protected void runTest() throws Throwable {
    Document document = dbf.newDocumentBuilder().newDocument();
    Element element = mock(Element.class);
    try {
        document.appendChild(element);
        fail("Expected DOMException");
    } catch (DOMException ex) {
        assertThat(ex.code).isEqualTo(DOMException.WRONG_DOCUMENT_ERR);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 67 with DOMException

use of org.w3c.dom.DOMException in project webservices-axiom by apache.

the class TestAppendChildWrongDocument method runTest.

protected void runTest() throws Throwable {
    DocumentBuilder documentBuilder = dbf.newDocumentBuilder();
    Document document1 = documentBuilder.newDocument();
    Document document2 = documentBuilder.newDocument();
    Element element = document2.createElementNS(null, "element");
    try {
        document1.appendChild(element);
        fail("Expected DOMException");
    } catch (DOMException ex) {
        assertEquals(DOMException.WRONG_DOCUMENT_ERR, ex.code);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 68 with DOMException

use of org.w3c.dom.DOMException in project webservices-axiom by apache.

the class TestAppendChildCyclic method runTest.

protected void runTest() throws Throwable {
    Document document = dbf.newDocumentBuilder().newDocument();
    Element grandparent = document.createElementNS(null, "grandparent");
    Element parent = document.createElementNS(null, "parent");
    grandparent.appendChild(parent);
    Element element = document.createElementNS(null, "element");
    parent.appendChild(element);
    try {
        element.appendChild(grandparent);
        fail("Expected DOMException");
    } catch (DOMException ex) {
        assertEquals(DOMException.HIERARCHY_REQUEST_ERR, ex.code);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 69 with DOMException

use of org.w3c.dom.DOMException in project webservices-axiom by apache.

the class TestAppendChildSelf method runTest.

protected void runTest() throws Throwable {
    Document document = dbf.newDocumentBuilder().newDocument();
    Element element = document.createElementNS("urn:test", "test");
    try {
        element.appendChild(element);
        fail("Expected DOMException");
    } catch (DOMException ex) {
        assertEquals(DOMException.HIERARCHY_REQUEST_ERR, ex.code);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 70 with DOMException

use of org.w3c.dom.DOMException in project webservices-axiom by apache.

the class TestAppendChildWrongDocument method runTest.

protected void runTest() throws Throwable {
    DocumentBuilder documentBuilder = dbf.newDocumentBuilder();
    Document document1 = documentBuilder.newDocument();
    Document document2 = documentBuilder.newDocument();
    Element element = document1.createElementNS(null, "element");
    Text text = document2.createTextNode("test");
    try {
        element.appendChild(text);
        fail("Expected DOMException");
    } catch (DOMException ex) {
        assertEquals(DOMException.WRONG_DOCUMENT_ERR, ex.code);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) Text(org.w3c.dom.Text) Document(org.w3c.dom.Document)

Aggregations

DOMException (org.w3c.dom.DOMException)323 Document (org.w3c.dom.Document)165 Element (org.w3c.dom.Element)131 Node (org.w3c.dom.Node)73 NodeList (org.w3c.dom.NodeList)57 DocumentBuilder (javax.xml.parsers.DocumentBuilder)42 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)42 Attr (org.w3c.dom.Attr)40 DOMImplementation (org.w3c.dom.DOMImplementation)37 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)28 FrameworkException (org.structr.common.error.FrameworkException)27 IOException (java.io.IOException)26 NamedNodeMap (org.w3c.dom.NamedNodeMap)25 DocumentType (org.w3c.dom.DocumentType)19 ArrayList (java.util.ArrayList)17 Text (org.w3c.dom.Text)17 DOMNode (org.structr.web.entity.dom.DOMNode)16 XPathExpressionException (javax.xml.xpath.XPathExpressionException)15 SAXException (org.xml.sax.SAXException)13 TransformerException (javax.xml.transform.TransformerException)12