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

Skip to content
Prev Previous commit
Next Next commit
Little bit of refactoring
we don't want to have another open connection, do we?
  • Loading branch information
pesse authored and Samuel Nitsche committed Nov 10, 2017
commit 34a63e0cfb0307241dcd460d63a9f40616a58e5a
15 changes: 11 additions & 4 deletions src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public List<String> getTestPaths() {
public int run() throws Exception {
final ConnectionInfo ci = getConnectionInfo();

// First of all do a compatibility check and fail-fast
checkFrameworkCompatibility(ci);

final List<ReporterOptions> reporterOptionsList = getReporterOptionsList();
final List<String> testPaths = getTestPaths();
Expand All @@ -118,6 +116,10 @@ public int run() throws Exception {

// Do the reporters initialization, so we can use the id to run and gather results.
try (Connection conn = ci.getConnection()) {

// First of all do a compatibility check and fail-fast
checkFrameworkCompatibility(conn);

for (ReporterOptions ro : reporterOptionsList) {
Reporter reporter = ReporterFactory.createReporter(ro.getReporterName());
reporter.init(conn);
Expand Down Expand Up @@ -212,11 +214,16 @@ public List<ReporterOptions> getReporterOptionsList() {
return reporterOptionsList;
}

private void checkFrameworkCompatibility(ConnectionInfo ci) throws SQLException {
/** Checks whether cli is compatible with the database framework
*
* @param conn Active Connection
* @throws SQLException
*/
private void checkFrameworkCompatibility(Connection conn) throws SQLException {

if ( !skipCompatibilityCheck ) {
try {
DBHelper.failOnVersionCompatibilityCheckFailed(ci.getConnection());
DBHelper.failOnVersionCompatibilityCheckFailed(conn);
} catch (DatabaseNotCompatibleException e) {
System.out.println(e.getMessage());

Expand Down