This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 241649 - org.jdom.IllegalDataException if CDATA ending delimiter is contained in Junit test output of a failed test
Summary: org.jdom.IllegalDataException if CDATA ending delimiter is contained in Junit...
Status: REOPENED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal with 2 votes (vote)
Assignee: Tomas Stupka
URL: http://jira.codehaus.org/browse/SUREF...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-10 15:07 UTC by soettl
Modified: 2017-08-30 12:10 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 203977


Attachments
stacktrace (2.82 KB, text/plain)
2014-02-10 15:07 UTC, soettl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description soettl 2014-02-10 15:07:41 UTC
This issue was reported manually by soettl.
It already has 2 duplicates 


Build: NetBeans IDE 7.4 (Build 201310111528)
VM: Java HotSpot(TM) 64-Bit Server VM, 24.0-b56, Java(TM) SE Runtime Environment, 1.7.0_40-b43
OS: Windows 7

User Comments:
mfriedenhagen: Inspecting a test with XML output on stdout

soettl: If the output of a failed Junit test contains a CDATA ending delimiter ("]]>") an exception is thrown.
This leads to the message 'No tests executed' in the NetBeans Test Results tab.
Seems to happen when NetBeans tries to parse the surefire (2.16) test report.

sample test:
###
package de.isarnet.testresultproblem;

import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
 * Unit test for simple App.
 */
public class AppTest {

    @Test
    public void testApp() {
        System.out.println("blabla ]]>");
        assertTrue(false);
    }
    
}
###




Stacktrace: 
org.jdom.IllegalDataException: The data "blabla ]]>
" is not legal for a JDOM CDATA section: CDATA cannot internally contain a CDATA ending delimiter (]]>).
   at org.jdom.CDATA.setText(CDATA.java:121)
   at org.jdom.CDATA.<init>(CDATA.java:95)
   at org.jdom.DefaultJDOMFactory.cdata(DefaultJDOMFactory.java:97)
   at org.jdom.input.SAXHandler.flushCharacters(SAXHandler.java:652)
   at org.jdom.input.SAXHandler.flushCharacters(SAXHandler.java:623)
   at org.jdom.input.SAXHandler.endElement(SAXHandler.java:678)
Comment 1 soettl 2014-02-10 15:07:43 UTC
Created attachment 144992 [details]
stacktrace
Comment 2 Milos Kleint 2014-02-10 16:33:13 UTC
hmmm, it appears to me that surefire badly escapes the output it puts into the xml file. I'll use your testcase to report upstream.
Comment 3 Milos Kleint 2014-02-11 10:19:13 UTC
I have filed issue at surefire - http://jira.codehaus.org/browse/SUREFIRE-1061.

please note that going back to 2.15 could fix your problem, however be aware of issue http://jira.codehaus.org/browse/SUREFIRE-1020 that introduced the problem but might have fixed other problems in embedding xml in the output. 

wontfix, the problem is in 3rd party software and is not fixable on our side.
Comment 4 soettl 2014-02-11 12:49:52 UTC
o.k. - thanks for the update and your support Milos!
Comment 5 Jesse Glick 2014-09-15 16:29:49 UTC
Still reproducible, and causing an error when running Jenkins tests:

org.jdom.IllegalDataException: The data "Picking up existing exploded jenkins.war at /…/./target/jenkins-for-test
=== Starting …(…Test)
<?xml version="1.0" encoding="utf-8"?>
<html>
  <head>
    <title>
      p1 Config [Jenkins]
    </title>
    <link rel="stylesheet" type="text/css" href="/jenkins/static/d383d9a4/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="/jenkins/static/d383d9a4/css/color.css"/>
    <link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/jenkins/static/d383d9a4/favicon.ico"/>
    <script>
//<![CDATA[
var isRunAsTest=true; var rootURL="/jenkins"; var resURL="/jenkins/static/d383d9a4";
//]]>
    </script>
    …
  </body>
</html>

" is not legal for a JDOM CDATA section: CDATA cannot internally contain a CDATA ending delimiter (]]>).
	at org.jdom.CDATA.setText(CDATA.java:121)
	at org.jdom.CDATA.<init>(CDATA.java:95)
	at org.jdom.DefaultJDOMFactory.cdata(DefaultJDOMFactory.java:97)
	at org.jdom.input.SAXHandler.flushCharacters(SAXHandler.java:652)
	at org.jdom.input.SAXHandler.flushCharacters(SAXHandler.java:623)
	at org.jdom.input.SAXHandler.endElement(SAXHandler.java:678)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2973)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:810)
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:789)
	at org.netbeans.modules.maven.junit.JUnitOutputListenerProvider.generateTest(JUnitOutputListenerProvider.java:527)
	at org.netbeans.modules.maven.junit.JUnitOutputListenerProvider.sequenceEnd(JUnitOutputListenerProvider.java:442)
	at org.netbeans.modules.maven.execute.AbstractOutputHandler.processEnd(AbstractOutputHandler.java:215)
	at org.netbeans.modules.maven.execute.CommandLineOutputHandler$Output.run(CommandLineOutputHandler.java:376)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

I think the bug is in NetBeans (or JDOM), not Surefire. If you open the target/surefire-reports/TEST-*.xml in the editor and Check XML, it passes, because this is well-formed XML. The ‘]]>’ sequence is correctly split between two CDATA sections, which is one common way of escaping text (the other being to use character references in PCDATA).
Comment 6 Exceptions Reporter 2015-09-15 07:32:00 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=203977
Comment 7 markiewb 2016-08-25 22:37:26 UTC
JDOM 1.x issue. See https://github.com/hunterhacker/jdom/pull/124

The maven.embedder module still uses JDOM 1.x. It needs an update to JDOM 2.x