Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9c7f855

Browse files
authored
Merge pull request#57 from utPLSQL/feature/pass_client_charset_to_xml_and_html
Feature/pass client charset to xml and html
2 parentsebd4cdb +ff0b270 commit9c7f855

File tree

8 files changed

+105
-4
lines changed

8 files changed

+105
-4
lines changed

‎src/main/java/org/utplsql/api/TestRunner.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,15 @@ private void validateReporter(Connection conn, Reporter reporter) throws SQLExce
180180
reporter.init(conn,compatibilityProxy,reporterFactory);
181181
}
182182

183+
/** Returns the databaseVersion the TestRunner was run against
184+
*
185+
* @return Version of the database the TestRunner was run against
186+
*/
187+
publicVersiongetUsedDatabaseVersion() {
188+
if (compatibilityProxy !=null )
189+
returncompatibilityProxy.getDatabaseVersion();
190+
else
191+
returnnull;
192+
}
193+
183194
}

‎src/main/java/org/utplsql/api/TestRunnerOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
importorg.utplsql.api.reporter.Reporter;
44

5+
importjava.nio.charset.Charset;
6+
importjava.nio.charset.StandardCharsets;
57
importjava.util.ArrayList;
68
importjava.util.List;
79

@@ -22,4 +24,5 @@ public class TestRunnerOptions {
2224
publicFileMapperOptionstestMappingOptions;
2325
publicbooleanfailOnErrors =false;
2426
publicbooleanskipCompatibilityCheck =false;
27+
publicStringclientCharacterSet =Charset.defaultCharset().toString();
2528
}

‎src/main/java/org/utplsql/api/testRunner/AbstractTestRunnerStatement.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public AbstractTestRunnerStatement(TestRunnerOptions options, Connection conn) t
3030

3131
protectedabstractStringgetSql();
3232

33-
protectedvoidcreateStatement()throwsSQLException {
33+
protectedintcreateStatement()throwsSQLException {
3434

3535
OracleConnectionoraConn =conn.unwrap(OracleConnection.class);
3636

@@ -82,6 +82,8 @@ protected void createStatement() throws SQLException {
8282
callableStatement.setArray(
8383
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_VARCHAR2_LIST,options.excludeObjects.toArray()));
8484
}
85+
86+
returnparamIdx;
8587
}
8688

8789
publicvoidexecute()throwsSQLException {

‎src/main/java/org/utplsql/api/testRunner/ActualTestRunnerStatement.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ protected String getSql() {
3333
"a_test_file_mappings => ?, " +
3434
"a_include_objects => ?, " +
3535
"a_exclude_objects => ?, " +
36-
"a_fail_on_errors => " +failOnErrors +"); " +
36+
"a_fail_on_errors => " +failOnErrors +", " +
37+
"a_client_character_set => ?); " +
3738
"END;";
3839
}
40+
41+
@Override
42+
protectedintcreateStatement()throwsSQLException {
43+
intcurParamIdx =super.createStatement();
44+
45+
callableStatement.setString(++curParamIdx,options.clientCharacterSet);
46+
47+
returncurParamIdx;
48+
}
3949
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
packageorg.utplsql.api.testRunner;
2+
3+
importorg.utplsql.api.TestRunnerOptions;
4+
5+
importjava.sql.Connection;
6+
importjava.sql.SQLException;
7+
8+
/** TestRunner-Statement for Framework version before 3.0.3
9+
* Does not know about client character set
10+
*
11+
* @author pesse
12+
*/
13+
classPre312TestRunnerStatementextendsAbstractTestRunnerStatement {
14+
15+
publicPre312TestRunnerStatement(TestRunnerOptionsoptions,Connectionconnection )throwsSQLException {
16+
super(options,connection);
17+
}
18+
19+
@Override
20+
protectedStringgetSql() {
21+
// Workaround because Oracle JDBC doesn't support passing boolean to stored procedures.
22+
StringcolorConsoleStr =Boolean.toString(options.colorConsole);
23+
StringfailOnErrors =Boolean.toString(options.failOnErrors);
24+
25+
return
26+
"BEGIN " +
27+
"ut_runner.run(" +
28+
"a_paths => ?, " +
29+
"a_reporters => ?, " +
30+
"a_color_console => " +colorConsoleStr +", " +
31+
"a_coverage_schemes => ?, " +
32+
"a_source_file_mappings => ?, " +
33+
"a_test_file_mappings => ?, " +
34+
"a_include_objects => ?, " +
35+
"a_exclude_objects => ?, " +
36+
"a_fail_on_errors => " +failOnErrors +"); " +
37+
"END;";
38+
}
39+
}

‎src/main/java/org/utplsql/api/testRunner/TestRunnerStatementProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public static TestRunnerStatement getCompatibleTestRunnerStatement(Version datab
2929
try {
3030
if (databaseVersion.isLessThan(newVersion("3.0.3")))
3131
stmt =newPre303TestRunnerStatement(options,conn);
32+
elseif (databaseVersion.isLessThan(newVersion("3.1.2")))
33+
stmt =newPre312TestRunnerStatement(options,conn);
3234

3335
}catch (InvalidVersionExceptione ) {}
3436

‎src/test/java/org/utplsql/api/OutputBufferIT.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
packageorg.utplsql.api;
22

33
importorg.junit.jupiter.api.Test;
4+
importorg.utplsql.api.compatibility.CompatibilityProxy;
5+
importorg.utplsql.api.exception.InvalidVersionException;
46
importorg.utplsql.api.reporter.CoreReporters;
57
importorg.utplsql.api.reporter.DefaultReporter;
68
importorg.utplsql.api.reporter.DocumentationReporter;
@@ -9,6 +11,7 @@
911
importjava.io.File;
1012
importjava.io.FileOutputStream;
1113
importjava.io.PrintStream;
14+
importjava.nio.charset.Charset;
1215
importjava.sql.SQLException;
1316
importjava.util.ArrayList;
1417
importjava.util.List;
@@ -106,7 +109,7 @@ public void fetchAllLines() throws SQLException {
106109
}
107110

108111
@Test
109-
publicvoidgetOutputFromSonarReporter()throwsSQLException {
112+
publicvoidgetOutputFromSonarReporter()throwsSQLException,InvalidVersionException {
110113
Reporterreporter =newDefaultReporter(CoreReporters.UT_SONAR_TEST_REPORTER.name(),null).init(newConnection());
111114

112115
newTestRunner()
@@ -119,4 +122,23 @@ public void getOutputFromSonarReporter() throws SQLException {
119122
assertTrue(outputLines.size() >0);
120123
}
121124

125+
@Test
126+
publicvoidsonarReporterHasEncodingSet()throwsSQLException,InvalidVersionException {
127+
CompatibilityProxyproxy =newCompatibilityProxy(newConnection());
128+
129+
if (proxy.getDatabaseVersion().isGreaterOrEqualThan(newVersion("3.1.2"))) {
130+
Reporterreporter =newDefaultReporter(CoreReporters.UT_SONAR_TEST_REPORTER.name(),null).init(getConnection());
131+
132+
TestRunnertr =newTestRunner()
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
}

‎src/test/java/org/utplsql/api/testRunner/TestRunnerStatementProviderIT.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,20 @@ public void testGettingPre303Version() throws SQLException {
2020

2121

2222
@Test
23-
publicvoidtestGettingActualVersion()throwsSQLException {
23+
publicvoidtestGettingPre312Version_from_303()throwsSQLException {
2424
TestRunnerStatementstmt =TestRunnerStatementProvider.getCompatibleTestRunnerStatement(newVersion("3.0.3"),newTestRunnerOptions(),getConnection());
25+
assertEquals(Pre312TestRunnerStatement.class,stmt.getClass());
26+
}
27+
28+
@Test
29+
publicvoidtestGettingPre312Version_from_311()throwsSQLException {
30+
TestRunnerStatementstmt =TestRunnerStatementProvider.getCompatibleTestRunnerStatement(newVersion("3.1.1"),newTestRunnerOptions(),getConnection());
31+
assertEquals(Pre312TestRunnerStatement.class,stmt.getClass());
32+
}
33+
34+
@Test
35+
publicvoidtestGettingActualVersion()throwsSQLException {
36+
TestRunnerStatementstmt =TestRunnerStatementProvider.getCompatibleTestRunnerStatement(newVersion("3.1.2"),newTestRunnerOptions(),getConnection());
2537
assertEquals(ActualTestRunnerStatement.class,stmt.getClass());
2638
}
2739
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp