4
4
import com .beust .jcommander .Parameters ;
5
5
import org .utplsql .api .*;
6
6
import org .utplsql .api .compatibility .CompatibilityProxy ;
7
+ import org .utplsql .api .compatibility .OptionalFeatures ;
7
8
import org .utplsql .api .exception .DatabaseNotCompatibleException ;
8
9
import org .utplsql .api .exception .SomeTestsFailedException ;
9
10
import org .utplsql .api .reporter .Reporter ;
@@ -82,6 +83,8 @@ public class RunCommand {
82
83
"most actual. Use this if you use CLI with a development version of utPLSQL-framework" )
83
84
private boolean skipCompatibilityCheck = false ;
84
85
86
+ private CompatibilityProxy compatibilityProxy ;
87
+
85
88
public ConnectionInfo getConnectionInfo () {
86
89
return connectionInfoList .get (0 );
87
90
}
@@ -92,7 +95,7 @@ public List<String> getTestPaths() {
92
95
93
96
public int run () throws Exception {
94
97
95
- checkOracleJDBCExists ();
98
+ RunCommandChecker . checkOracleJDBCExists ();
96
99
97
100
final ConnectionInfo ci = getConnectionInfo ();
98
101
@@ -113,10 +116,10 @@ public int run() throws Exception {
113
116
try (Connection conn = ci .getConnection ()) {
114
117
115
118
// Check if orai18n exists if database version is 11g
116
- checkOracleI18nExists (ci .getOracleDatabaseVersion (conn ));
119
+ RunCommandChecker . checkOracleI18nExists (ci .getOracleDatabaseVersion (conn ));
117
120
118
121
// First of all do a compatibility check and fail-fast
119
- checkFrameworkCompatibility (conn );
122
+ compatibilityProxy = checkFrameworkCompatibility (conn );
120
123
121
124
reporterList = initReporters (conn , reporterOptionsList );
122
125
@@ -129,6 +132,12 @@ public int run() throws Exception {
129
132
}
130
133
}
131
134
135
+ // Output a message if --failureExitCode is set but database framework is not capable of
136
+ String msg = RunCommandChecker .getCheckFailOnErrorMessage (failureExitCode , compatibilityProxy .getDatabaseVersion ());
137
+ if ( msg != null ) {
138
+ System .out .println (msg );
139
+ }
140
+
132
141
ExecutorService executorService = Executors .newFixedThreadPool (1 + reporterList .size ());
133
142
134
143
// Run tests.
@@ -268,7 +277,7 @@ public List<ReporterOptions> getReporterOptionsList() {
268
277
* @param conn Active Connection
269
278
* @throws SQLException
270
279
*/
271
- private void checkFrameworkCompatibility (Connection conn ) throws SQLException {
280
+ private CompatibilityProxy checkFrameworkCompatibility (Connection conn ) throws SQLException {
272
281
273
282
CompatibilityProxy proxy = new CompatibilityProxy (conn , skipCompatibilityCheck );
274
283
@@ -279,6 +288,8 @@ private void checkFrameworkCompatibility(Connection conn) throws SQLException {
279
288
System .out .println ("Skipping Compatibility check with framework version, expecting the latest version " +
280
289
"to be installed in database" );
281
290
}
291
+
292
+ return proxy ;
282
293
}
283
294
284
295
public FileMapperOptions getMapperOptions (List <String > mappingParams , List <String > filePaths ) {
@@ -328,33 +339,14 @@ public FileMapperOptions getMapperOptions(List<String> mappingParams, List<Strin
328
339
return mapperOptions ;
329
340
}
330
341
331
-
332
- /** Checks that ojdbc library exists
342
+ /** Returns the version of the database framework if available
333
343
*
344
+ * @return
334
345
*/
335
- private void checkOracleJDBCExists ()
336
- {
337
- if ( !OracleLibraryChecker .checkOjdbcExists () )
338
- {
339
- System .out .println ("Could not find Oracle JDBC driver in classpath. Please download the jar from Oracle website" +
340
- " and copy it to the 'lib' folder of your utPLSQL-cli installation." );
341
- System .out .println ("Download from http://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html" );
342
-
343
- throw new RuntimeException ("Can't run utPLSQL-cli without Oracle JDBC driver" );
344
- }
345
- }
346
+ public Version getDatabaseVersion () {
347
+ if ( compatibilityProxy != null )
348
+ return compatibilityProxy .getDatabaseVersion ();
346
349
347
- /** Checks that orai18n library exists if database is an oracle 11
348
- *
349
- */
350
- private void checkOracleI18nExists (String oracleDatabaseVersion )
351
- {
352
- if ( oracleDatabaseVersion .startsWith ("11." ) && !OracleLibraryChecker .checkOrai18nExists () )
353
- {
354
- System .out .println ("Warning: Could not find Oracle i18n driver in classpath. Depending on the database charset " +
355
- "utPLSQL-cli might not run properly. It is recommended you download " +
356
- "the i18n driver from the Oracle website and copy it to the 'lib' folder of your utPLSQL-cli installation." );
357
- System .out .println ("Download from http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html" );
358
- }
350
+ return null ;
359
351
}
360
352
}
0 commit comments