From: Anamika M. <pra...@ho...> - 2007-05-08 17:34:09
|
Thank you again Stefan, this is very helpful, I am all set with this. could you pl. let me know how if there is a way to run a xmlunit test case = from the command line (I have been running my testcases through the NetBean= s IDE. Thanks. Anamika. =20 Abhin: I wrote the following (in case this is still helpful): public int differenceFound(Difference d) { Node controlN =3D d.getControlNodeDetail().getNode(); Node testN =3D d.getTestNodeDetail().getNode(); String controlNodeName =3D controlN.getNodeName(); String testNodeName =3D testN.getNodeName(); String testXpathLoc =3D d.getTestNodeDetail().getXpathLocation(); String conXpathLoc =3D d.getControlNodeDetail().getXpathLocation(); String foo =3D "/abcd[1]/efgh[1]/ijk[1]/text()[1]";=20 if(conXpathLoc.equals(foo) && testXpathLoc.equals(foo)) return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; else return RETURN_ACCEPT_DIFFERENCE;=20 }----------------------------------------------------------=20 > To: xml...@li...> From: bo...@ap...> Date= : Tue, 8 May 2007 06:42:34 +0200> CC: Ana...@om...> Subject: = Re: [Xmlunit-general] Comparing two XML documents while skipping certain no= des> > On Fri, 4 May 2007, Anamika Majumder <Ana...@om...>> w= rote:> > > The method int differenceFound(org.custommonkey.xmlunit.Differen= ce> > 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", a= m I missing the point entirely??> > If you are you trying to to test your c= ustom implementation of> DifferenceListener, this is a problem, I agree.> >= What I suggested was that you write a DifferenceListener like> (untested c= ode, I didn't try to even compile it):> > public class MyDiffListener imple= ments DifferenceListener {> > public int differenceFound(Difference d) {> i= f (d.getId() =3D=3D DifferenceConstants.ELEMENT_TAG_NAME_ID> && d.getContro= lNodeDetail().getValue().equals("foo")> && d.getTestNodeDetail().getValue()= .equals("bar")) {> return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;> }> ret= urn RETURN_ACCEPT_DIFFERENCE;> }> > public void skippedComparison(Node cont= rol, Node test) {}> }> > and use Diff.overrideDifferenceListener() with an = instance of your> class.> > I know you cannot write tests for MyDiffListene= r, 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/pow= erbar/db2/> _______________________________________________> Xmlunit-genera= l mailing list> Xml...@li...> https://lists.source= forge.net/lists/listinfo/xmlunit-general _________________________________________________________________ See what you=92re getting into=85before you go there. http://newlivehotmail.com/?ocid=3DTXT_TAGWL_migration_HM_viral_preview_0507= |