44import com .beust .jcommander .Parameters ;
55import org .utplsql .api .*;
66import org .utplsql .api .compatibility .CompatibilityProxy ;
7+ import org .utplsql .api .compatibility .OptionalFeatures ;
78import org .utplsql .api .exception .DatabaseNotCompatibleException ;
89import org .utplsql .api .exception .SomeTestsFailedException ;
910import org .utplsql .api .reporter .Reporter ;
@@ -82,6 +83,8 @@ public class RunCommand {
8283 "most actual. Use this if you use CLI with a development version of utPLSQL-framework" )
8384 private boolean skipCompatibilityCheck = false ;
8485
86+ private CompatibilityProxy compatibilityProxy ;
87+
8588 public ConnectionInfo getConnectionInfo () {
8689 return connectionInfoList .get (0 );
8790 }
@@ -92,7 +95,7 @@ public List<String> getTestPaths() {
9295
9396 public int run () throws Exception {
9497
95- checkOracleJDBCExists ();
98+ RunCommandChecker . checkOracleJDBCExists ();
9699
97100 final ConnectionInfo ci = getConnectionInfo ();
98101
@@ -113,10 +116,10 @@ public int run() throws Exception {
113116 try (Connection conn = ci .getConnection ()) {
114117
115118 // Check if orai18n exists if database version is 11g
116- checkOracleI18nExists (ci .getOracleDatabaseVersion (conn ));
119+ RunCommandChecker . checkOracleI18nExists (ci .getOracleDatabaseVersion (conn ));
117120
118121 // First of all do a compatibility check and fail-fast
119- checkFrameworkCompatibility (conn );
122+ compatibilityProxy = checkFrameworkCompatibility (conn );
120123
121124 reporterList = initReporters (conn , reporterOptionsList );
122125
@@ -129,6 +132,12 @@ public int run() throws Exception {
129132 }
130133 }
131134
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+
132141 ExecutorService executorService = Executors .newFixedThreadPool (1 + reporterList .size ());
133142
134143 // Run tests.
@@ -268,7 +277,7 @@ public List<ReporterOptions> getReporterOptionsList() {
268277 * @param conn Active Connection
269278 * @throws SQLException
270279 */
271- private void checkFrameworkCompatibility (Connection conn ) throws SQLException {
280+ private CompatibilityProxy checkFrameworkCompatibility (Connection conn ) throws SQLException {
272281
273282 CompatibilityProxy proxy = new CompatibilityProxy (conn , skipCompatibilityCheck );
274283
@@ -279,6 +288,8 @@ private void checkFrameworkCompatibility(Connection conn) throws SQLException {
279288 System .out .println ("Skipping Compatibility check with framework version, expecting the latest version " +
280289 "to be installed in database" );
281290 }
291+
292+ return proxy ;
282293 }
283294
284295 public FileMapperOptions getMapperOptions (List <String > mappingParams , List <String > filePaths ) {
@@ -328,33 +339,14 @@ public FileMapperOptions getMapperOptions(List<String> mappingParams, List<Strin
328339 return mapperOptions ;
329340 }
330341
331-
332- /** Checks that ojdbc library exists
342+ /** Returns the version of the database framework if available
333343 *
344+ * @return
334345 */
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 ();
346349
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 ;
359351 }
360352}
0 commit comments