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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations