Hi Gordon,

you must set 'XMLUnit.setIgnoreWhitespace(true);' somewhere before:

@Test
public void testXmlTest1() throws Exception {
        Diff compareXML;
        final String source = "<stuff-doc><stuff>Stuff Stuff 
Stuff</stuff><more-stuff>Some More Stuff</more-stuff></stuff-doc>";
        final String test = "<stuff-doc>\n<stuff>Stuff Stuff 
Stuff</stuff>\n<more-stuff>Some More Stuff</more-stuff>\n</stuff-doc>";

        // OUTPUT:
        // identical: false
        // similar: false
        compareXML = XMLUnit.compareXML(source, test);
        System.out.println("identical: " + compareXML.identical());
        System.out.println("similar: " + compareXML.similar());

        // OUTPUT with ignoreWhitespaces = true:
        // identical: true
        // similar: true
        XMLUnit.setIgnoreWhitespace(true);
        compareXML = XMLUnit.compareXML(source, test);
        System.out.println("identical: " + compareXML.identical());
        System.out.println("similar: " + compareXML.similar());
        Assert.assertTrue(compareXML.toString(),  compareXML.similar());
        
}

lg,
Harry

On 2014-05-09, Gordon Ross wrote:
> My code is:
> public void testXmlTest1() throws SAXException, IOException
>       {
>               String source = "<stuff-doc><stuff>Stuff Stuff 
> Stuff</stuff><more-stuff>Some More Stuff</more-stuff></stuff-doc>";
>               String test = "<stuff-doc>\n<stuff>Stuff Stuff 
> Stuff</stuff>\n<more-stuff>Some More Stuff</more-stuff>\n</stuff-doc>";
>               assertXMLEqual(source, test);
>       }
> XMLUnit is saying they are not the same as the number of children of
> <stuff-doc> is 5, not 2. Well, that’s true because of the whitespace
> creating text nodes. But I thought XMLUnit was supposed to cope with
> this?

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Xmlunit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmlunit-general

Reply via email to