Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added compatibility warning in case Random Execution Order was specified
Also refactored it all into one function
  • Loading branch information
pesse committed Apr 4, 2019
commit d9eb0a78e39af483b730404c5aea8433e5bf6353
28 changes: 23 additions & 5 deletions src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.slf4j.LoggerFactory;
import org.utplsql.api.*;
import org.utplsql.api.compatibility.CompatibilityProxy;
import org.utplsql.api.compatibility.OptionalFeatures;
import org.utplsql.api.db.DefaultDatabaseInformation;
import org.utplsql.api.exception.DatabaseNotCompatibleException;
import org.utplsql.api.exception.OracleCreateStatmenetStuckException;
Expand Down Expand Up @@ -174,11 +175,7 @@ public int doRun() throws OracleCreateStatmenetStuckException {
initDatabase(dataSource);
reporterList = initReporters(dataSource);

// Output a message if --failureExitCode is set but database framework is not capable of
String msg = RunCommandChecker.getCheckFailOnErrorMessage(failureExitCode, compatibilityProxy.getUtPlsqlVersion());
if (msg != null) {
System.out.println(msg);
}
checkForCompatibility(compatibilityProxy.getUtPlsqlVersion());

ExecutorService executorService = Executors.newFixedThreadPool(1 + reporterList.size());

Expand Down Expand Up @@ -240,6 +237,27 @@ public int run() {
return Cli.DEFAULT_ERROR_CODE;
}

private void checkForCompatibility( Version utPlSqlVersion ) {
if (!OptionalFeatures.FAIL_ON_ERROR.isAvailableFor(utPlSqlVersion) && failureExitCode != 1 ) {
System.out.println("You specified option `--failure-exit-code` but your database framework version (" +
utPlSqlVersion.getNormalizedString() + ") is not able to " +
"redirect failureCodes. Please upgrade to a newer version if you want to use that feature.");
}

if ( !OptionalFeatures.RANDOM_EXECUTION_ORDER.isAvailableFor(utPlSqlVersion) && randomTestOrder ) {
System.out.println("You specified option `-random` but your database framework version (" +
utPlSqlVersion.getNormalizedString() + ") is not able to " +
"redirect failureCodes. Please upgrade to a newer version if you want to use that feature.");
}

if ( !OptionalFeatures.RANDOM_EXECUTION_ORDER.isAvailableFor(utPlSqlVersion) && randomTestOrderSeed != null ) {
System.out.println("You specified option `-seed` but your database framework version (" +
utPlSqlVersion.getNormalizedString() + ") is not able to " +
"redirect failureCodes. Please upgrade to a newer version if you want to use that feature.");
}

}

TestRunner newTestRunner( List<Reporter> reporterList) {

final File baseDir = new File("").getAbsoluteFile();
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/org/utplsql/cli/RunCommandChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,4 @@ static void checkOracleI18nExists(Connection con) throws SQLException {
System.out.println("Download from http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html");
}
}

/** Returns a warning message if failureExitCode is specified but database version is too low
*
* @param failureExitCode
* @param databaseVersion
*/
static String getCheckFailOnErrorMessage(int failureExitCode, Version databaseVersion) {
if ( failureExitCode != 1 && !OptionalFeatures.FAIL_ON_ERROR.isAvailableFor(databaseVersion)) {
return "Your database framework version (" + databaseVersion.getNormalizedString() + ") is not able to " +
"redirect failureCodes. Please upgrade to a newer version if you want to use that feature.";
}

return null;
}
}