*
* @throws Exception Should never happen.
*/
@Test
public void testIgnore() throws Exception {
final XMLComparator cmp = new XMLComparator(
"<body>\n" +
" <form id=\"MyForm\">\n" +
" <table cellpading=\"1\">\n" +
" <tr><td>foo</td></tr>\n" +
" </table>\n" +
" </form>\n" +
"</body>",
"<body>\n" +
" <form id=\"MyForm\">\n" +
" <table cellpading=\"2\">\n" +
" <tr><td>foo</td></tr>\n" +
" </table>\n" +
" </form>\n" +
"</body>");
ensureFail("Should fail because the \"cellpading\" attribute value is different.", cmp);
// Following comparison should not fail anymore.
cmp.ignoredAttributes.add("cellpading");
cmp.compare();
cmp.ignoredAttributes.clear();
cmp.ignoredAttributes.add("bgcolor");
ensureFail("The \"cellpading\" attribute should not be ignored anymore.", cmp);
// Ignore the table node, which contains the faulty attribute.
cmp.ignoredNodes.add("table");
cmp.compare();
// Ignore the form node and all its children.
cmp.ignoredNodes.clear();
cmp.ignoredNodes.add("form");
cmp.compare();
}