Skip to content

Commit e1fdabb

Browse files
authoredApr 4, 2019
Merge pull request #141 from utPLSQL/bugfix/dbms_output_enable
Bugfix/dbms output enable
·
v3.1.83.1.9
2 parents e63528b + c246828 commit e1fdabb

File tree

5 files changed

+47
-15
lines changed

5 files changed

+47
-15
lines changed
 

‎README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ utplsql run "my/Username"/"myP@ssword"@connectstring
8686
#### Options
8787
```
8888
-p=suite_path(s) - A suite path or a comma separated list of suite paths for unit test to be executed.
89-
The path(s) can be in one of the following formats:
89+
(--path) The path(s) can be in one of the following formats:
9090
schema[.package[.procedure]]
9191
schema:suite[.suite[.suite][...]][.procedure]
9292
Both formats can be mixed in the list.
9393
If only schema is provided, then all suites owner by that schema are executed.
9494
If -p is omitted, the current schema is used.
9595
9696
-f=format - A reporter to be used for reporting.
97-
If no -f option is provided, the default ut_documentation_reporter is used.
97+
(--format) If no -f option is provided, the default ut_documentation_reporter is used.
9898
See reporters command for possible values
9999
-o=output - Defines file name to save the output from the specified reporter.
100100
If defined, the output is not displayed on screen by default. This can be changed with the -s parameter.
@@ -119,12 +119,14 @@ utplsql run "my/Username"/"myP@ssword"@connectstring
119119
-name_subexpression=subexpression_number
120120
121121
-c - If specified, enables printing of test results in colors as defined by ANSICONSOLE standards.
122-
Works only on reporeters that support colors (ut_documentation_reporter).
122+
(--color) Works only on reporeters that support colors (ut_documentation_reporter).
123123
124-
--failure-exit-code - Override the exit code on failure, defaults to 1. You can set it to 0 to always exit with a success status.
124+
-fcode=code - Override the exit code on failure, defaults to 1. You can set it to 0 to always exit with a success status.
125+
(--failure-exit-code)
125126
126127
-scc - If specified, skips the compatibility-check with the version of the database framework.
127-
If you skip compatibility-check, CLI will expect the most actual framework version
128+
(--skip- If you skip compatibility-check, CLI will expect the most actual framework version
129+
compatibility-check)
128130
129131
-include=pckg_list - Comma-separated object list to include in the coverage report.
130132
Format: [schema.]package[,[schema.]package ...].
@@ -135,13 +137,16 @@ utplsql run "my/Username"/"myP@ssword"@connectstring
135137
See coverage reporting options in framework documentation.
136138
137139
-q - Does not output the informational messages normally printed to console.
138-
Default: false
140+
(--quiet) Default: false
139141
140142
-d - Outputs a load of debug information to console
141-
Default: false
143+
(--debug) Default: false
142144
143-
-t - Sets the timeout in minutes after which the cli will abort.
144-
Default 60
145+
-t=timeInMinutes - Sets the timeout in minutes after which the cli will abort.
146+
(--timeout) Default 60
147+
148+
-dbout - Enables DBMS_OUTPUT in the TestRunner-Session
149+
(--dbms_output) Default: false
145150
```
146151

147152
Parameters -f, -o, -s are correlated. That is parameters -o and -s are controlling outputs for reporter specified by the preceding -f parameter.
@@ -214,13 +219,19 @@ UT_COVERALLS_REPORTER:
214219
Designed for [Coveralls](https://coveralls.io/).
215220
JSON format conforms with specification: https://docs.coveralls.io/api-introduction
216221
222+
UT_DEBUG_REPORTER:
223+
No description available
224+
217225
UT_DOCUMENTATION_REPORTER:
218226
A textual pretty-print of unit test results (usually use for console output)
219227
Provides additional properties lvl and failed
220228
221229
UT_JUNIT_REPORTER:
222230
Provides outcomes in a format conforming with JUnit 4 and above as defined in: https://gist.github.com/kuzuha/232902acab1344d6b578
223231
232+
UT_REALTIME_REPORTER:
233+
Provides test results in a XML format, for clients such as SQL Developer interested in showing progressing details.
234+
224235
UT_SONAR_TEST_REPORTER:
225236
Generates a JSON report providing detailed information on test execution.
226237
Designed for [SonarQube](https://about.sonarqube.com/) to report test execution.

‎pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.utplsql</groupId>
66
<artifactId>cli</artifactId>
7-
<version>3.1.6</version>
7+
<version>3.1.7-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>cli</name>
@@ -22,7 +22,7 @@
2222
<dependency>
2323
<groupId>org.utplsql</groupId>
2424
<artifactId>java-api</artifactId>
25-
<version>3.1.6</version>
25+
<version>3.1.7-SNAPSHOT</version>
2626
<scope>compile</scope>
2727
<exclusions>
2828
<exclusion>

‎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)
Please sign in to comment.