Problem with the automatically generated file "testng-results.xml" and the UTF-8 encoding

1,218 views
Skip to first unread message

Daniel

unread,
Dec 2, 2013, 5:24:35 AM12/2/13
to testng...@googlegroups.com
Hi,

I use TestNG togehter with Selenium, Maven, Jenkins, Cucumber and Testlink.
Because of the German special characters "ö,ä,ü,ß" my whole project has the default encoding of "Cp1252" and everything runs smoothly.

But now I got a problem with the encoding.
If I run my Cucumber Selenium tests in my Maven project via Jenkins and the "testng-results.xml" file is getting read for Testlink, I got following error, because there are some German special characters:

FATAL: hudson.util.IOException2: Failed to read C:\...\workspace\target\surefire-reports\testng-results.xml
hudson.plugins.testlink.result.ResultSeekerException: hudson.util.IOException2: Failed to read C:\...\workspace\target\surefire-reports\testng-results.xml
    at hudson.plugins.testlink.result.JUnitCaseClassNameResultSeeker.seek(JUnitCaseClassNameResultSeeker.java:131)
    at hudson.plugins.testlink.TestLinkBuilder.perform(TestLinkBuilder.java:236)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:804)
    at hudson.model.Build$BuildExecution.build(Build.java:199)
    at hudson.model.Build$BuildExecution.doRun(Build.java:160)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:586)
    at hudson.model.Run.execute(Run.java:1593)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:242)
Caused by: hudson.util.IOException2: Failed to read C:\...\workspace\target\surefire-reports\testng-results.xml
    at hudson.tasks.junit.TestResult.parse(TestResult.java:284)
    at hudson.tasks.junit.TestResult.parsePossiblyEmpty(TestResult.java:223)
    at hudson.tasks.junit.TestResult.parse(TestResult.java:158)
    at hudson.tasks.junit.TestResult.parse(TestResult.java:141)
    at hudson.tasks.junit.TestResult.<init>(TestResult.java:117)
    at hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:117)
    at hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:90)
    at hudson.FilePath.act(FilePath.java:905)
    at hudson.FilePath.act(FilePath.java:878)
    at hudson.tasks.junit.JUnitParser.parse(JUnitParser.java:87)
    at hudson.plugins.testlink.result.JUnitCaseClassNameResultSeeker.seek(JUnitCaseClassNameResultSeeker.java:94)
    ... 10 more
Caused by: org.dom4j.DocumentException: Ungültiges Byte 2 von 2-Byte-UTF-8-Sequenz. Nested exception: Ungültiges Byte 2 von 2-Byte-UTF-8-Sequenz.
    at org.dom4j.io.SAXReader.read(SAXReader.java:484)
    at org.dom4j.io.SAXReader.read(SAXReader.java:264)
    at hudson.tasks.junit.SuiteResult.parse(SuiteResult.java:129)
    at hudson.tasks.junit.TestResult.parse(TestResult.java:267)
    ... 20 more
Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Ungültiges Byte 2 von 2-Byte-UTF-8-Sequenz.
    at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.scanData(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanCDATASection(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.dom4j.io.SAXReader.read(SAXReader.java:465)
    ... 23 more
ERROR: An error occured while trying to retrieve the test results: hudson.util.IOException2: Failed to read C:\...\workspace\target\surefire-reports\testng-results.xml
Finished: FAILURE


The automaticly generated "testng-results.xml" file under "target/surefire-reports/" has the file encoding "UTF-8" and the first line in that file is "<?xml version="1.0" encoding="UTF-8"?>".
I guess I can resolve the problem if I find a way to change the automatically used encoding for the "testng-results.xml".

Someone knows how to do this or are there maybe other ways to solve the problem?

ETHALON GmbH
Lilienstrasse 5-9
D-20095 Hamburg
GERMANY
T: +49 40 33300-123
F: +49 40 3330099-123
www.ethalon.de


---------------------------------------------------------------------------------------------------------------------------------
Geschäftsführer: Brigitta Quednau, Jörn Peters,
Firmensitz: Hamburg
Handelsregister Hamburg: Nr.: B 28100,
UST-IDNR.: DE 118557482, ILN: 40 25825 000000
---------------------------------------------------------------------------------------------------------------------------------
Diese E-Mail enthält möglicherweise vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie
bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte
Weitergabe dieser E-Mail ist nicht gestattet.
This email may contain confidential and/or privileged information. If you are not the intended recipient
or have received this email in error please notify the sender immediately and destroy this email.
Any unauthorised copying, disclosure or distribution of the material in this email is strictly forbidden.

Krishnan Mahadevan

unread,
Dec 20, 2013, 3:40:26 AM12/20/13
to testng...@googlegroups.com
Daniel,
The Listener that is responsible for creating "testng-results.xml" is org.testng.reporters.XMLReporter

Within this class, inside the method org.testng.reporters.XMLReporter.generateReport(List<XmlSuite>, List<ISuite>, String)
I noticed this : rootBuffer = new XMLStringBuffer();
This is the buffer that is holding all data to be written into the above xml file.

The constructor for XMLStringBuffer() has been defined as below

  public XMLStringBuffer() {

    init(Buffer.create(), "", "1.0", "UTF-8");

  }


I guess that is why you are noticing this behavior.

So perhaps you can try something like this :


Disable the default TestNG Reporters.

Sub-class XMLReporter

override generateReport() method and modify it to suite your need.

Hope that helps







Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages