assertEquals(document.getRoot().getName(), Name.HTML);
assertNull(document.getDoctype());
//ROOT.
HTMLNode root = document.getRoot();
assertNotNull(root);
assertEquals(root.getParent(), null);
List<HTMLNode> children = root.getChildren();
//ArrayList<HTMLNode> children = (ArrayList<HTMLNode>)root.getChildren();
assertNotNull(children);
assertEquals(children.size(), 2);
assertEquals(children.get(0).getChildren().size(), 1);
assertEquals(children.get(0).getChildren().get(0).getChildren().size(), 1);
for (int i = 0; i < children.size(); i++)
{
if (i == 0)
{
assertEquals(children.get(i).getName(), Name.HEAD);
assertEquals(children.get(i).getName().toString(), "HEAD");
}
if (i == 1)
{
assertEquals(children.get(i).getName(), Name.BODY);
assertEquals(children.get(i).getName().toString(), "BODY");
}
}
List<HTMLNode> children_ = root.getChildrenNode();
assertEquals(children_.size(), 2);
assertEquals(children.size(), children_.size());
//BODY.
NodePath path_ = NodePathParser.toPath(children.get(1));
assertNotNull(path_);
System.out.println("NODEPATH-CLASS: " + path_.getClass().getName());
System.out.println("PATH OF BODY: " + path_.toString());
HTMLNode bodyNode = NodePathUtil.lookFor(document.getRoot(), path_);
assertEquals(bodyNode, children.get(1));
String bodyPath = "html.body";
HTMLNode bodyNode1 = NodePathUtil.lookFor(document.getRoot(), NodePathParser.toPath(bodyPath));
assertNotNull(bodyNode1);
assertEquals(bodyNode1, bodyNode);
//Test Node.getChildren() and Node.getChildrenNode() methods.
List<HTMLNode> bodyChildren = bodyNode.getChildren();
List<HTMLNode> bodyChildren1 = bodyNode.getChildrenNode();
assertEquals(bodyChildren.size(), bodyChildren1.size());
assertEquals(bodyChildren.size(), 2);
assertEquals(bodyChildren1.size(), 2);
//TABLE
String pathStr = "html.body.table[0]";
NodePath path = NodePathParser.toPath(pathStr);
assertNotNull(path);
HTMLNode tableNode = NodePathUtil.lookFor(document.getRoot(), path);
assertNotNull(tableNode);
assertEquals(tableNode.getName(), Name.TABLE);
assertEquals(tableNode.getName().toString(), "TABLE");
assertEquals(tableNode.getChildren().size(), 1);
assertEquals(true, tableNode.isNode(Name.TABLE));
//assertNotSame(tableNode.isNode(Name.TABLE),tableNode.isNode(tableNode.getName().toString()));
assertEquals(tableNode.isNode(Name.TABLE), tableNode.isNode(tableNode.getName().name()));
assertEquals(tableNode.isNode(Name.TABLE), tableNode.isNode(tableNode.getName().toString()));
assertEquals(new String(tableNode.getValue()), "table bgcolor='red' border='1' cellspacing='2' cellpadding='3'");
System.out.println("\n\nTABLE-VALUE: " + new String(tableNode.getValue()));
/*
assertEquals(tableNode.getTextValue(),("<table bgcolor='red' border='1' cellspacing='2' cellpadding='3'>" +
"<tbody>" +
"<tr>" +
"<td><h1>Cell 1</h1></td><td><h2>Cell 2<h2></td>" +
"</tr>" +
"</tbody>" +
"</table>"));
*///==>ERROR.
//System.out.println("TABLE-TEXTVALUE: " + tableNode.getTextValue());
List<HTMLNode> tableChildren = tableNode.getChildrenNode();
assertEquals(tableChildren.size(), 1);
assertEquals(tableChildren.get(0).getName(), Name.TBODY);
assertEquals(tableChildren.get(0).getChildren().get(0).getName(), Name.TR);
assertEquals(tableChildren.get(0).getChildren().get(0).getChildren().get(0).getName(), Name.TD);
assertEquals(tableChildren.get(0).getChildren().get(0).getChildren().size(), 2);
assertNotNull(HTML.getConfig(Name.TABLE));
HTMLNode _node = NodePathUtil.lookFor(document.getRoot(), NodePathParser.toPath("html.body"));
assertNotNull(_node);
//There are two Ways for creating a Table.
//1st Way.
/* NodeImpl nodeImpl =new NodeImpl("table bgcolor='blue' border='0'".toCharArray(),HTML.getConfig("TABLE"),TypeToken.TAG);