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
Refactoring
  • Loading branch information
pesse committed Feb 7, 2019
commit 6a7d6507607b704b0f99a21553d177838b71912e
55 changes: 31 additions & 24 deletions src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public List<String> getTestPaths() {
return testPaths;
}

public void init() {
void init() {
LoggerConfiguration.configure(logSilent, logDebug);
}

Expand Down Expand Up @@ -166,29 +166,8 @@ public int run() {

final DataSource dataSource = DataSourceProvider.getDataSource(getConnectionInfo(), getReporterManager().getNumberOfReporters() + 1);

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

// Check if orai18n exists if database version is 11g
RunCommandChecker.checkOracleI18nExists(conn);

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

logger.info("Successfully connected to database. UtPLSQL core: " + compatibilityProxy.getDatabaseVersion());
logger.info("Oracle-Version: {}", new DefaultDatabaseInformation().getOracleVersion(conn));

reporterFactory = ReporterFactoryProvider.createReporterFactory(compatibilityProxy);

reporterList = getReporterManager().initReporters(conn, reporterFactory, compatibilityProxy);

} catch (SQLException e) {
if (e.getErrorCode() == 1017 || e.getErrorCode() == 12514) {
throw new DatabaseConnectionFailed(e);
} else {
throw e;
}
}
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.getDatabaseVersion());
Expand Down Expand Up @@ -263,6 +242,34 @@ private void outputMainInformation() {
logger.info("");
}

private void initDatabase(DataSource dataSource) throws SQLException {
try (Connection conn = dataSource.getConnection()) {

// Check if orai18n exists if database version is 11g
RunCommandChecker.checkOracleI18nExists(conn);

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

logger.info("Successfully connected to database. UtPLSQL core: " + compatibilityProxy.getDatabaseVersion());
logger.info("Oracle-Version: {}", new DefaultDatabaseInformation().getOracleVersion(conn));
Comment thread
pesse marked this conversation as resolved.
}
catch (SQLException e) {
if (e.getErrorCode() == 1017 || e.getErrorCode() == 12514) {
throw new DatabaseConnectionFailed(e);
} else {
throw e;
}
}
}

private List<Reporter> initReporters(DataSource dataSource) throws SQLException {
try (Connection conn = dataSource.getConnection()) {
reporterFactory = ReporterFactoryProvider.createReporterFactory(compatibilityProxy);
return getReporterManager().initReporters(conn, reporterFactory, compatibilityProxy);
}
}

/** Returns FileMapperOptions for the first item of a given param list in a baseDir
*
* @param pathParams
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/utplsql/cli/TestRunCommandChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void getCheckFailOnErrorMessage()
assertNotNull(RunCommandChecker.getCheckFailOnErrorMessage(2, new Version("3.0.0")));
assertNotNull(RunCommandChecker.getCheckFailOnErrorMessage(2, new Version("3.0.1")));
assertNotNull(RunCommandChecker.getCheckFailOnErrorMessage(2, new Version("3.0.2")));
assertNull(RunCommandChecker.getCheckFailOnErrorMessage(2, new Version("3.0.3")));
assertNull(RunCommandChecker.getCheckFailOnErrorMessage(2, new Version("3.0.3.1266")));
Comment thread
Pazus marked this conversation as resolved.
assertNull(RunCommandChecker.getCheckFailOnErrorMessage(2, new Version("3.0.4")));
}
}