nodeappendchildnewchilddiffdocumentpublic final class nodeappendchildnewchilddiffdocument extends org.w3c.domts.DOMTestCase The "appendChild(newChild)" method raises a
WRONG_DOCUMENT_ERR DOMException if the "newChild" was
created from a different document than the one that
created this node.
Retrieve the second employee and attempt to append
a node created from a different document. An attempt
to make such a replacement should raise the desired
exception. |
Constructors Summary |
---|
public nodeappendchildnewchilddiffdocument(org.w3c.domts.DOMTestDocumentBuilderFactory factory)Constructor.
super(factory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
preload(contentType, "staff", false);
preload(contentType, "staff", true);
|
Methods Summary |
---|
public java.lang.String | getTargetURI()Gets URI that identifies the test.
return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildnewchilddiffdocument";
| public static void | main(java.lang.String[] args)Runs this test from the command line.
DOMTestCase.doMain(nodeappendchildnewchilddiffdocument.class, args);
| public void | runTest()Runs the test case.
Document doc1;
Document doc2;
Node newChild;
NodeList elementList;
Node elementNode;
Node appendedChild;
doc1 = (Document) load("staff", false);
doc2 = (Document) load("staff", true);
newChild = doc1.createElement("newChild");
elementList = doc2.getElementsByTagName("employee");
elementNode = elementList.item(1);
{
boolean success = false;
try {
appendedChild = elementNode.appendChild(newChild);
} catch (DOMException ex) {
success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
}
assertTrue("throw_WRONG_DOCUMENT_ERR", success);
}
|
|