Skip to content

Introduce special Exception for when utPLSQL is not installed #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions src/main/java/org/utplsql/api/DBHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import oracle.jdbc.OracleTypes;
import org.utplsql.api.exception.DatabaseNotCompatibleException;
import org.utplsql.api.exception.UtPLSQLNotInstalledException;

import java.sql.*;

Expand Down Expand Up @@ -67,6 +68,11 @@ public static Version getDatabaseFrameworkVersion( Connection conn )
result = new Version(rs.getString(1));

rs.close();
} catch ( SQLException e ) {
if ( e.getErrorCode() == UtPLSQLNotInstalledException.ERROR_CODE )
throw new UtPLSQLNotInstalledException(e);
else
throw e;
}

return result;
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/org/utplsql/api/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.utplsql.api.compatibility.CompatibilityProxy;
import org.utplsql.api.exception.DatabaseNotCompatibleException;
import org.utplsql.api.exception.SomeTestsFailedException;
import org.utplsql.api.exception.UtPLSQLNotInstalledException;
import org.utplsql.api.reporter.DocumentationReporter;
import org.utplsql.api.reporter.Reporter;
import org.utplsql.api.testRunner.TestRunnerStatement;
Expand Down Expand Up @@ -84,7 +85,7 @@ public TestRunner skipCompatibilityCheck( boolean skipCompatibilityCheck )
return this;
}

public void run(Connection conn) throws SomeTestsFailedException, SQLException, DatabaseNotCompatibleException {
public void run(Connection conn) throws SomeTestsFailedException, SQLException, DatabaseNotCompatibleException, UtPLSQLNotInstalledException {

CompatibilityProxy compatibilityProxy = new CompatibilityProxy(conn, options.skipCompatibilityCheck);

Expand Down Expand Up @@ -113,7 +114,11 @@ public void run(Connection conn) throws SomeTestsFailedException, SQLException,
} catch (SQLException e) {
if (e.getErrorCode() == SomeTestsFailedException.ERROR_CODE) {
throw new SomeTestsFailedException(e.getMessage(), e);
} else {
}
else if (e.getErrorCode() == UtPLSQLNotInstalledException.ERROR_CODE) {
throw new UtPLSQLNotInstalledException(e);
}
else {
// If the execution failed by unexpected reasons finishes all reporters,
// this way the users don't need to care about reporters' sessions hanging.
OracleConnection oraConn = conn.unwrap(OracleConnection.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.utplsql.api.exception;

import java.sql.SQLException;

/** Exception to track when utPLSQL framework is not installed or accessible on the used database
*
* @author pesse
*/
public class UtPLSQLNotInstalledException extends SQLException {

public static final int ERROR_CODE = 904;

public UtPLSQLNotInstalledException( SQLException cause ) {
super("utPLSQL framework is not installed on your database or not accessable to the user you are connected with", cause);
}
}