11package org .utplsql .api ;
22
33import org .junit .jupiter .api .Test ;
4+ import org .utplsql .api .compatibility .CompatibilityProxy ;
5+ import org .utplsql .api .exception .InvalidVersionException ;
46import org .utplsql .api .reporter .CoreReporters ;
57import org .utplsql .api .reporter .DefaultReporter ;
68import org .utplsql .api .reporter .DocumentationReporter ;
911import java .io .File ;
1012import java .io .FileOutputStream ;
1113import java .io .PrintStream ;
14+ import java .nio .charset .Charset ;
1215import java .sql .SQLException ;
1316import java .util .ArrayList ;
1417import java .util .List ;
@@ -106,7 +109,7 @@ public void fetchAllLines() throws SQLException {
106109 }
107110
108111 @ Test
109- public void getOutputFromSonarReporter () throws SQLException {
112+ public void getOutputFromSonarReporter () throws SQLException , InvalidVersionException {
110113 Reporter reporter = new DefaultReporter (CoreReporters .UT_SONAR_TEST_REPORTER .name (), null ).init (newConnection ());
111114
112115 new TestRunner ()
@@ -119,4 +122,23 @@ public void getOutputFromSonarReporter() throws SQLException {
119122 assertTrue (outputLines .size () > 0 );
120123 }
121124
125+ @ Test
126+ public void sonarReporterHasEncodingSet () throws SQLException , InvalidVersionException {
127+ CompatibilityProxy proxy = new CompatibilityProxy (newConnection ());
128+
129+ if ( proxy .getDatabaseVersion ().isGreaterOrEqualThan (new Version ("3.1.2" ))) {
130+ Reporter reporter = new DefaultReporter (CoreReporters .UT_SONAR_TEST_REPORTER .name (), null ).init (getConnection ());
131+
132+ TestRunner tr = new TestRunner ()
133+ .addPath (getUser ())
134+ .addReporter (reporter );
135+
136+ tr .run (getConnection ());
137+
138+ List <String > outputLines = reporter .getOutputBuffer ().fetchAll (getConnection ());
139+
140+ assertTrue (outputLines .get (0 ).contains ("encoding=\" " + Charset .defaultCharset ().toString () + "\" " ));
141+ }
142+
143+ }
122144}
0 commit comments