Skip to content

Commit 76ba799

Browse files
authored
Merge pull request #71 from utPLSQL/feature/improvements_and_refactoring
* Add some basic logging * Add exact version numbers for some optional features * get rid of enabling DBMSOutput
2 parents c72bef0 + 92d027e commit 76ba799

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
<artifactId>jsr305</artifactId>
4242
<version>3.0.2</version>
4343
</dependency>
44+
<dependency>
45+
<groupId>org.slf4j</groupId>
46+
<artifactId>slf4j-api</artifactId>
47+
<version>1.7.25</version>
48+
</dependency>
49+
50+
<!-- Tests -->
4451
<dependency>
4552
<groupId>org.junit.jupiter</groupId>
4653
<artifactId>junit-jupiter-api</artifactId>
@@ -53,6 +60,13 @@
5360
<version>${junit.jupiter.version}</version>
5461
<scope>test</scope>
5562
</dependency>
63+
64+
<dependency>
65+
<groupId>ch.qos.logback</groupId>
66+
<artifactId>logback-classic</artifactId>
67+
<version>1.2.3</version>
68+
<scope>test</scope>
69+
</dependency>
5670
</dependencies>
5771

5872
<repositories>

src/main/java/org/utplsql/api/TestRunner.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.utplsql.api;
22

3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
35
import org.utplsql.api.compatibility.CompatibilityProxy;
46
import org.utplsql.api.db.DatabaseInformation;
57
import org.utplsql.api.db.DefaultDatabaseInformation;
@@ -24,6 +26,8 @@
2426
*/
2527
public class TestRunner {
2628

29+
private static final Logger logger = LoggerFactory.getLogger(TestRunner.class);
30+
2731
private final TestRunnerOptions options = new TestRunnerOptions();
2832
private CompatibilityProxy compatibilityProxy;
2933
private ReporterFactory reporterFactory;
@@ -122,9 +126,13 @@ private void delayedAddReporters() {
122126

123127
public void run(Connection conn) throws SQLException {
124128

129+
logger.info("TestRunner initialized");
130+
125131
DatabaseInformation databaseInformation = new DefaultDatabaseInformation();
126132

127133
compatibilityProxy = new CompatibilityProxy(conn, options.skipCompatibilityCheck, databaseInformation);
134+
logger.info("Running on utPLSQL {}", compatibilityProxy.getDatabaseVersion());
135+
128136
if ( reporterFactory == null )
129137
reporterFactory = ReporterFactory.createDefault(compatibilityProxy);
130138

@@ -133,6 +141,7 @@ public void run(Connection conn) throws SQLException {
133141
// First of all check version compatibility
134142
compatibilityProxy.failOnNotCompatible();
135143

144+
logger.info("Initializing reporters");
136145
for (Reporter r : options.reporterList)
137146
validateReporter(conn, r);
138147

@@ -141,12 +150,14 @@ public void run(Connection conn) throws SQLException {
141150
}
142151

143152
if (options.reporterList.isEmpty()) {
153+
logger.info("No reporter given so choosing ut_documentation_reporter");
144154
options.reporterList.add(new DocumentationReporter().init(conn));
145155
}
146156

147-
DBHelper.enableDBMSOutput(conn);
148157
try(TestRunnerStatement testRunnerStatement = compatibilityProxy.getTestRunnerStatement(options, conn)) {
158+
logger.info("Running tests");
149159
testRunnerStatement.execute();
160+
logger.info("Running tests finished.");
150161
} catch (SQLException e) {
151162
if (e.getErrorCode() == SomeTestsFailedException.ERROR_CODE) {
152163
throw new SomeTestsFailedException(e.getMessage(), e);
@@ -157,8 +168,6 @@ else if (e.getErrorCode() == UtPLSQLNotInstalledException.ERROR_CODE) {
157168
else {
158169
throw e;
159170
}
160-
} finally {
161-
DBHelper.disableDBMSOutput(conn);
162171
}
163172
}
164173

src/main/java/org/utplsql/api/compatibility/OptionalFeatures.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
public enum OptionalFeatures {
1010

11-
FAIL_ON_ERROR("3.0.3", null),
12-
FRAMEWORK_COMPATIBILITY_CHECK("3.0.3", null),
13-
CUSTOM_REPORTERS("3.1.0", null);
11+
FAIL_ON_ERROR("3.0.3.1266", null),
12+
FRAMEWORK_COMPATIBILITY_CHECK("3.0.3.1266", null),
13+
CUSTOM_REPORTERS("3.1.0.1849", null);
1414

1515
private final Version minVersion;
1616
private final Version maxVersion;

src/main/java/org/utplsql/api/reporter/Reporter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import oracle.jdbc.OracleTypes;
66
import oracle.sql.Datum;
77
import oracle.sql.ORAData;
8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
810
import org.utplsql.api.compatibility.CompatibilityProxy;
911
import org.utplsql.api.outputBuffer.OutputBuffer;
1012

@@ -18,6 +20,8 @@
1820
*/
1921
public abstract class Reporter implements ORAData {
2022

23+
private static final Logger logger = LoggerFactory.getLogger(Reporter.class);
24+
2125
private String selfType;
2226
private String id;
2327
private Object[] attributes;
@@ -73,6 +77,8 @@ private void initDbReporter( OracleConnection oraConn, ReporterFactory reporterF
7377
Reporter obj = (Reporter) callableStatement.getORAData(1, reporterFactory);
7478

7579
setAttributes(obj.getAttributes());
80+
81+
logger.debug("Database-reporter initialized, Type: {}, ID: {}", selfType, id);
7682
}
7783

7884
protected void setAttributes(Object[] attributes ) {

0 commit comments

Comments
 (0)