use of org.w3c.dom.DOMException in project webservices-axiom by apache.
the class TestAppendChildForbidden method runTest.
@Override
protected void runTest() throws Throwable {
OMDocument omDocument = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), new StringReader("<test/>")).getDocument();
if (build) {
omDocument.build();
}
Document document = (Document) omDocument;
try {
document.appendChild(document.createElementNS(null, "test"));
fail("Expected DOMException");
} catch (DOMException ex) {
assertThat(ex.code).isEqualTo(DOMException.HIERARCHY_REQUEST_ERR);
}
}
use of org.w3c.dom.DOMException in project webservices-axiom by apache.
the class TestInsertBeforeForbidden method runTest.
@Override
protected void runTest() throws Throwable {
OMDocument omDocument = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), new StringReader("<!--test--><test/>")).getDocument();
if (build) {
omDocument.build();
}
Document document = (Document) omDocument;
Comment comment = (Comment) document.getFirstChild();
try {
document.insertBefore(document.createElementNS(null, "test"), comment);
fail("Expected DOMException");
} catch (DOMException ex) {
assertThat(ex.code).isEqualTo(DOMException.HIERARCHY_REQUEST_ERR);
}
}
use of org.w3c.dom.DOMException in project webservices-axiom by apache.
the class DOMExceptionTranslatorTest method testMessage.
@Test
public void testMessage() {
DOMException ex = DOMExceptionUtil.newDOMException(DOMException.NOT_FOUND_ERR);
assertThat(ex.getMessage()).isEqualTo("NOT_FOUND_ERR: An attempt is made to reference a node in a context where it does not exist.");
}
use of org.w3c.dom.DOMException in project webservices-axiom by apache.
the class TestReplaceChildWrongDocument method runTest.
protected void runTest() throws Throwable {
DocumentBuilder db = dbf.newDocumentBuilder();
Document document1 = db.newDocument();
Document document2 = db.newDocument();
Element parent = document1.createElementNS(null, "parent");
Element child1 = document1.createElementNS(null, "child1");
Element child2 = document1.createElementNS(null, "child2");
Element child3 = document1.createElementNS(null, "child3");
parent.appendChild(child1);
parent.appendChild(child2);
parent.appendChild(child3);
Element replacementChild = document2.createElementNS(null, "newchild");
try {
parent.replaceChild(replacementChild, child2);
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 TestSetAttributeNSInvalid method runTest.
protected void runTest() throws Throwable {
Document document = dbf.newDocumentBuilder().newDocument();
Element element = document.createElementNS(null, "test");
try {
element.setAttributeNS(DOMUtils.getNamespaceURI(qname), DOMUtils.getQualifiedName(qname), "value");
fail("Expected DOMException");
} catch (DOMException ex) {
assertEquals(DOMException.NAMESPACE_ERR, ex.code);
}
}
Aggregations