On Fri, 4 May 2007, Anamika Majumder <[EMAIL PROTECTED]>
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

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Xmlunit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmlunit-general

Reply via email to