Menu

XMLUnit 0.8 issues with files and strings

2003-02-20
2003-02-27
  • Bhaskar Mulpuri

    Bhaskar Mulpuri - 2003-02-20

    I have a file that has the following xml
    <?xml version="1.0"?>
    <request>
        <order_query ordernumber="3065"/>
        <order_query ordernumber="3066"/>
    </request>

    There are end of line and tab characters in the above file.

    I have an xml string as follows:
    <?xml version="1.0"?>
    <request><order_query ordernumber="3065"/><order_query ordernumber="3066"/></request>

    There is one end of line character in the above xml.

    My code is as follows:

    XMLUnit.setIgnoreWhitespace(true);
    assertXMLEqual("Query XML Not Similar For Collection", xmlFileReader, new StringReader(testQueryXml));

    // xmlFileReader is a FileReader for the above mentioned file.
    // testQueryXml is a string that has the above xml contained in a string.

    The error I get is
    [different] Expected number of child nodes '5' but was '2' - comparing <request...> to <request...>

    My understanding is that if I set the XMLUnit.setIgnoreWhitespace(true), then all form feeds, tabs, etc.. are read as empty elements and ignored.

    Is this incorrect or is this a bug in XMLUnit?

    Thanx
    Bhaskar

     
    • tim bacon

      tim bacon - 2003-02-27

      Your understanding is correct - the whole point of setIgnoreWhitespace(true) is to remove these redundant text nodes. Indeed the JUnit tests prove that it works OK with Xalan/Xerces as the underlying XML tools - look at or better try to run test_Diff.testXMLUnitDoesNotWorkWellWithFiles() and see what happens.

      Rgds,

      Tim

       

Log in to post a comment.

MongoDB Logo MongoDB