From: Stefan B. <bo...@ap...> - 2007-05-08 04:42:36
|
On Fri, 4 May 2007, Anamika Majumder <Ana...@om...> wrote: > The method int differenceFound(org.custommonkey.xmlunit.Difference > difference) in the DifferenceListener interface needs a Difference > object, while the Difference class has only protected constructors. > The tests I am writing are in a different package and do not have > access to any protected constructors in the package > "org.custommonkey.xmlunit", am I missing the point entirely?? If you are you trying to to test your custom implementation of DifferenceListener, this is a problem, I agree. What I suggested was that you write a DifferenceListener like (untested code, I didn't try to even compile it): public class MyDiffListener implements DifferenceListener { public int differenceFound(Difference d) { if (d.getId() == DifferenceConstants.ELEMENT_TAG_NAME_ID && d.getControlNodeDetail().getValue().equals("foo") && d.getTestNodeDetail().getValue().equals("bar")) { return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; } return RETURN_ACCEPT_DIFFERENCE; } public void skippedComparison(Node control, Node test) {} } and use Diff.overrideDifferenceListener() with an instance of your class. I know you cannot write tests for MyDiffListener, but it is pretty easy to validate and using the approach outlined above, your XMLUnit tests should skip over differences between "foo" and "bar" nodes. Stefan |