java - string comparison failure for xml string comparison -


i working on junit test output of method string in xml format.i not sure why string comparison failing

assert.assertequals("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" +             "<rate>1.0</rate>", xmlutil.formatxml(test_xml));   actaul response method :  <?xml version="1.0" encoding="iso-8859-1"?> <rate>1.0</rate> 

error :

junit.framework.comparisonfailure: expected:<...oding="iso-8859-1"?>[ <rate>1.0</rate>]> was:<...oding="iso-8859-1"?>[ <rate>1.0</rate> ]>     ] 

edit adding new line in end doesnt help:

assert.assertequals("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" +                 "<rate>1.0</rate>\n", xmlutil.formatxml(test_xml));  junit.framework.comparisonfailure: expected:<...oding="iso-8859-1"?>[ <rate>1.0</rate>] > was:<...oding="iso-8859-1"?>[ <rate>1.0</rate> ] > 

the expected , actual xml may have different carriage control character content. try removing newline , linefeed characters

string expected =         "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>rate>1.0</rate>"; assert.assertequals(expected,        "<rate>1.0</rate>", xmlutil.formatxml(test_xml).replaceall("[\r\n]", ""); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -