Skip to content

Commit 4317e4e

Browse files
committed
Enable DBMS-Output and use some new Compatibility-Proxy functions
Fixes #136 Fixes #137
1 parent 8501d6a commit 4317e4e

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

src/main/java/org/utplsql/cli/RunCommand.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ public class RunCommand implements ICommand {
120120
description = "Sets the timeout in minutes after which the cli will abort. Default 60")
121121
private int timeoutInMinutes = 60;
122122

123+
@Parameter(
124+
names = {"-dbout", "--dbms_output"},
125+
description = "Enables DBMS_OUTPUT for the TestRunner (default: DISABLED)"
126+
)
127+
private boolean enableDbmsOutput = false;
128+
123129
private CompatibilityProxy compatibilityProxy;
124130
private ReporterFactory reporterFactory;
125131
private ReporterManager reporterManager;
@@ -157,15 +163,15 @@ public int doRun() throws OracleCreateStatmenetStuckException {
157163
reporterList = initReporters(dataSource);
158164

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

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

167173
// Run tests.
168-
Future<Boolean> future = executorService.submit(new RunTestRunnerTask(dataSource, newTestRunner(reporterList)));
174+
Future<Boolean> future = executorService.submit(new RunTestRunnerTask(dataSource, newTestRunner(reporterList), enableDbmsOutput));
169175

170176
// Gather each reporter results on a separate thread.
171177
getReporterManager().startReporterGatherers(executorService, dataSource);
@@ -278,7 +284,7 @@ private void initDatabase(DataSource dataSource) throws SQLException {
278284
// First of all do a compatibility check and fail-fast
279285
compatibilityProxy = checkFrameworkCompatibility(conn);
280286

281-
logger.info("Successfully connected to database. UtPLSQL core: {}", compatibilityProxy.getDatabaseVersion());
287+
logger.info("Successfully connected to database. UtPLSQL core: {}", compatibilityProxy.getVersionDescription());
282288
logger.info("Oracle-Version: {}", new DefaultDatabaseInformation().getOracleVersion(conn));
283289
}
284290
catch (SQLException e) {

src/main/java/org/utplsql/cli/RunTestRunnerTask.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
5+
import org.utplsql.api.DBHelper;
56
import org.utplsql.api.TestRunner;
67
import org.utplsql.api.exception.OracleCreateStatmenetStuckException;
78
import org.utplsql.api.exception.SomeTestsFailedException;
@@ -24,17 +25,20 @@ public class RunTestRunnerTask implements Callable<Boolean> {
2425
private static final Logger logger = LoggerFactory.getLogger(RunTestRunnerTask.class);
2526
private DataSource dataSource;
2627
private TestRunner testRunner;
28+
private boolean enableDmbsOutput;
2729

28-
RunTestRunnerTask(DataSource dataSource, TestRunner testRunner) {
30+
RunTestRunnerTask(DataSource dataSource, TestRunner testRunner, boolean enableDmbsOutput) {
2931
this.dataSource = dataSource;
3032
this.testRunner = testRunner;
33+
this.enableDmbsOutput = enableDmbsOutput;
3134
}
3235

3336
@Override
3437
public Boolean call() throws Exception {
3538
Connection conn = null;
3639
try {
3740
conn = dataSource.getConnection();
41+
if ( enableDmbsOutput ) DBHelper.enableDBMSOutput(conn);
3842
logger.info("Running tests now.");
3943
logger.info("--------------------------------------");
4044
testRunner.run(conn);
@@ -54,6 +58,7 @@ public Boolean call() throws Exception {
5458
} finally {
5559
if ( conn != null ) {
5660
try {
61+
if ( enableDmbsOutput ) DBHelper.disableDBMSOutput(conn);
5762
conn.close();
5863
} catch (SQLException e) {
5964
logger.error(e.getMessage(), e);

src/test/java/org/utplsql/cli/RunCommandIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,14 @@ void run_MultipleReporters() throws Exception {
6565
}
6666

6767

68+
@Test
69+
void run_withDbmsOutputEnabled() throws Exception {
70+
71+
int result = TestHelper.runApp("run",
72+
TestHelper.getConnectionString(),
73+
"-dbout",
74+
"--failure-exit-code=2");
75+
76+
assertValidReturnCode(result);
77+
}
6878
}

0 commit comments

Comments
 (0)