XML report encoding

762 views
Skip to first unread message

Pef

unread,
Mar 17, 2010, 4:50:32 AM3/17/10
to testng-users
Hi all,

I'm currently trying to integrate my testng reports to a Cruise
Control build results page.

I use a Ant task to run tests and convert to junit report. Conversion
fails on some xml files, due to prolog : character encoding is set to
UTF-8 but files actually require ISO-8859-1. Displayed error is :
"The file (file).xml is not a valid XML document. It is possibly
corrupted."

How can I change character encoding from ant task?

Some other files seem to be corrupted too : the file resuming failed
tests does not contain any prolog at all, only Doctype declaration.

Cosmin Marginean

unread,
Mar 17, 2010, 9:07:03 AM3/17/10
to testng...@googlegroups.com
Hi,

What TestNG output are you using?
In terms of changing the file enconding in Ant is probably not a
question for this group, but here's a hint:
http://ant.apache.org/manual/CoreTasks/copy.html (property outputencoding)

Cosmin

Cédric Beust ♔

unread,
Mar 17, 2010, 9:11:18 AM3/17/10
to testng...@googlegroups.com
Hi Pef,

Which files are you referring to, testng-results.xml?

-- 
Cedric


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.




--
Cédric



Pef

unread,
Mar 17, 2010, 9:20:10 AM3/17/10
to testng-users
I'm using these two tasks :

<target name="tests.run">
<testng
outputDir="${testng.html.report}"
sourceDir="${project.work.dir}/build"
haltOnFailure="false">
<xmlfileset dir="${project.work.dir}/build" includes="testng.xml"/>
<classpath>
<path refid="tests.classpath"/>
</classpath>
</testng>
</target>

<target name="tests.junitreport">
<junitreport todir="${testng.xml.report}">
<fileset dir="${testng.html.report}">
<include name="*/*.xml"/>
<exclude name="*/testng-failed.xml"/>
</fileset>
<report format="noframes" todir="${testng.xml.report}"/>
</junitreport>
</target>

Since I still have not found a convenient solution, I have made a
little java class that parses the xml files generated by testng and
makes the necessary changes (encoding, message formatting...). So now,
the JUnit conversion works well but I still not see the tests results
in Cruise control status page (under "Test results" tab)...
But at this point I don't know if it's a Cruise control or TestNG
issue...

Pef

unread,
Mar 17, 2010, 9:23:21 AM3/17/10
to testng-users
I'm referring to all the xml files generated for each <test> instance
in my XML test suite.

On Mar 17, 2:11 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> Hi Pef,
>
> Which files are you referring to, testng-results.xml?
>
> --
> Cedric
>
>
>
> On Wed, Mar 17, 2010 at 1:50 AM, Pef <src...@wanadoo.fr> wrote:
> > Hi all,
>
> > I'm currently trying to integrate my testng reports to a Cruise
> > Control build results page.
>
> > I use a Ant task to run tests and convert to junit report. Conversion
> > fails on some xml files, due to prolog : character encoding is set to
> > UTF-8 but files actually require ISO-8859-1. Displayed error is :
> > "The file (file).xml is not a valid XML document. It is possibly
> > corrupted."
>
> > How can I change character encoding from ant task?
>
> > Some other files seem to be corrupted too : the file resuming failed
> > tests does not contain any prolog at all, only Doctype declaration.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "testng-users" group.
> > To post to this group, send email to testng...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > testng-users...@googlegroups.com<testng-users%2Bunsu...@googlegroups.com>

Cédric Beust ♔

unread,
Mar 17, 2010, 9:29:49 AM3/17/10
to testng...@googlegroups.com
I'm not opposed to changing the encoding of these files from utf-8 to iso-8859-1 but I'm concerned about the consequences (I'm not exactly an expert in this area).

Thoughts?

-- 
Cedric


To unsubscribe from this group, send email to testng-users...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.




--
Cédric



Cosmin Marginean

unread,
Mar 17, 2010, 9:33:10 AM3/17/10
to testng...@googlegroups.com
I am not 100% about the impact, but I am no encoding ninja either. I am mostly worried about impact on existing code and I'm not even sure how are we supposed to validate this.
I suggest the Ant copy stuff which should solve the encoding issue.

Cosmin

Cédric Beust ♔

unread,
Mar 17, 2010, 9:37:28 AM3/17/10
to testng...@googlegroups.com
Fair enough.

On a related issue:  Pef, can you tell us exactly what fails and how?

-- 
Cedric

Bill Michell

unread,
Mar 17, 2010, 9:39:58 AM3/17/10
to testng...@googlegroups.com
On 17 Mar 2010, at 13:29, Cédric Beust ♔ wrote:

I'm not opposed to changing the encoding of these files from utf-8 to iso-8859-1 but I'm concerned about the consequences (I'm not exactly an expert in this area).

This line is supposed to accurately reflect the exact coding used in the file stored on disk.

utf-8 and iso-8859-1 files are only byte-for-byte identical if all characters therein are in the US-ASCII character set. Any attempt to use additional characters will require you to make a conscious choice between the two. Certain common characters, including the UK £ symbol, are not in the US-ASCII character set...

Now, of course, we can represent characters not in the encoding using appropriate character entity references and similar tricks, as long as the code that writes these files is properly XML character set aware.

Any conformant XML processor should be reading the character set declaration and either processing the byte stream using it, or else throwing an exception about an unsupported character set.

In other words, if we're using standard XML processors, then this should all be transparent to us - and if we aren't, then we should be! It is remarkably easy to produce badly formed XML files if we don't.


Now I can imagine allowing the user to specify the preferred encoding for these result files, either in the testng.xml file or else in an (optional) ant parameter (and thus from the command line too). But I'd resist the idea of making the default encoding be anything other than either UTF-8 or US-ASCII...

-- 
Bill Michell




Cédric Beust ♔

unread,
Mar 17, 2010, 9:47:16 AM3/17/10
to testng...@googlegroups.com
Thanks for the precisions, Bill.

I'm pretty sure the XML generated is well formed but I'm suspecting the original poster is using strings (test names maybe?) that contain characters that are not in the utf-8 range, hence my asking him exactly what was failing.

It feels like iso-8859-1 would be a better default encoding but I'd like to make sure I won't be breaking any existing code before making this change.

-- 
Cedric

Pef

unread,
Mar 17, 2010, 9:51:07 AM3/17/10
to testng-users
Sorry if I'm not clear enough.
What fails :
1/ JUnit-compliant conversion of TestNG reports : due to wrong UTF-8
encoding and some invalid characters in "messages" attributes (like
"<" or ">" in assertions results : "Expected <true> but was <false>")
2/ Reports integration in Cruise control status page (under "Test
results" tab)

On Mar 17, 2:37 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> Fair enough.
>
> On a related issue:  Pef, can you tell us exactly what fails and how?
>
> --
> Cedric
>

> On Wed, Mar 17, 2010 at 6:33 AM, Cosmin Marginean <cosmin...@gmail.com>wrote:
>
>
>
> >  I am not 100% about the impact, but I am no encoding ninja either. I am
> > mostly worried about impact on existing code and I'm not even sure how are
> > we supposed to validate this.

> > I suggest the Ant copy stuff which *should* solve the encoding issue.

> >> <testng-users%2Bunsu...@googlegroups.com<testng-users%252Buns...@googlegroups.com>

Felipe Knorr Kuhn

unread,
Mar 17, 2010, 9:51:42 AM3/17/10
to testng...@googlegroups.com
Hello,

If this helps the discussion, most of my test names are in Brazilian
Portuguese and I had remove all special characters (áéíçãõ etc)
because the HTML report was not using html entities too.

All of our projects use ISO-8859-1.

FK

2010/3/17 Cédric Beust ♔ <cbe...@google.com>:

Pef

unread,
Mar 17, 2010, 9:56:13 AM3/17/10
to testng-users
The invalid UTF-8 characters in the xml files are not under my
"responsibility". For example, the encoding error is thrown because of
the following java i/o error : "file.properties (Le chemin d'accès
spécifié est introuvable)".
That's the reason why i was expecting a configuration option in testng
letting users to choose the encoding type.

On Mar 17, 2:47 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> Thanks for the precisions, Bill.
>
> I'm pretty sure the XML generated is well formed but I'm suspecting the
> original poster is using strings (test names maybe?) that contain characters
> that are not in the utf-8 range, hence my asking him exactly what was
> failing.
>
> It feels like iso-8859-1 would be a better default encoding but I'd like to
> make sure I won't be breaking any existing code before making this change.
>
> --
> Cedric
>
> On Wed, Mar 17, 2010 at 6:39 AM, Bill Michell

> <bill.mich...@googlemail.com>wrote:

> >> <testng-users%2Bunsu...@googlegroups.com<testng-users%252Buns...@googlegroups.com>

> > Bill Michell
> > billmich...@gmail.com

Cédric Beust ♔

unread,
Mar 17, 2010, 9:56:33 AM3/17/10
to testng...@googlegroups.com
On Wed, Mar 17, 2010 at 6:51 AM, Pef <src...@wanadoo.fr> wrote:
Sorry if I'm not clear enough.
What fails :
1/ JUnit-compliant conversion of TestNG reports : due to wrong UTF-8
encoding and some invalid characters in "messages" attributes (like
"<" or ">" in assertions results : "Expected <true> but was <false>")

Ok this is clearly a TestNG bug, which should escape these sequences.

As for what Felipe is reporting, it looks like switching to ISO-8859-1 would solve this problem as well (I'd rather not go down the road of replacing all accented characters with their respective entities).
 
2/ Reports integration in Cruise control status page (under "Test
results" tab)

This I'm less clear on, can you be more specific?  Is this a TestNG problem?

--
Cédric



Bill Michell

unread,
Mar 17, 2010, 10:03:59 AM3/17/10
to testng...@googlegroups.com
On 17 Mar 2010, at 13:47, Cédric Beust ♔ wrote:

Thanks for the precisions, Bill.

I'm pretty sure the XML generated is well formed but I'm suspecting the original poster is using strings (test names maybe?) that contain characters that are not in the utf-8 range, hence my asking him exactly what was failing.

Um - utf-8 includes representations for all the unicode character set, including characters that can't be expressed in 16 bits...




It feels like iso-8859-1 would be a better default encoding but I'd like to make sure I won't be breaking any existing code before making this change.

I'd avoid this. If you aren't going to use standard XML writing routines, I'd go to US-ASCII and explicitly escape all characters above #x7F using a suitable escape sequence, plus < and "

You also need to strip out unsupported control characters - see http://www.w3.org/TR/REC-xml/#charsets for a definitive list - essentially, most characters below #x20 are not permitted, and there are a handful of other exceptions too.

-- 
Bill Michell




Cédric Beust ♔

unread,
Mar 17, 2010, 10:12:30 AM3/17/10
to testng...@googlegroups.com
On Wed, Mar 17, 2010 at 7:03 AM, Bill Michell <bill.m...@googlemail.com> wrote:

On 17 Mar 2010, at 13:47, Cédric Beust ♔ wrote:

Thanks for the precisions, Bill.

I'm pretty sure the XML generated is well formed but I'm suspecting the original poster is using strings (test names maybe?) that contain characters that are not in the utf-8 range, hence my asking him exactly what was failing.

Um - utf-8 includes representations for all the unicode character set, including characters that can't be expressed in 16 bits...

Mmmh, true.

In this case, I'd still like to see that stack trace from Pef to find out exactly what's going on.

 
It feels like iso-8859-1 would be a better default encoding but I'd like to make sure I won't be breaking any existing code before making this change.

I'd avoid this. If you aren't going to use standard XML writing routines, I'd go to US-ASCII and explicitly escape all characters above #x7F using a suitable escape sequence, plus < and "

Really?  This sounds like a lot of work (regardless of the fact that it's probably just one method call away).  What's wrong with just switching the encoding of the generated files from UTF-8 to ISO-8859-1?  Are there downsides?

--
Cédric



Pef

unread,
Mar 17, 2010, 10:22:32 AM3/17/10
to testng-users
Here is the trace :

tests.junitreport:
[junitreport] [Fatal Error] Test%20version-issue.xml:1:387: Invalid
byte 2 of 3-byte UTF-8 sequence.
[junitreport] The file C:\logiciels\CruiseControlTestProjects
\FORGES_SERVER\report\html\testng\FORGES_TESTS\Test version-issue.xml


is not a valid XML document. It is possibly corrupted.

[junitreport] Processing C:\logiciels\CruiseControlTestProjects
\FORGES_SERVER\report\xml\testng\TESTS-TestSuites.xml to C:\logiciels
\CruiseControlTestProjects\FORGES_SERVER\report\xml\testng\junit-
noframes.html
[junitreport] Loading stylesheet jar:file:/C:/logiciels/apache-
ant-1.7.0/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/
junit/xsl/junit-noframes.xsl
[junitreport] Transform time: 563ms

The fault file content (Test%20version-issue.xml) :

<?xml version="1.0" encoding="UTF-8"?><testsuite errors="0"
failures="1" name="Test version-issue" tests="1"
time="0.266"><properties/><testcase
classname="test.web.TestVersionIssue" name="testGetNextVersionIssue"
time="0.109"><failure message="[file].properties (Le chemin d'accès
spécifié est introuvable)" type="java.io.FileNotFoundException"><!
[CDATA[java.io.FileNotFoundException: [file].properties (Le chemin


d'accès spécifié est introuvable)

at java.io.FileInputStream.open(Native Method)

at java.io.FileInputStream.<init>(FileInputStream.java:106)

at java.io.FileInputStream.<init>(FileInputStream.java:66)

... Removed 21 stack frames]]></failure></testcase></testsuite>

Cédric Beust ♔

unread,
Mar 17, 2010, 10:27:35 AM3/17/10
to testng...@googlegroups.com
Can you include the entire stack trace?

Thanks.

-- 
Cedric



--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.




--
Cédric



Pef

unread,
Mar 17, 2010, 10:37:29 AM3/17/10
to testng-users
Sorry it's all that Cruise control let me see...

> > testng-users...@googlegroups.com<testng-users%2Bunsu...@googlegroups.com>

Cédric Beust ♔

unread,
Mar 17, 2010, 11:05:28 AM3/17/10
to testng...@googlegroups.com
Well, I can't even be sure that the problem is in TestNG with this stack trace...

Let's tackle the problem differently:  what happens if you manually edit the XML file to include the right encoding and then run Cruise Control?  If you manage to fix the problem, can you post the exact doctype and encoding you specified?

-- 
Cedric


To unsubscribe from this group, send email to testng-users...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.




--
Cédric



Bill Michell

unread,
Mar 17, 2010, 11:06:29 AM3/17/10
to testng...@googlegroups.com
Well, not all the world uses ISO-8859-1 so you still have to find a way to solve the issue for people whose system exceptions include characters not in ISO-8859-1.

Looking at the stack trace, I'd say the issue was with the way the file is being spooled to disk. I'd guess you're using the default system character encoding, but claiming UTF-8.

The fix would be either to claim the default system encoding as the encoding in the xml declaration, or else to explicitly use some other encoding mechanism when opening your output file writer.

Give me a minute and I'll try and find the appropriate line of code.


--
Cédric




--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

-- 
Bill Michell




Pef

unread,
Mar 17, 2010, 11:19:03 AM3/17/10
to testng-users
To correct the fault file causing the error (Test%20version-issue.xml
as indicated above) I have just set the xml prolog to : <?xml
version="1.0" encoding="ISO-8859-1"?>
So the error message "[file].properties (Le chemin d'accès spécifié
est introuvable)" is not causing trouble anymore.
No extra doctype is added to the xml file :

<?xml version="1.0" encoding="ISO-8859-1"?><testsuite name="Test
version-issue" failures="12" tests="1" time="0.281" errors="0">
<properties/>
<testcase name="testGetNextVersionIssue" time="0.141"
classname="test.web.TestVersionIssue">
<failure type="java.io.FileNotFoundException"


message="[file].properties (Le chemin d'accès spécifié est
introuvable)">

<![CDATA[java.io.FileNotFoundException: [file].properties (Le
chemin d'accès spécifié est introuvable)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
... Removed 21 stack frames]]>
</failure>
</testcase>
</testsuite>

Then, the junit conversion log succeed with trace :

tests.junitreport:


[junitreport] Processing C:\logiciels\CruiseControlTestProjects
\FORGES_SERVER\report\xml\testng\TESTS-TestSuites.xml to C:\logiciels
\CruiseControlTestProjects\FORGES_SERVER\report\xml\testng\junit-
noframes.html
[junitreport] Loading stylesheet jar:file:/C:/logiciels/apache-
ant-1.7.0/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/
junit/xsl/junit-noframes.xsl

[junitreport] Transform time: 422ms

But still no result summary in Cruise control web page... (I start
thinking that it's in fact a Cruise control configuration issue, but
it's even more obscure to me than the testng one....)

> > <testng-users%2Bunsu...@googlegroups.com<testng-users%252Buns...@googlegroups.com>

Bill Michell

unread,
Mar 17, 2010, 11:35:33 AM3/17/10
to testng...@googlegroups.com
The candidate line I can see is in org.testng.reporters.XMLReporter.writeSuiteToFile(File, ISuite)

  private void writeSuiteToFile(File suiteFile, ISuite suite) {
    XMLStringBuffer xmlBuffer = new XMLStringBuffer("");
    writeSuiteToBuffer(xmlBuffer, suite);
    File parentDir = suiteFile.getParentFile();
    if (parentDir.exists() || suiteFile.getParentFile().mkdirs()) {
      Utils.writeFile(parentDir.getAbsolutePath(), "testng-results.xml", xmlBuffer.toXML());
    }
  }


Utils.writeFile is set to use the current platform default encoding to write the file out, no matter what the prolog might claim.

However, org.testng.reporters.XMLReporter.generateReport(List<XmlSuite>, List<ISuite>, String) uses a different mechanism...

  public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
    if (Utils.isStringEmpty(config.getOutputDirectory())) {
      config.setOutputDirectory(outputDirectory);
    }

    rootBuffer = new XMLStringBuffer("");
    rootBuffer.push(XMLReporterConfig.TAG_TESTNG_RESULTS);
    writeReporterOutput(rootBuffer);
    for (int i = 0; i < suites.size(); i++) {
      writeSuite(xmlSuites.get(i), suites.get(i));
    }
    rootBuffer.pop();
    Utils.writeUtf8File(config.getOutputDirectory(), "testng-results.xml", rootBuffer.toXML());
  }


Note the use of Utils.writeUtf8File, which explicitly sets the requested encoding to UTF-8

So the individual suites will not use the correct encoding, though the combined version will.

Patch here:

### Eclipse Workspace Patch 1.0
#P TestNG
Index: src/org/testng/reporters/XMLReporter.java
===================================================================
--- src/org/testng/reporters/XMLReporter.java (revision 865)
+++ src/org/testng/reporters/XMLReporter.java (working copy)
@@ -64,7 +64,7 @@
     writeSuiteToBuffer(xmlBuffer, suite);
     File parentDir = suiteFile.getParentFile();
     if (parentDir.exists() || suiteFile.getParentFile().mkdirs()) {
-      Utils.writeFile(parentDir.getAbsolutePath(), "testng-results.xml", xmlBuffer.toXML());
+      Utils.writeUtf8File(parentDir.getAbsolutePath(), "testng-results.xml", xmlBuffer.toXML());
     }
   }
 

Give me a while and I'll figure out how to run testNGs internal tests - I used to know, but things have changed - and I can commit.
-- 
Bill Michell




Bill Michell

unread,
Mar 17, 2010, 11:49:45 AM3/17/10
to testng...@googlegroups.com
Actually, reading the original report again, maybe that isn't the line that needs fixing.

But the problem would appear to be in one of the methods that is calling Utils.writeFile when it should be calling Utils.writeUtf8File

Here is the list of candidates - I'm not certain which one is implicated...

org.testng.junit - src - TestNG
JUnitDirectoryConverter
generateConfiguration(String[])
org.testng.reporters - src - TestNG
SuiteHTMLReporter
generateClasses(XmlSuite, ISuite)
generateExcludedMethodsReport(XmlSuite, ISuite)
generateIndex(List<ISuite>)
generateIndex(XmlSuite, ISuite)
generateMain(XmlSuite, ISuite)
generateMethodsAndGroups(XmlSuite, ISuite)
generateMethodsChronologically(XmlSuite, ISuite, String, boolean)
generateReporterOutput(XmlSuite, ISuite)
generateSuites(XmlSuite, ISuite)
generateTableOfContents(XmlSuite, ISuite)
generateXmlFile(XmlSuite, ISuite)
TestHTMLReporter
generateLog(ITestContext, String, String, Collection<ITestResult>, Collection<ITestResult>, Collection<ITestResult>, Collection<ITestResult>, Collection<ITestResult>, Collection<ITestResult>)
-- 
Bill Michell




Cédric Beust ♔

unread,
Mar 17, 2010, 11:57:43 AM3/17/10
to testng...@googlegroups.com
Bill, thank you very much for taking the time to investigate this.

Pef, I applied Bill's patch and I uploaded the new version to http://testng.org/beta .  Can you try it and let us know if this fixes your problem?

[Just read Bill's update... ok.  Let's proceed with the initial fix and take it from there]

-- 
Cédric

Pef

unread,
Mar 17, 2010, 12:01:28 PM3/17/10
to testng-users
OK, thank you very much guys!! let you know in few minutes

On Mar 17, 4:57 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> Bill, thank you very much for taking the time to investigate this.
>

> Pef, I applied Bill's patch and I uploaded the new version tohttp://testng.org/beta.  Can you try it and let us know if this fixes your


> problem?
>
> [Just read Bill's update... ok.  Let's proceed with the initial fix and take
> it from there]
>
> --
> Cédric
>
> On Wed, Mar 17, 2010 at 8:35 AM, Bill Michell

> <bill.mich...@googlemail.com>wrote:

> > On Wed, Mar 17, 2010 at 7:03 AM, Bill Michell <bill.mich...@googlemail.com

> > billmich...@gmail.com
>
> >  --
> > Bill Michell
> > billmich...@gmail.com


>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "testng-users" group.
> > To post to this group, send email to testng...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > testng-users...@googlegroups.com<testng-users%2Bunsu...@googlegroups.com>

Bill Michell

unread,
Mar 17, 2010, 12:01:41 PM3/17/10
to testng...@googlegroups.com
The file pef is complaining about is named C:\logiciels\CruiseControlTestProjects

\FORGES_SERVER\report\html\testng\FORGES_TESTS\Test version-issue.xml

Any idea which method would be writing that one out?

Pef

unread,
Mar 17, 2010, 12:06:15 PM3/17/10
to testng-users
This file name is coming from the xml suite. It's actually the name of
my test instance... Maybe TestNG should escape these names if it uses
it to create files...

On Mar 17, 5:01 pm, Bill Michell <bill.mich...@googlemail.com> wrote:
> The file pef is complaining about is named C:\logiciels\CruiseControlTestProjects
> \FORGES_SERVER\report\html\testng\FORGES_TESTS\Test version-issue.xml
>
> Any idea which method would be writing that one out?
>
> On 17 Mar 2010, at 15:57, Cédric Beust ♔ wrote:
>
>
>
> > Bill, thank you very much for taking the time to investigate this.
>

> > Pef, I applied Bill's patch and I uploaded the new version tohttp://testng.org/beta.  Can you try it and let us know if this fixes your problem?


>
> > [Just read Bill's update... ok.  Let's proceed with the initial fix and take it from there]
>
> > --
> > Cédric
>

> >>> On Wed, Mar 17, 2010 at 7:03 AM, Bill Michell <bill.mich...@googlemail.com> wrote:
>
> >>> On 17 Mar 2010, at 13:47, Cédric Beust ♔ wrote:
>
> >>>> Thanks for the precisions, Bill.
>
> >>>> I'm pretty sure the XML generated is well formed but I'm suspecting the original poster is using strings (test names maybe?) that contain characters that are not in the utf-8 range, hence my asking him exactly what was failing.
>
> >>> Um - utf-8 includes representations for all the unicode character set, including characters that can't be expressed in 16 bits...
>
> >>> Mmmh, true.
>
> >>> In this case, I'd still like to see that stack trace from Pef to find out exactly what's going on.
>
> >>>> It feels like iso-8859-1 would be a better default encoding but I'd like to make sure I won't be breaking any existing code before making this change.
>
> >>> I'd avoid this. If you aren't going to use standard XML writing routines, I'd go to US-ASCII and explicitly escape all characters above #x7F using a suitable escape sequence, plus < and "
>
> >>> Really?  This sounds like a lot of work (regardless of the fact that it's probably just one method call away).  What's wrong with just switching the encoding of the generated files from UTF-8 to ISO-8859-1?  Are there downsides?
>
> >> Well, not all the world uses ISO-8859-1 so you still have to find a way to solve the issue for people whose system exceptions include characters not in ISO-8859-1.
>
> >> Looking at the stack trace, I'd say the issue was with the way the file is being spooled to disk. I'd guess you're using the default system character encoding, but claiming UTF-8.
>
> >> The fix would be either to claim the default system encoding as the encoding in the xml declaration, or else to explicitly use some other encoding mechanism when opening your output file writer.
>
> >> Give me a minute and I'll try and find the appropriate line of code.
>
> >>> --
> >>> Cédric
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups "testng-users" group.
> >>> To post to this group, send email to testng...@googlegroups.com.
> >>> To unsubscribe from this group, send email to testng-users...@googlegroups.com.

> >>> For more options, visit this group athttp://groups.google.com/group/testng-users?hl=en.


>
> >> --
> >> Bill Michell
> >> billmich...@gmail.com
>
> > --
> > Bill Michell
> > billmich...@gmail.com
>

> > --
> > You received this message because you are subscribed to the Google Groups "testng-users" group.
> > To post to this group, send email to testng...@googlegroups.com.
> > To unsubscribe from this group, send email to testng-users...@googlegroups.com.

> > For more options, visit this group athttp://groups.google.com/group/testng-users?hl=en.


>
> > --
> > You received this message because you are subscribed to the Google Groups "testng-users" group.
> > To post to this group, send email to testng...@googlegroups.com.
> > To unsubscribe from this group, send email to testng-users...@googlegroups.com.

> > For more options, visit this group athttp://groups.google.com/group/testng-users?hl=en.
>
> --
> Bill Michell
> billmich...@gmail.com

Bill Michell

unread,
Mar 17, 2010, 12:14:39 PM3/17/10
to testng...@googlegroups.com
It needs to do something... Not sure I would describe it as escaping, in the context though...

At present, all the reporters I have found just use the suite name to create the file name...

JohnBurgess

unread,
Mar 17, 2010, 12:34:51 PM3/17/10
to testng-users
I use testNG and report tests results in Cruise Control. You don't
need to convert to junit format - the logs it produces normally will
work with CC. In the config file, I have

<log>
<merge dir="projects/prc4/testout/creation" />
<merge dir="projects/prc4/testout/sample" />
<merge dir="projects/prc4/testout/more" />
</log>

to merge the test logs for each suite I run (creation, sample and more
tests) into the main logs and they are then all reported on.

On Mar 17, 8:50 am, Pef <src...@wanadoo.fr> wrote:
> Hi all,
>
> I'm currently trying to integrate my testng reports to a Cruise
> Control build results page.
>
> I use a Ant task to run tests and convert to junit report. Conversion
> fails on some xml files, due to prolog : character encoding is set to
> UTF-8 but files actually require ISO-8859-1. Displayed error is :

> "The file (file).xml is not a valid XML document. It is possibly
> corrupted."
>

Pef

unread,
Mar 17, 2010, 12:54:32 PM3/17/10
to testng-users
Oh nice! Thank you for this tip!
I don't have time to test it today, but i'll do it tomorrow for sure.
I'll let you know the result...

Pef

unread,
Mar 17, 2010, 12:57:57 PM3/17/10
to testng-users
So I finished the test (Cruise control takes over 30min to run all
tests..) but it seems the path did not fix the problem, still have the
log :

tests.junitreport:
[junitreport] [Fatal Error] Test%20version-issue.xml:1:387: Invalid
byte 2 of 3-byte UTF-8 sequence.

[junitreport] The file C:\logiciels\CruiseControlTestProjects


\FORGES_SERVER\report\html\testng\FORGES_TESTS\Test version-issue.xml

is not a valid XML document. It is possibly corrupted.

[junitreport] Processing C:\logiciels\CruiseControlTestProjects
\FORGES_SERVER\report\xml\testng\TESTS-TestSuites.xml to C:\logiciels
\CruiseControlTestProjects\FORGES_SERVER\report\xml\testng\junit-
noframes.html
[junitreport] Loading stylesheet jar:file:/C:/logiciels/apache-
ant-1.7.0/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/
junit/xsl/junit-noframes.xsl

[junitreport] Transform time: 187ms

I have to go now, but I'll continue my tests tomorrow...

Thank you very much all for your help, and see you tomorrow for the
next!!

On Mar 17, 4:57 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> Bill, thank you very much for taking the time to investigate this.
>

> Pef, I applied Bill's patch and I uploaded the new version tohttp://testng.org/beta.  Can you try it and let us know if this fixes your


> problem?
>
> [Just read Bill's update... ok.  Let's proceed with the initial fix and take
> it from there]
>
> --
> Cédric
>
> On Wed, Mar 17, 2010 at 8:35 AM, Bill Michell

> <bill.mich...@googlemail.com>wrote:

> > On Wed, Mar 17, 2010 at 7:03 AM, Bill Michell <bill.mich...@googlemail.com

> > billmich...@gmail.com
>
> >  --
> > Bill Michell
> > billmich...@gmail.com
>

> >  --
> > You received this message because you are subscribed to the Google Groups
> > "testng-users" group.
> > To post to this group, send email to testng...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > testng-users...@googlegroups.com<testng-users%2Bunsu...@googlegroups.com>

Pef

unread,
Mar 18, 2010, 4:31:19 AM3/18/10
to testng-users
THe holy GRAIL!!!!!!!!!!! :D

Your code snippet solved my problem! I now have my test results in CC
web page! Sooooo Thanksful JohnBurgess!!

In other hand, after my morning tests, I still have a problem with xml
files like yesterday... Hope a solution will be found today, with the
good work done yesterday!

Pef

unread,
Mar 22, 2010, 9:12:13 AM3/22/10
to testng-users
Hi guys!

I'm still facing this XML encoding issue, since my firstly created
class converting files can not be run systematically.
So, some tests results do not appear in Cruise Control summary.

Any solutions for that?

Thanks

Reply all
Reply to author
Forward
0 new messages