package textbender.a.b.rhinohideDemo._.core; import org.junit.*; import org.w3c.dom.*; import textbender.a.b.rhinohideDemo._.*; import static org.junit.Assert.*; /** Test of Core Level 1 (isolate). */ public final class RhiNode_1i { private Document document; private Node node; @Before public void before() { document = Core_1i_Test.window().getDocument(); node = Core_1_Demo.getElementById( document, "testBlockNode" ); } // ------------------------------------------------------------------------------------ @Test public void appendChild() { final String string = "[RhiNode_1i.appendChild]"; node.appendChild( document.createTextNode( string )); Text text = (Text)node.getLastChild(); assertEquals( /*expected*/string, /*actual*/text.getData() ); } /////////////// these also fail, in the same way: // @Test public void appendChild_2() { final String tagName = "hr"; node.appendChild( document.createElement( tagName )); // Element element = (Element)node.getLastChild(); // assertEquals( /*expected*/tagName, /*actual*/element.getTagName().toLowerCase() ); } // @Test public void appendChild_3() { Node nodeToMove = Core_1_Demo.getElementById( document, "nodeToReplace" ); node.appendChild( nodeToMove ); } @Test public void insertBefore() { Node parent = Core_1_Demo.getElementById( document, "nodeForInsertion" ); final String string = "[RhiNode_1i.insertBefore]"; parent.insertBefore( document.createTextNode( string ), parent.getFirstChild() ); Text text = (Text)parent.getFirstChild(); assertEquals( /*expected*/string, /*actual*/text.getData() ); } @Test public void replaceChild() { final String string = "[RhiNode_1i.replaceChild]"; Node parent = Core_1_Demo.getElementById( document, "nodeToReplace" ); parent.replaceChild( document.createTextNode(string), parent.getLastChild() ); Text text = (Text)parent.getLastChild(); assertEquals( /*expected*/string, /*actual*/text.getData() ); } }