Issue Details (XML | Word | Printable)

Key: SUREFIRE-57
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Unassigned
Reporter: Klaus Brunner
Votes: 3
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Maven Surefire

Invalid characters in XML reports

Created: 30/Nov/06 11:31 AM   Updated: 23/Nov/07 10:51 AM
Component/s: JUnit 3.x support
Affects Version/s: None
Fix Version/s: 2.4

Time Tracking:
Not Specified

File Attachments: 1. XML File pom.xml (2 kB)
2. XML File TEST-com.acme.test.ResourceLoaderTest.xml (5 kB)


Complexity: Intermediate
Testcase included: yes


 Description  « Hide
Surefire (or possibly Xpp3Dom?) should check for invalid characters in JUnit output and escape or mask them to ensure valid XML reports. This applies to all characters outside the allowed range defined in the XML spec (http://www.w3.org/TR/REC-xml/#NT-Char).

I have a JUnit test case that uses assertEquals on strings. In some situations, the string to compare against the reference may be completely garbled and contain things such as null characters, which then show up in the assertion failure message ("expected X but was Y") and consequently in the XML reports.

Here's a simple test case to trigger the problem:

public class InvalidCharactersTest extends TestCase {
public void testStrings() { String expected = "abc"; String actual = "abc" + '\u0000'; assertEquals(expected, actual); }
}

The resulting Surefire XML report contains the null character as is and is therefore not valid XML. Running the Surefire Reports plugin then fails with a parsing error.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Khai Do added a comment - 07/Nov/07 08:48 AM
I am having the same problem with invalid characters. However the invalid character is not in the same exact location for me. I'm getting an invalid character in the "java.library.path" property in the my surefire junit reports.

I will attach the junit report for you to see (line 28:385-388). Also attached is my pom.xml that i used to run test and generate the report.

I'm running on Win2003 server using java 1.5_07, maven 2.0.7 and ant 1.6.5


Khai Do added a comment - 07/Nov/07 12:38 PM
Actually I found the problem in my situation. I must have installed some application which in turn added those invalid characters into my PATH system environment variable and that's why it was appearing the junit report. Anyways i've removed the offending characters from the PATH environment variable and that fixed my problem.

Dan Fabulich added a comment - 23/Nov/07 10:51 AM
Fixed in revision 597701