Closed
Description
Describe the bug
When an utPLSQL output contains a CDATA section, then the ut_realtime_reporter
produces an invalid XML message. Such a message cannot be processed by consumers such as the SQL Developer extension.
This is related to utPLSQL/utPLSQL-SQLDeveloper#107.
Provide version info
19.0.0.0.0
19.0.0
PL/SQL procedure successfully completed.
UT_VERSION
------------------------------------------------------------
v3.1.11.3380-develop
BANNER BANNER_FULL BANNER_LEGACY CON_ID
-------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ----------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production 0
Version 19.7.0.0.0
PARAMETER VALUE
------------------------------ ----------------------------------------------------------------
NLS_LANGUAGE AMERICAN
NLS_TERRITORY SWITZERLAND
NLS_CURRENCY SFr.
NLS_ISO_CURRENCY SWITZERLAND
NLS_NUMERIC_CHARACTERS .,
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD.MM.YYYY HH24:MI:SS
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT DD.MM.RR HH24:MI:SSXFF
PARAMETER VALUE
------------------------------ ----------------------------------------------------------------
NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
NLS_TIMESTAMP_TZ_FORMAT DD.MM.RR HH24:MI:SSXFF TZR
NLS_DUAL_CURRENCY SF
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
17 rows selected.
PORT_STRING
------------------------------------------------------------
x86_64/Linux 2.4.xx
To Reproduce
1. Create Test Package
CREATE OR REPLACE PACKAGE junit_utplsql_test2_pkg is
--%suite(JUnit testing)
--%suitepath(b)\n
--%test(test XML with nested CDATA)
PROCEDURE test_nested_cdata;
END;
/
CREATE OR REPLACE PACKAGE BODY junit_utplsql_test2_pkg IS
PROCEDURE test_nested_cdata IS
BEGIN
dbms_output.put_line('nested cdata block: <![CDATA[...]]>, to be handled.');
ut.expect(1).to_equal(1);
END;
END;
/
2. Run Test
DECLARE
l_reporter ut_realtime_reporter := ut_realtime_reporter();
BEGIN
l_reporter.set_reporter_id('12345');
l_reporter.output_buffer.init();
sys.dbms_output.enable(NULL);
ut_runner.run(
a_paths => ut_varchar2_list('junit_utplsql_test2_pkg'),
a_reporters => ut_reporters(l_reporter)
);
sys.dbms_output.disable;
END;
/
3. Consume wrong XML message
WITH
FUNCTION reporter return ut_realtime_reporter IS
l_reporter ut_realtime_reporter := ut_realtime_reporter();
BEGIN
l_reporter.set_reporter_id('12345');
RETURN l_reporter;
END;
SELECT text
FROM TABLE(reporter().get_lines())
WHERE item_type = 'post-test'
/
This produces the following output:
<?xml version="1.0"?>
<event type="post-test">
<test id="junit_utplsql_test2_pkg.test_nested_cdata">
<testNumber>1</testNumber>
<totalNumberOfTests>1</totalNumberOfTests>
<startTime>2020-06-04T10:47:00.245501</startTime>
<endTime>2020-06-04T10:47:00.250778</endTime>
<executionTime>.005277</executionTime>
<counter>
<disabled>0</disabled>
<success>1</success>
<failure>0</failure>
<error>0</error>
<warning>0</warning>
</counter>
<serverOutput><![CDATA[nested cdata block: <![CDATA[...]]>, to be handled.
]]></serverOutput>
</test>
</event>
This is not a valid XML document. You can go to https://www.xmlvalidation.com/ and paste the result there for details. The reason is the nested CDATA section.
Expected behavior
Produce a valid XML document. Always.