From: <bo...@us...> - 2008-03-26 20:59:58
|
Revision: 256 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=256&view=rev Author: bodewig Date: 2008-03-26 13:59:54 -0700 (Wed, 26 Mar 2008) Log Message: ----------- Make it possible to upgrade Differences from recoverable to non-recoverable Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java 2008-03-26 20:49:12 UTC (rev 255) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java 2008-03-26 20:59:54 UTC (rev 256) @@ -81,6 +81,9 @@ case RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR: difference.setRecoverable(true); break; + case RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT: + difference.setRecoverable(false); + break; default: throw new IllegalArgumentException(returnValue + " is not a defined " Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java 2008-03-26 20:49:12 UTC (rev 255) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java 2008-03-26 20:59:54 UTC (rev 256) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2007, Jeff Martin, Tim Bacon +Copyright (c) 2001-2008, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -307,6 +307,10 @@ haltComparison = true; } break; + case RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT: + identical = similar = false; + haltComparison = true; + break; default: throw new IllegalArgumentException(returnValue + " is not a defined DifferenceListener.RETURN_... value"); Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java 2008-03-26 20:49:12 UTC (rev 255) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java 2008-03-26 20:59:54 UTC (rev 256) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2008, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -62,6 +62,12 @@ * interpreted as being similar. */ int RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR = 2; + /** + * Override return value for the <code>differenceFound</code> method. + * Indicates that the nodes identified as being similar should be + * interpreted as being different. + */ + int RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT = 3; /** * Receive notification that 2 nodes are different. * @param difference a Difference instance as defined in {@link Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-03-26 20:49:12 UTC (rev 255) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-03-26 20:59:54 UTC (rev 256) @@ -744,4 +744,24 @@ } } + public void testUpgradingOfRecoverableDifference() throws Exception { + String control = "<foo:bar xmlns:foo='urn:foo'/>"; + String test = "<bar xmlns='urn:foo'/>"; + Diff diff = buildDiff(control, test); + assertFalse(diff.toString(), diff.identical()); + assertTrue(diff.toString(), diff.similar()); + + diff = buildDiff(control, test); + diff.overrideDifferenceListener(new DifferenceListener() { + public int differenceFound(Difference d) { + return RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT; + } + public void skippedComparison(Node c, Node t) { + fail("skippedComparison shouldn't get invoked"); + } + }); + + assertFalse(diff.toString(), diff.identical()); + assertFalse(diff.toString(), diff.similar()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |