Skip to content

Feature/improvements and refactoring #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>

<!-- Tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand All @@ -53,6 +60,13 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<repositories>
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/org/utplsql/api/TestRunner.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.utplsql.api;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.utplsql.api.compatibility.CompatibilityProxy;
import org.utplsql.api.db.DatabaseInformation;
import org.utplsql.api.db.DefaultDatabaseInformation;
Expand All @@ -24,6 +26,8 @@
*/
public class TestRunner {

private static final Logger logger = LoggerFactory.getLogger(TestRunner.class);

private final TestRunnerOptions options = new TestRunnerOptions();
private CompatibilityProxy compatibilityProxy;
private ReporterFactory reporterFactory;
Expand Down Expand Up @@ -122,9 +126,13 @@ private void delayedAddReporters() {

public void run(Connection conn) throws SQLException {

logger.info("TestRunner initialized");

DatabaseInformation databaseInformation = new DefaultDatabaseInformation();

compatibilityProxy = new CompatibilityProxy(conn, options.skipCompatibilityCheck, databaseInformation);
logger.info("Running on utPLSQL {}", compatibilityProxy.getDatabaseVersion());

if ( reporterFactory == null )
reporterFactory = ReporterFactory.createDefault(compatibilityProxy);

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

logger.info("Initializing reporters");
for (Reporter r : options.reporterList)
validateReporter(conn, r);

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

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

DBHelper.enableDBMSOutput(conn);
try(TestRunnerStatement testRunnerStatement = compatibilityProxy.getTestRunnerStatement(options, conn)) {
logger.info("Running tests");
testRunnerStatement.execute();
logger.info("Running tests finished.");
} catch (SQLException e) {
if (e.getErrorCode() == SomeTestsFailedException.ERROR_CODE) {
throw new SomeTestsFailedException(e.getMessage(), e);
Expand All @@ -157,8 +168,6 @@ else if (e.getErrorCode() == UtPLSQLNotInstalledException.ERROR_CODE) {
else {
throw e;
}
} finally {
DBHelper.disableDBMSOutput(conn);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

public enum OptionalFeatures {

FAIL_ON_ERROR("3.0.3", null),
FRAMEWORK_COMPATIBILITY_CHECK("3.0.3", null),
CUSTOM_REPORTERS("3.1.0", null);
FAIL_ON_ERROR("3.0.3.1266", null),
FRAMEWORK_COMPATIBILITY_CHECK("3.0.3.1266", null),
CUSTOM_REPORTERS("3.1.0.1849", null);

private final Version minVersion;
private final Version maxVersion;
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/utplsql/api/reporter/Reporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import oracle.jdbc.OracleTypes;
import oracle.sql.Datum;
import oracle.sql.ORAData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.utplsql.api.compatibility.CompatibilityProxy;
import org.utplsql.api.outputBuffer.OutputBuffer;

Expand All @@ -18,6 +20,8 @@
*/
public abstract class Reporter implements ORAData {

private static final Logger logger = LoggerFactory.getLogger(Reporter.class);

private String selfType;
private String id;
private Object[] attributes;
Expand Down Expand Up @@ -73,6 +77,8 @@ private void initDbReporter( OracleConnection oraConn, ReporterFactory reporterF
Reporter obj = (Reporter) callableStatement.getORAData(1, reporterFactory);

setAttributes(obj.getAttributes());

logger.debug("Database-reporter initialized, Type: {}, ID: {}", selfType, id);
}

protected void setAttributes(Object[] attributes ) {
Expand Down