From: Eli T. <sou...@ne...> - 2003-06-25 18:02:26
|
I ran into a problem when using a DetailedDiff while using an overrideDifferenceListener(). I thought I would post it here in case other people run into the same problem. Below is a slightly modified version of the testCompareToSkeletonXML example: public void testCompareToSkeletonXML() throws Exception { String myControlXML =3D "<location><street-address>22 anystreet</street-address><postcode>XY00 99Z</postcode></location>"; String myTestXML =3D "<location><street-address>20 eastcheap</street-address><postcode>EC3M 1EB</postcode></location>"; DifferenceListener myDifferenceListener =3D new IgnoreTextAndAttributeValuesDifferenceListener(); Diff myDiff =3D new Diff(myControlXML, myTestXML); myDiff.overrideDifferenceListener(myDifferenceListener); // This works fine: assertTrue("test XML matches control skeleton XML", myDiff.similar()); DetailedDiff myDetailedDiff =3D new DetailedDiff(myDiff); // Without this line, the test fails: //myDetailedDiff.overrideDifferenceListener(myDifferenceListener); assertTrue("Does not work with detailed diff", myDetailedDiff.similar()); } The point is that you must override the difference listener on the detailedDiff object that you are using, otherwise the difference listener you specified will not be used. I'm not sure of a way the code could be changed to work around this or to make the problem more obvious so others don't run into the same issue in the future. =20 - Eli Tucker http://nerdmonkey.com |