nodeinsertbeforenodenamepublic final class nodeinsertbeforenodename extends org.w3c.domts.DOMTestCase The "insertBefore(newChild,refchild)" method returns
the node being inserted.
Insert an Element node before the fourth
child of the second employee and check the node
returned from the "insertBefore(newChild,refChild)"
method. The node returned should be "newChild". |
Constructors Summary |
---|
public nodeinsertbeforenodename(org.w3c.domts.DOMTestDocumentBuilderFactory factory)Constructor.
super(factory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
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/nodeinsertbeforenodename";
| public static void | main(java.lang.String[] args)Runs this test from the command line.
DOMTestCase.doMain(nodeinsertbeforenodename.class, args);
| public void | runTest()Runs the test case.
Document doc;
NodeList elementList;
Node employeeNode;
NodeList childList;
Node refChild;
Node newChild;
Node insertedNode;
String childName;
doc = (Document) load("staff", true);
elementList = doc.getElementsByTagName("employee");
employeeNode = elementList.item(1);
childList = employeeNode.getChildNodes();
refChild = childList.item(3);
newChild = doc.createElement("newChild");
insertedNode = employeeNode.insertBefore(newChild, refChild);
childName = insertedNode.getNodeName();
assertEquals("nodeInsertBeforeNodeNameAssert1", "newChild", childName);
|
|