Results 1 to 3 of 3
- 03-11-2009, 05:18 PM #1
Member
- Join Date
- Nov 2008
- Location
- Gothenburg
- Posts
- 4
- Rep Power
- 0
ComparisonFailure on equal(to the eye) strings
Hello!
I have problems with trying to verify a string read from a text file.
* I read in the entire text file and save it as a String (say myStringReadFromFile).
* I manually copy the text from the the text file, and as the text is not so long I paste it into my assertEquals method and adjust it slightly to something like this:
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
+ "<Event pointID=\"Alarms\" xmlns=\"ng:event\">\n"
+ "<Header>\n"
+ ...
, myStringReadFromFile);
Now the thing is I get a junit.framework.ComparisonFailure. Using Eclipse, I double click on the failure to open the "Result Comparison" window, but nothing differs the actual from the expected text!
I copy the two text fields manually into two different text files and run a winmerge on them. They are identical..
Any help on how to make things easier..? :)
Thanks!
Staffan
- 03-12-2009, 05:28 AM #2
try usng string buffer
Stringbuffer sb = new Stringbugger
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
sb.append("<Event pointID=\"Alarms\" xmlns=\"ng:event\">");
sb.append("<Header>");
assertEqualls(sb.tostring,myStringReadFromFile);It's easy to write a code that computers can understand...
... the challenge is to write a code that humans can understand
- 03-12-2009, 02:57 PM #3
Member
- Join Date
- Nov 2008
- Location
- Gothenburg
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Tomcat & JBoss [for jsp] are of equal difficulty to setup & run (localhost_lastest ed
By lse123 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 01-03-2009, 10:00 AM -
Problem using equal() method
By ookie833 in forum New To JavaReplies: 3Last Post: 11-18-2008, 05:19 AM -
Entering a while loop with a not equal to string
By bri1547 in forum New To JavaReplies: 9Last Post: 07-09-2008, 07:10 AM -
checking if there are equal numbers
By nalinda in forum New To JavaReplies: 1Last Post: 11-18-2007, 06:21 AM -
checking if there are equal numbers
By nalinda in forum New To JavaReplies: 0Last Post: 11-18-2007, 02:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks