/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; ProcessingInstruction pi1; ProcessingInstruction pi2; int pi1Position; int pi2Position; Node appendedChild; doc = (Document) load("hc_staff", true); pi1 = doc.createProcessingInstruction("PI1", ""); pi2 = doc.createProcessingInstruction("PI2", ""); appendedChild = doc.appendChild(pi1); appendedChild = doc.appendChild(pi2); pi1Position = (int) pi1.compareDocumentPosition(pi2); assertEquals("nodecomparedocumentpositionFollowing17", 4, pi1Position); pi2Position = (int) pi2.compareDocumentPosition(pi1); assertEquals("nodecomparedocumentpositionPRECEDING17", 2, pi2Position); } /**
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; Element elemMain; Element elem; Text txt; ProcessingInstruction pi; int elementToTxtPosition; int txtToPiPosition; Node appendedChild; doc = (Document) load("hc_staff", false); elemMain = doc.createElementNS("http://www.w3.org/1999/xhtml", "p"); elem = doc.createElementNS("http://www.w3.org/1999/xhtml", "br"); txt = doc.createTextNode("TEXT"); pi = doc.createProcessingInstruction("PIT", "PID"); appendedChild = elemMain.appendChild(txt); appendedChild = elemMain.appendChild(elem); appendedChild = elemMain.appendChild(pi); elementToTxtPosition = (int) txt.compareDocumentPosition(elem); assertEquals("nodecomparedocumentpositionFollowing34", 4, elementToTxtPosition); txtToPiPosition = (int) pi.compareDocumentPosition(txt); assertEquals("nodecomparedocumentpositionPRECEDING34", 2, txtToPiPosition); } /**
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; ProcessingInstruction pi; int documentPosition; int piPosition; Node appendedChild; doc = (Document) load("hc_staff", true); pi = doc.createProcessingInstruction("PITarget", "PIDATA"); appendedChild = doc.appendChild(pi); documentPosition = (int) doc.compareDocumentPosition(pi); assertEquals("nodecomparedocumentpositionIsContainedFollowing12", 20, documentPosition); piPosition = (int) pi.compareDocumentPosition(doc); assertEquals("nodecomparedocumentpositionContainsPRECEDING12", 10, piPosition); } /**
entRefPosition = (int) entRef.compareDocumentPosition(entRefChild1); assertEquals("nodecomparedocumentpositionIsContainedFollowing27", 20, entRefPosition); entRefChild1Position = (int) entRefChild1.compareDocumentPosition(entRef); assertEquals("nodecomparedocumentpositionContainsPRECEDING", 10, entRefChild1Position);
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; Element docElem; EntityReference entRef1; EntityReference entRef2; Element entRefChild1; ProcessingInstruction entRefChild2; int entRefChild1Position; int entRefChild2Position; Node appendedChild; doc = (Document) load("hc_staff", true); entRef1 = doc.createEntityReference("ent4"); entRef2 = doc.createEntityReference("ent4"); docElem = doc.getDocumentElement(); appendedChild = docElem.appendChild(entRef1); appendedChild = docElem.appendChild(entRef2); entRefChild1 = (Element) entRef1.getFirstChild(); assertNotNull("entRefChild1NotNull", entRefChild1); entRefChild2 = (ProcessingInstruction) entRef2.getLastChild(); assertNotNull("entRefChild2NotNull", entRefChild2); entRefChild1Position = (int) entRefChild1.compareDocumentPosition(entRefChild2); assertEquals("nodecomparedocumentpositionFollowing29", 4, entRefChild1Position); entRefChild2Position = (int) entRefChild2.compareDocumentPosition(entRefChild1); assertEquals("nodecomparedocumentpositionPRECEDING29", 2, entRefChild2Position); } /**
entRefChild1Position = (int) entRefChild1.compareDocumentPosition(entRefChild2); assertEquals("nodecomparedocumentpositionFollowing28", 4, entRefChild1Position); entRefChild2Position = (int) entRefChild2.compareDocumentPosition(entRefChild1); assertEquals("nodecomparedocumentpositionPRECEDING28", 2, entRefChild2Position);