Main Page Packages Class Hierarchy Compound List File List Compound Members

# nodeinsertbefore Class Reference

Inherits DOMTestCase.

List of all members.

## Public Methods
| nodeinsertbefore (DOMTestDocumentBuilderFactory factory)
void | runTest () throws java.lang.Throwable
String | getTargetURI ()
## Static Public Methods
void | main (String[] args)

## Detailed Description

The "insertBefore(newChild,refChild)" method inserts the node "newChild" before the node "refChild".

Insert a newly created Element node before the eigth child of the second employee and check the "newChild" and "refChild" after insertion for correct placement.

Author:
  NIST , Mary Brady

See also:
  http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727

Definition at line 44 of file nodeinsertbefore.java.

## Constructor & Destructor Documentation

nodeinsertbefore::nodeinsertbefore | ( | DOMTestDocumentBuilderFactory | factory | ) | `[inline]`

| Definition at line 46 of file nodeinsertbefore.java.
    00047  {
    00048       super(factory);
    00049
    00050    }

## Member Function Documentation

String nodeinsertbefore::getTargetURI | ( |  | ) | `[inline, virtual]`

| Reimplemented from DOMTest. Definition at line 120 of file nodeinsertbefore.java.
    00120                                 {
    00121       return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbefore";
    00122    }

void nodeinsertbefore::main | ( | String | args[] | ) | `[inline, static]`

| Definition at line 123 of file nodeinsertbefore.java. References DOMTestCase::doMain().
    00123                                           {
    00124         DOMTestCase.doMain(nodeinsertbefore.class,args);
    00125    }

void nodeinsertbefore::runTest | ( |  | ) | `[inline, virtual]`

| Reimplemented from DOMTestCase. Definition at line 52 of file nodeinsertbefore.java. References DOMTestCase::assertEquals(), DOMTest::isIgnoringElementContentWhitespace(), and DOMTest::load().
    00052                                                     {
    00053       Document doc;
    00054       NodeList elementList;
    00055       Node employeeNode;
    00056       NodeList childList;
    00057       Node refChild;
    00058       Node newChild;
    00059       Node child;
    00060       String childName;
    00061       Node insertedNode;
    00062       List actual = new ArrayList();
    00063
    00064       List expectedWithWhitespace = new ArrayList();
    00065       expectedWithWhitespace.add("#text");
    00066       expectedWithWhitespace.add("employeeId");
    00067       expectedWithWhitespace.add("#text");
    00068       expectedWithWhitespace.add("name");
    00069       expectedWithWhitespace.add("#text");
    00070       expectedWithWhitespace.add("position");
    00071       expectedWithWhitespace.add("#text");
    00072       expectedWithWhitespace.add("newChild");
    00073       expectedWithWhitespace.add("salary");
    00074       expectedWithWhitespace.add("#text");
    00075       expectedWithWhitespace.add("gender");
    00076       expectedWithWhitespace.add("#text");
    00077       expectedWithWhitespace.add("address");
    00078       expectedWithWhitespace.add("#text");
    00079
    00080       List expectedWithoutWhitespace = new ArrayList();
    00081       expectedWithoutWhitespace.add("employeeId");
    00082       expectedWithoutWhitespace.add("name");
    00083       expectedWithoutWhitespace.add("position");
    00084       expectedWithoutWhitespace.add("newChild");
    00085       expectedWithoutWhitespace.add("salary");
    00086       expectedWithoutWhitespace.add("gender");
    00087       expectedWithoutWhitespace.add("address");
    00088
    00089       List expected = new ArrayList();
    00090
    00091       doc = load("staff");
    00092       elementList = doc.getElementsByTagName("employee");
    00093       employeeNode = elementList.item(1);
    00094       childList = employeeNode.getChildNodes();
    00095
    00096         if(
    00097         isIgnoringElementContentWhitespace()
    00098         ) {
    00099         refChild = childList.item(3);
    00100       expected =  expectedWithoutWhitespace;
    00101
    00102         }
    00103
    00104                 else {
    00105                         refChild = childList.item(7);
    00106       expected =  expectedWithWhitespace;
    00107
    00108                 }
    00109         newChild = doc.createElement("newChild");
    00110       insertedNode = employeeNode.insertBefore(newChild,refChild);
    00111       for(int _index = 0; _index < childList.getLength();_index++) {
    00112       child = ( Node ) childList.item(_index);
    00113            childName = child.getNodeName();
    00114       actual.add(childName);
    00115
    00116         }
    00117       assertEquals("nodeNames",expected,actual);
    00118
    00119    }

The documentation for this class was generated from the following file:

- nodeinsertbefore.java