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
Enable DBMS-Output and use some new Compatibility-Proxy functions
Fixes #136
Fixes #137
  • Loading branch information
pesse committed Apr 4, 2019
commit 4317e4ec7344fd7fb5cefd2d99d6adbd0b7972ec
12 changes: 9 additions & 3 deletions src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ public class RunCommand implements ICommand {
description = "Sets the timeout in minutes after which the cli will abort. Default 60")
private int timeoutInMinutes = 60;

@Parameter(
names = {"-dbout", "--dbms_output"},
description = "Enables DBMS_OUTPUT for the TestRunner (default: DISABLED)"
)
private boolean enableDbmsOutput = false;

private CompatibilityProxy compatibilityProxy;
private ReporterFactory reporterFactory;
private ReporterManager reporterManager;
Expand Down Expand Up @@ -157,15 +163,15 @@ public int doRun() throws OracleCreateStatmenetStuckException {
reporterList = initReporters(dataSource);

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

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

// Run tests.
Future<Boolean> future = executorService.submit(new RunTestRunnerTask(dataSource, newTestRunner(reporterList)));
Future<Boolean> future = executorService.submit(new RunTestRunnerTask(dataSource, newTestRunner(reporterList), enableDbmsOutput));

// Gather each reporter results on a separate thread.
getReporterManager().startReporterGatherers(executorService, dataSource);
Expand Down Expand Up @@ -278,7 +284,7 @@ private void initDatabase(DataSource dataSource) throws SQLException {
// 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("Successfully connected to database. UtPLSQL core: {}", compatibilityProxy.getVersionDescription());
logger.info("Oracle-Version: {}", new DefaultDatabaseInformation().getOracleVersion(conn));
}
catch (SQLException e) {
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/utplsql/cli/RunTestRunnerTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.utplsql.api.DBHelper;
import org.utplsql.api.TestRunner;
import org.utplsql.api.exception.OracleCreateStatmenetStuckException;
import org.utplsql.api.exception.SomeTestsFailedException;
Expand All @@ -24,17 +25,20 @@ public class RunTestRunnerTask implements Callable<Boolean> {
private static final Logger logger = LoggerFactory.getLogger(RunTestRunnerTask.class);
private DataSource dataSource;
private TestRunner testRunner;
private boolean enableDmbsOutput;

RunTestRunnerTask(DataSource dataSource, TestRunner testRunner) {
RunTestRunnerTask(DataSource dataSource, TestRunner testRunner, boolean enableDmbsOutput) {
this.dataSource = dataSource;
this.testRunner = testRunner;
this.enableDmbsOutput = enableDmbsOutput;
}

@Override
public Boolean call() throws Exception {
Connection conn = null;
try {
conn = dataSource.getConnection();
if ( enableDmbsOutput ) DBHelper.enableDBMSOutput(conn);
logger.info("Running tests now.");
logger.info("--------------------------------------");
testRunner.run(conn);
Expand All @@ -54,6 +58,7 @@ public Boolean call() throws Exception {
} finally {
if ( conn != null ) {
try {
if ( enableDmbsOutput ) DBHelper.disableDBMSOutput(conn);
conn.close();
} catch (SQLException e) {
logger.error(e.getMessage(), e);
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/utplsql/cli/RunCommandIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,14 @@ void run_MultipleReporters() throws Exception {
}


@Test
void run_withDbmsOutputEnabled() throws Exception {

int result = TestHelper.runApp("run",
TestHelper.getConnectionString(),
"-dbout",
"--failure-exit-code=2");

assertValidReturnCode(result);
}
}