From ec292cf39d61e6ff8a7806aeba598c65e7b88248 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Sat, 20 May 2017 20:54:11 -0300 Subject: [PATCH 1/6] Add support for multiple reporters --- .../io/github/utplsql/api/TestRunner.java | 24 +++++++++++++++++++ .../api/types/CoverageHTMLReporter.java | 2 +- .../github/utplsql/api/types/CustomTypes.java | 24 ++++++++++--------- .../api/types/DocumentationReporter.java | 2 +- .../io/github/utplsql/api/TestRunnerTest.java | 21 ++++++++++++++++ 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/src/main/java/io/github/utplsql/api/TestRunner.java b/src/main/java/io/github/utplsql/api/TestRunner.java index 79423d7..959aa6c 100644 --- a/src/main/java/io/github/utplsql/api/TestRunner.java +++ b/src/main/java/io/github/utplsql/api/TestRunner.java @@ -1,10 +1,14 @@ package io.github.utplsql.api; import io.github.utplsql.api.types.BaseReporter; +import io.github.utplsql.api.types.CustomTypes; +import oracle.jdbc.OracleConnection; +import java.sql.Array; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.SQLException; +import java.util.List; /** * Created by Vinicius Avellar on 12/04/2017. @@ -27,6 +31,26 @@ public void run(Connection conn, String path, BaseReporter reporter) throws SQLE } } + public void run(Connection conn, List pathList, List reporterList) throws SQLException { + for (BaseReporter r : reporterList) + validateReporter(conn, r); + + OracleConnection oraConn = conn.unwrap(OracleConnection.class); + Array pathArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, pathList.toArray()); + Array reporterArray = oraConn.createARRAY(CustomTypes.UT_REPORTERS, reporterList.toArray()); + + CallableStatement callableStatement = null; + try { + callableStatement = conn.prepareCall("BEGIN ut_runner.run(a_paths => ?, a_reporters => ?); END;"); + callableStatement.setArray(1, pathArray); + callableStatement.setArray(2, reporterArray); + callableStatement.execute(); + } finally { + if (callableStatement != null) + callableStatement.close(); + } + } + /** * Check if the reporter was initialized, if not call reporter.init. * @param conn the database connection diff --git a/src/main/java/io/github/utplsql/api/types/CoverageHTMLReporter.java b/src/main/java/io/github/utplsql/api/types/CoverageHTMLReporter.java index 6bba1ee..da423e7 100644 --- a/src/main/java/io/github/utplsql/api/types/CoverageHTMLReporter.java +++ b/src/main/java/io/github/utplsql/api/types/CoverageHTMLReporter.java @@ -9,7 +9,7 @@ public class CoverageHTMLReporter extends BaseReporter { @Override public String getSQLTypeName() throws SQLException { - return CustomTypes.UT_COVERAGE_HTML_REPORTER.getName(); + return CustomTypes.UT_COVERAGE_HTML_REPORTER; } } diff --git a/src/main/java/io/github/utplsql/api/types/CustomTypes.java b/src/main/java/io/github/utplsql/api/types/CustomTypes.java index 14f3893..0a43d5e 100644 --- a/src/main/java/io/github/utplsql/api/types/CustomTypes.java +++ b/src/main/java/io/github/utplsql/api/types/CustomTypes.java @@ -3,20 +3,22 @@ /** * Database custom data types. */ -public enum CustomTypes { - // Object names must be upper case. - UT_DOCUMENTATION_REPORTER("UT_DOCUMENTATION_REPORTER"), - UT_COVERAGE_HTML_REPORTER("UT_COVERAGE_HTML_REPORTER"), - UT_VARCHAR2_LIST("UT_VARCHAR2_LIST"); +public final class CustomTypes { - private String typeName; + // Object names must be upper case. + public static final String UT_REPORTERS = "UT_REPORTERS"; + public static final String UT_DOCUMENTATION_REPORTER = "UT_DOCUMENTATION_REPORTER"; + public static final String UT_COVERAGE_HTML_REPORTER = "UT_COVERAGE_HTML_REPORTER"; + public static final String UT_VARCHAR2_LIST = "UT_VARCHAR2_LIST"; - CustomTypes(String typeName) { - this.typeName = typeName; - } + private CustomTypes() {} - public String getName() { - return this.typeName; + public static BaseReporter createReporter(String reporterName) { + switch (reporterName.toUpperCase()) { + case UT_DOCUMENTATION_REPORTER: return new DocumentationReporter(); + case UT_COVERAGE_HTML_REPORTER: return new CoverageHTMLReporter(); + } + throw new RuntimeException("Reporter " + reporterName + " not implemented."); } } diff --git a/src/main/java/io/github/utplsql/api/types/DocumentationReporter.java b/src/main/java/io/github/utplsql/api/types/DocumentationReporter.java index 174842e..8fcdd28 100644 --- a/src/main/java/io/github/utplsql/api/types/DocumentationReporter.java +++ b/src/main/java/io/github/utplsql/api/types/DocumentationReporter.java @@ -9,7 +9,7 @@ public class DocumentationReporter extends BaseReporter { @Override public String getSQLTypeName() throws SQLException { - return CustomTypes.UT_DOCUMENTATION_REPORTER.getName(); + return CustomTypes.UT_DOCUMENTATION_REPORTER; } } diff --git a/src/test/java/io/github/utplsql/api/TestRunnerTest.java b/src/test/java/io/github/utplsql/api/TestRunnerTest.java index f273589..c20d895 100644 --- a/src/test/java/io/github/utplsql/api/TestRunnerTest.java +++ b/src/test/java/io/github/utplsql/api/TestRunnerTest.java @@ -2,6 +2,7 @@ import io.github.utplsql.api.rules.DatabaseRule; import io.github.utplsql.api.types.BaseReporter; +import io.github.utplsql.api.types.CoverageHTMLReporter; import io.github.utplsql.api.types.DocumentationReporter; import org.junit.Assert; import org.junit.Rule; @@ -9,6 +10,8 @@ import java.sql.Connection; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; /** * Created by Vinicius on 13/04/2017. @@ -30,4 +33,22 @@ public void runWithDocumentationReporter() { } } + @Test + public void runWithTwoReporters() { + try { + Connection conn = db.newConnection(); + + List pathList = new ArrayList<>(); + pathList.add("app"); + + List reporterList = new ArrayList<>(); + reporterList.add(new DocumentationReporter().init(conn)); + reporterList.add(new CoverageHTMLReporter().init(conn)); + + new TestRunner().run(conn, pathList, reporterList); + } catch (SQLException e) { + Assert.fail(e.getMessage()); + } + } + } From 236a95a6baafaf4ceec288e0e80dc876f4a36f3e Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Moreira Date: Mon, 22 May 2017 13:39:20 -0300 Subject: [PATCH 2/6] Package changes --- .../io/github/utplsql/api/CustomTypes.java | 16 +++++++++++++ .../io/github/utplsql/api/OutputBuffer.java | 8 +++---- .../io/github/utplsql/api/TestRunner.java | 11 ++++----- .../CoverageHTMLReporter.java | 6 +++-- .../DocumentationReporter.java | 6 +++-- .../Reporter.java} | 8 +++---- .../utplsql/api/reporter/ReporterFactory.java | 20 ++++++++++++++++ .../github/utplsql/api/types/CustomTypes.java | 24 ------------------- .../github/utplsql/api/OutputBufferTest.java | 12 +++++----- .../io/github/utplsql/api/TestRunnerTest.java | 14 +++++------ .../utplsql/api/rules/DatabaseRule.java | 4 ++++ 11 files changed, 74 insertions(+), 55 deletions(-) create mode 100644 src/main/java/io/github/utplsql/api/CustomTypes.java rename src/main/java/io/github/utplsql/api/{types => reporter}/CoverageHTMLReporter.java (61%) rename src/main/java/io/github/utplsql/api/{types => reporter}/DocumentationReporter.java (60%) rename src/main/java/io/github/utplsql/api/{types/BaseReporter.java => reporter/Reporter.java} (87%) create mode 100644 src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java delete mode 100644 src/main/java/io/github/utplsql/api/types/CustomTypes.java diff --git a/src/main/java/io/github/utplsql/api/CustomTypes.java b/src/main/java/io/github/utplsql/api/CustomTypes.java new file mode 100644 index 0000000..a25c097 --- /dev/null +++ b/src/main/java/io/github/utplsql/api/CustomTypes.java @@ -0,0 +1,16 @@ +package io.github.utplsql.api; + +/** + * Database custom data reporter. + */ +public final class CustomTypes { + + // Object names must be upper case. + public static final String UT_REPORTERS = "UT_REPORTERS"; + public static final String UT_DOCUMENTATION_REPORTER = "UT_DOCUMENTATION_REPORTER"; + public static final String UT_COVERAGE_HTML_REPORTER = "UT_COVERAGE_HTML_REPORTER"; + public static final String UT_VARCHAR2_LIST = "UT_VARCHAR2_LIST"; + + private CustomTypes() {} + +} diff --git a/src/main/java/io/github/utplsql/api/OutputBuffer.java b/src/main/java/io/github/utplsql/api/OutputBuffer.java index be1e484..6ef8a03 100644 --- a/src/main/java/io/github/utplsql/api/OutputBuffer.java +++ b/src/main/java/io/github/utplsql/api/OutputBuffer.java @@ -1,6 +1,6 @@ package io.github.utplsql.api; -import io.github.utplsql.api.types.BaseReporter; +import io.github.utplsql.api.reporter.Reporter; import oracle.jdbc.OracleTypes; import java.io.PrintStream; @@ -13,13 +13,13 @@ */ public class OutputBuffer { - private BaseReporter reporter; + private Reporter reporter; /** * Creates a new OutputBuffer. * @param reporter the reporter to be used */ - public OutputBuffer(BaseReporter reporter) { + public OutputBuffer(Reporter reporter) { this.reporter = reporter; } @@ -27,7 +27,7 @@ public OutputBuffer(BaseReporter reporter) { * Returns the reporter used by this buffer. * @return the reporter instance */ - public BaseReporter getReporter() { + public Reporter getReporter() { return reporter; } diff --git a/src/main/java/io/github/utplsql/api/TestRunner.java b/src/main/java/io/github/utplsql/api/TestRunner.java index 959aa6c..b491534 100644 --- a/src/main/java/io/github/utplsql/api/TestRunner.java +++ b/src/main/java/io/github/utplsql/api/TestRunner.java @@ -1,7 +1,6 @@ package io.github.utplsql.api; -import io.github.utplsql.api.types.BaseReporter; -import io.github.utplsql.api.types.CustomTypes; +import io.github.utplsql.api.reporter.Reporter; import oracle.jdbc.OracleConnection; import java.sql.Array; @@ -17,7 +16,7 @@ public class TestRunner { public TestRunner() {} - public void run(Connection conn, String path, BaseReporter reporter) throws SQLException { + public void run(Connection conn, String path, Reporter reporter) throws SQLException { validateReporter(conn, reporter); CallableStatement callableStatement = null; try { @@ -31,8 +30,8 @@ public void run(Connection conn, String path, BaseReporter reporter) throws SQLE } } - public void run(Connection conn, List pathList, List reporterList) throws SQLException { - for (BaseReporter r : reporterList) + public void run(Connection conn, List pathList, List reporterList) throws SQLException { + for (Reporter r : reporterList) validateReporter(conn, r); OracleConnection oraConn = conn.unwrap(OracleConnection.class); @@ -57,7 +56,7 @@ public void run(Connection conn, List pathList, List repor * @param reporter the reporter * @throws SQLException any sql exception */ - private void validateReporter(Connection conn, BaseReporter reporter) throws SQLException { + private void validateReporter(Connection conn, Reporter reporter) throws SQLException { if (reporter.getReporterId() == null || reporter.getReporterId().isEmpty()) reporter.init(conn); } diff --git a/src/main/java/io/github/utplsql/api/types/CoverageHTMLReporter.java b/src/main/java/io/github/utplsql/api/reporter/CoverageHTMLReporter.java similarity index 61% rename from src/main/java/io/github/utplsql/api/types/CoverageHTMLReporter.java rename to src/main/java/io/github/utplsql/api/reporter/CoverageHTMLReporter.java index da423e7..039e3b5 100644 --- a/src/main/java/io/github/utplsql/api/types/CoverageHTMLReporter.java +++ b/src/main/java/io/github/utplsql/api/reporter/CoverageHTMLReporter.java @@ -1,11 +1,13 @@ -package io.github.utplsql.api.types; +package io.github.utplsql.api.reporter; + +import io.github.utplsql.api.CustomTypes; import java.sql.SQLException; /** * Created by Vinicius on 13/04/2017. */ -public class CoverageHTMLReporter extends BaseReporter { +public class CoverageHTMLReporter extends Reporter { @Override public String getSQLTypeName() throws SQLException { diff --git a/src/main/java/io/github/utplsql/api/types/DocumentationReporter.java b/src/main/java/io/github/utplsql/api/reporter/DocumentationReporter.java similarity index 60% rename from src/main/java/io/github/utplsql/api/types/DocumentationReporter.java rename to src/main/java/io/github/utplsql/api/reporter/DocumentationReporter.java index 8fcdd28..2d993d8 100644 --- a/src/main/java/io/github/utplsql/api/types/DocumentationReporter.java +++ b/src/main/java/io/github/utplsql/api/reporter/DocumentationReporter.java @@ -1,11 +1,13 @@ -package io.github.utplsql.api.types; +package io.github.utplsql.api.reporter; + +import io.github.utplsql.api.CustomTypes; import java.sql.SQLException; /** * Created by Vinicius on 13/04/2017. */ -public class DocumentationReporter extends BaseReporter { +public class DocumentationReporter extends Reporter { @Override public String getSQLTypeName() throws SQLException { diff --git a/src/main/java/io/github/utplsql/api/types/BaseReporter.java b/src/main/java/io/github/utplsql/api/reporter/Reporter.java similarity index 87% rename from src/main/java/io/github/utplsql/api/types/BaseReporter.java rename to src/main/java/io/github/utplsql/api/reporter/Reporter.java index 7d52a10..007ea63 100644 --- a/src/main/java/io/github/utplsql/api/types/BaseReporter.java +++ b/src/main/java/io/github/utplsql/api/reporter/Reporter.java @@ -1,4 +1,4 @@ -package io.github.utplsql.api.types; +package io.github.utplsql.api.reporter; import io.github.utplsql.api.DBHelper; @@ -8,15 +8,15 @@ /** * Created by Vinicius on 13/04/2017. */ -public abstract class BaseReporter implements SQLData { +public abstract class Reporter implements SQLData { private String selfType; private String reporterId; private java.sql.Date startDate; - public BaseReporter() {} + public Reporter() {} - public BaseReporter init(Connection conn) throws SQLException { + public Reporter init(Connection conn) throws SQLException { setStartDate(new java.sql.Date(Calendar.getInstance().getTimeInMillis())); setReporterId(DBHelper.newSysGuid(conn)); return this; diff --git a/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java b/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java new file mode 100644 index 0000000..0dfe28f --- /dev/null +++ b/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java @@ -0,0 +1,20 @@ +package io.github.utplsql.api.reporter; + +import io.github.utplsql.api.CustomTypes; + +/** + * Created by vinicius.moreira on 22/05/2017. + */ +public final class ReporterFactory { + + private ReporterFactory() {} + + public static Reporter createReporter(String reporterName) { + switch (reporterName.toUpperCase()) { + case CustomTypes.UT_DOCUMENTATION_REPORTER: return new DocumentationReporter(); + case CustomTypes.UT_COVERAGE_HTML_REPORTER: return new CoverageHTMLReporter(); + } + throw new RuntimeException("Reporter " + reporterName + " not implemented."); + } + +} diff --git a/src/main/java/io/github/utplsql/api/types/CustomTypes.java b/src/main/java/io/github/utplsql/api/types/CustomTypes.java deleted file mode 100644 index 0a43d5e..0000000 --- a/src/main/java/io/github/utplsql/api/types/CustomTypes.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.utplsql.api.types; - -/** - * Database custom data types. - */ -public final class CustomTypes { - - // Object names must be upper case. - public static final String UT_REPORTERS = "UT_REPORTERS"; - public static final String UT_DOCUMENTATION_REPORTER = "UT_DOCUMENTATION_REPORTER"; - public static final String UT_COVERAGE_HTML_REPORTER = "UT_COVERAGE_HTML_REPORTER"; - public static final String UT_VARCHAR2_LIST = "UT_VARCHAR2_LIST"; - - private CustomTypes() {} - - public static BaseReporter createReporter(String reporterName) { - switch (reporterName.toUpperCase()) { - case UT_DOCUMENTATION_REPORTER: return new DocumentationReporter(); - case UT_COVERAGE_HTML_REPORTER: return new CoverageHTMLReporter(); - } - throw new RuntimeException("Reporter " + reporterName + " not implemented."); - } - -} diff --git a/src/test/java/io/github/utplsql/api/OutputBufferTest.java b/src/test/java/io/github/utplsql/api/OutputBufferTest.java index c3fe2b0..466a815 100644 --- a/src/test/java/io/github/utplsql/api/OutputBufferTest.java +++ b/src/test/java/io/github/utplsql/api/OutputBufferTest.java @@ -1,8 +1,8 @@ package io.github.utplsql.api; import io.github.utplsql.api.rules.DatabaseRule; -import io.github.utplsql.api.types.BaseReporter; -import io.github.utplsql.api.types.DocumentationReporter; +import io.github.utplsql.api.reporter.Reporter; +import io.github.utplsql.api.reporter.DocumentationReporter; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -23,9 +23,9 @@ public class OutputBufferTest { @Rule public final DatabaseRule db = new DatabaseRule(); - public BaseReporter createReporter() throws SQLException { + public Reporter createReporter() throws SQLException { Connection conn = db.newConnection(); - BaseReporter reporter = new DocumentationReporter().init(conn); + Reporter reporter = new DocumentationReporter().init(conn); System.out.println("Reporter ID: " + reporter.getReporterId()); return reporter; } @@ -35,7 +35,7 @@ public void printAvailableLines() { ExecutorService executorService = Executors.newFixedThreadPool(2); try { - final BaseReporter reporter = createReporter(); + final Reporter reporter = createReporter(); Future task1 = executorService.submit(() -> { try { @@ -91,7 +91,7 @@ public void printAvailableLines() { @Test public void fetchAllLines() { try { - final BaseReporter reporter = createReporter(); + final Reporter reporter = createReporter(); Connection conn = db.newConnection(); new TestRunner().run(conn, "", reporter); diff --git a/src/test/java/io/github/utplsql/api/TestRunnerTest.java b/src/test/java/io/github/utplsql/api/TestRunnerTest.java index c20d895..0b33075 100644 --- a/src/test/java/io/github/utplsql/api/TestRunnerTest.java +++ b/src/test/java/io/github/utplsql/api/TestRunnerTest.java @@ -1,9 +1,9 @@ package io.github.utplsql.api; import io.github.utplsql.api.rules.DatabaseRule; -import io.github.utplsql.api.types.BaseReporter; -import io.github.utplsql.api.types.CoverageHTMLReporter; -import io.github.utplsql.api.types.DocumentationReporter; +import io.github.utplsql.api.reporter.Reporter; +import io.github.utplsql.api.reporter.CoverageHTMLReporter; +import io.github.utplsql.api.reporter.DocumentationReporter; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -25,8 +25,8 @@ public class TestRunnerTest { public void runWithDocumentationReporter() { try { Connection conn = db.newConnection(); - BaseReporter reporter = new DocumentationReporter(); - new TestRunner().run(conn, "", reporter); + Reporter reporter = new DocumentationReporter(); + new TestRunner().run(conn, db.getUser(), reporter); Assert.assertNotNull(reporter.getReporterId()); } catch (SQLException e) { Assert.fail(e.getMessage()); @@ -39,9 +39,9 @@ public void runWithTwoReporters() { Connection conn = db.newConnection(); List pathList = new ArrayList<>(); - pathList.add("app"); + pathList.add(db.getUser()); - List reporterList = new ArrayList<>(); + List reporterList = new ArrayList<>(); reporterList.add(new DocumentationReporter().init(conn)); reporterList.add(new CoverageHTMLReporter().init(conn)); diff --git a/src/test/java/io/github/utplsql/api/rules/DatabaseRule.java b/src/test/java/io/github/utplsql/api/rules/DatabaseRule.java index 7806c2c..da0c35a 100644 --- a/src/test/java/io/github/utplsql/api/rules/DatabaseRule.java +++ b/src/test/java/io/github/utplsql/api/rules/DatabaseRule.java @@ -29,6 +29,10 @@ public DatabaseRule() { connectionList = new ArrayList<>(); } + public String getUser() { + return sUser; + } + public synchronized Connection newConnection() throws SQLException { Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@" + sUrl, sUser, sPass); connectionList.add(conn); From a2fbce8ebee46af39387493a3feb0b45bccc8664 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Mon, 22 May 2017 20:24:59 -0300 Subject: [PATCH 3/6] New reporters --- .../io/github/utplsql/api/CustomTypes.java | 5 ++ .../api/reporter/CoverageHTMLReporter.java | 47 +++++++++++++++++-- .../api/reporter/CoverageSonarReporter.java | 14 ++++++ .../api/reporter/CoverallsReporter.java | 14 ++++++ .../api/reporter/DocumentationReporter.java | 3 -- .../utplsql/api/reporter/ReporterFactory.java | 8 ++-- .../api/reporter/SonarTestReporter.java | 14 ++++++ .../api/reporter/TeamCityReporter.java | 14 ++++++ .../utplsql/api/reporter/XUnitReporter.java | 14 ++++++ 9 files changed, 124 insertions(+), 9 deletions(-) create mode 100644 src/main/java/io/github/utplsql/api/reporter/CoverageSonarReporter.java create mode 100644 src/main/java/io/github/utplsql/api/reporter/CoverallsReporter.java create mode 100644 src/main/java/io/github/utplsql/api/reporter/SonarTestReporter.java create mode 100644 src/main/java/io/github/utplsql/api/reporter/TeamCityReporter.java create mode 100644 src/main/java/io/github/utplsql/api/reporter/XUnitReporter.java diff --git a/src/main/java/io/github/utplsql/api/CustomTypes.java b/src/main/java/io/github/utplsql/api/CustomTypes.java index a25c097..6dc6856 100644 --- a/src/main/java/io/github/utplsql/api/CustomTypes.java +++ b/src/main/java/io/github/utplsql/api/CustomTypes.java @@ -9,6 +9,11 @@ public final class CustomTypes { public static final String UT_REPORTERS = "UT_REPORTERS"; public static final String UT_DOCUMENTATION_REPORTER = "UT_DOCUMENTATION_REPORTER"; public static final String UT_COVERAGE_HTML_REPORTER = "UT_COVERAGE_HTML_REPORTER"; + public static final String UT_TEAMCITY_REPORTER = "UT_TEAMCITY_REPORTER"; + public static final String UT_XUNIT_REPORTER = "UT_XUNIT_REPORTER"; + public static final String UT_COVERALLS_REPORTER = "UT_COVERALLS_REPORTER"; + public static final String UT_COVERAGE_SONAR_REPORTER = "UT_COVERAGE_SONAR_REPORTER"; + public static final String UT_SONAR_TEST_REPORTER = "UT_SONAR_TEST_REPORTER"; public static final String UT_VARCHAR2_LIST = "UT_VARCHAR2_LIST"; private CustomTypes() {} diff --git a/src/main/java/io/github/utplsql/api/reporter/CoverageHTMLReporter.java b/src/main/java/io/github/utplsql/api/reporter/CoverageHTMLReporter.java index 039e3b5..b0a61be 100644 --- a/src/main/java/io/github/utplsql/api/reporter/CoverageHTMLReporter.java +++ b/src/main/java/io/github/utplsql/api/reporter/CoverageHTMLReporter.java @@ -3,15 +3,56 @@ import io.github.utplsql.api.CustomTypes; import java.sql.SQLException; +import java.sql.SQLInput; +import java.sql.SQLOutput; -/** - * Created by Vinicius on 13/04/2017. - */ public class CoverageHTMLReporter extends Reporter { + private String projectName; + private String assetsPath; + + public CoverageHTMLReporter() { + + } + + public CoverageHTMLReporter(String projectName, String assetsPath) { + this.projectName = projectName; + this.assetsPath = assetsPath; + } + @Override public String getSQLTypeName() throws SQLException { return CustomTypes.UT_COVERAGE_HTML_REPORTER; } + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public String getAssetsPath() { + return assetsPath; + } + + public void setAssetsPath(String assetsPath) { + this.assetsPath = assetsPath; + } + + @Override + public void readSQL(SQLInput stream, String typeName) throws SQLException { + super.readSQL(stream, typeName); + setProjectName(stream.readString()); + setAssetsPath(stream.readString()); + } + + @Override + public void writeSQL(SQLOutput stream) throws SQLException { + super.writeSQL(stream); + stream.writeString(getProjectName()); + stream.writeString(getAssetsPath()); + } + } diff --git a/src/main/java/io/github/utplsql/api/reporter/CoverageSonarReporter.java b/src/main/java/io/github/utplsql/api/reporter/CoverageSonarReporter.java new file mode 100644 index 0000000..4f20c49 --- /dev/null +++ b/src/main/java/io/github/utplsql/api/reporter/CoverageSonarReporter.java @@ -0,0 +1,14 @@ +package io.github.utplsql.api.reporter; + +import io.github.utplsql.api.CustomTypes; + +import java.sql.SQLException; + +public class CoverageSonarReporter extends Reporter { + + @Override + public String getSQLTypeName() throws SQLException { + return CustomTypes.UT_COVERAGE_SONAR_REPORTER; + } + +} diff --git a/src/main/java/io/github/utplsql/api/reporter/CoverallsReporter.java b/src/main/java/io/github/utplsql/api/reporter/CoverallsReporter.java new file mode 100644 index 0000000..4173eab --- /dev/null +++ b/src/main/java/io/github/utplsql/api/reporter/CoverallsReporter.java @@ -0,0 +1,14 @@ +package io.github.utplsql.api.reporter; + +import io.github.utplsql.api.CustomTypes; + +import java.sql.SQLException; + +public class CoverallsReporter extends Reporter { + + @Override + public String getSQLTypeName() throws SQLException { + return CustomTypes.UT_COVERALLS_REPORTER; + } + +} diff --git a/src/main/java/io/github/utplsql/api/reporter/DocumentationReporter.java b/src/main/java/io/github/utplsql/api/reporter/DocumentationReporter.java index 2d993d8..c574b04 100644 --- a/src/main/java/io/github/utplsql/api/reporter/DocumentationReporter.java +++ b/src/main/java/io/github/utplsql/api/reporter/DocumentationReporter.java @@ -4,9 +4,6 @@ import java.sql.SQLException; -/** - * Created by Vinicius on 13/04/2017. - */ public class DocumentationReporter extends Reporter { @Override diff --git a/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java b/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java index 0dfe28f..0b920ab 100644 --- a/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java +++ b/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java @@ -2,9 +2,6 @@ import io.github.utplsql.api.CustomTypes; -/** - * Created by vinicius.moreira on 22/05/2017. - */ public final class ReporterFactory { private ReporterFactory() {} @@ -13,6 +10,11 @@ public static Reporter createReporter(String reporterName) { switch (reporterName.toUpperCase()) { case CustomTypes.UT_DOCUMENTATION_REPORTER: return new DocumentationReporter(); case CustomTypes.UT_COVERAGE_HTML_REPORTER: return new CoverageHTMLReporter(); + case CustomTypes.UT_TEAMCITY_REPORTER: return new TeamCityReporter(); + case CustomTypes.UT_XUNIT_REPORTER: return new XUnitReporter(); + case CustomTypes.UT_COVERALLS_REPORTER: return new CoverallsReporter(); + case CustomTypes.UT_COVERAGE_SONAR_REPORTER: return new CoverageSonarReporter(); + case CustomTypes.UT_SONAR_TEST_REPORTER: return new SonarTestReporter(); } throw new RuntimeException("Reporter " + reporterName + " not implemented."); } diff --git a/src/main/java/io/github/utplsql/api/reporter/SonarTestReporter.java b/src/main/java/io/github/utplsql/api/reporter/SonarTestReporter.java new file mode 100644 index 0000000..1544847 --- /dev/null +++ b/src/main/java/io/github/utplsql/api/reporter/SonarTestReporter.java @@ -0,0 +1,14 @@ +package io.github.utplsql.api.reporter; + +import io.github.utplsql.api.CustomTypes; + +import java.sql.SQLException; + +public class SonarTestReporter extends Reporter { + + @Override + public String getSQLTypeName() throws SQLException { + return CustomTypes.UT_SONAR_TEST_REPORTER; + } + +} diff --git a/src/main/java/io/github/utplsql/api/reporter/TeamCityReporter.java b/src/main/java/io/github/utplsql/api/reporter/TeamCityReporter.java new file mode 100644 index 0000000..ef7689d --- /dev/null +++ b/src/main/java/io/github/utplsql/api/reporter/TeamCityReporter.java @@ -0,0 +1,14 @@ +package io.github.utplsql.api.reporter; + +import io.github.utplsql.api.CustomTypes; + +import java.sql.SQLException; + +public class TeamCityReporter extends Reporter { + + @Override + public String getSQLTypeName() throws SQLException { + return CustomTypes.UT_TEAMCITY_REPORTER; + } + +} diff --git a/src/main/java/io/github/utplsql/api/reporter/XUnitReporter.java b/src/main/java/io/github/utplsql/api/reporter/XUnitReporter.java new file mode 100644 index 0000000..aca7d92 --- /dev/null +++ b/src/main/java/io/github/utplsql/api/reporter/XUnitReporter.java @@ -0,0 +1,14 @@ +package io.github.utplsql.api.reporter; + +import io.github.utplsql.api.CustomTypes; + +import java.sql.SQLException; + +public class XUnitReporter extends Reporter { + + @Override + public String getSQLTypeName() throws SQLException { + return CustomTypes.UT_XUNIT_REPORTER; + } + +} From c7a5f44a943b85b65610bba2bd27ea1e40e019ad Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Mon, 22 May 2017 20:44:10 -0300 Subject: [PATCH 4/6] Some reporter creation tests --- .../github/utplsql/api/ReporterNameTest.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/test/java/io/github/utplsql/api/ReporterNameTest.java diff --git a/src/test/java/io/github/utplsql/api/ReporterNameTest.java b/src/test/java/io/github/utplsql/api/ReporterNameTest.java new file mode 100644 index 0000000..34f9118 --- /dev/null +++ b/src/test/java/io/github/utplsql/api/ReporterNameTest.java @@ -0,0 +1,40 @@ +package io.github.utplsql.api; + +import io.github.utplsql.api.reporter.*; +import org.junit.Assert; +import org.junit.Test; + +import java.sql.SQLException; + +public class ReporterNameTest { + + @Test + public void reporterSQLTypeName() throws SQLException { + Assert.assertEquals(CustomTypes.UT_COVERAGE_HTML_REPORTER, new CoverageHTMLReporter().getSQLTypeName()); + Assert.assertEquals(CustomTypes.UT_COVERAGE_SONAR_REPORTER, new CoverageSonarReporter().getSQLTypeName()); + Assert.assertEquals(CustomTypes.UT_COVERALLS_REPORTER, new CoverallsReporter().getSQLTypeName()); + Assert.assertEquals(CustomTypes.UT_DOCUMENTATION_REPORTER, new DocumentationReporter().getSQLTypeName()); + Assert.assertEquals(CustomTypes.UT_SONAR_TEST_REPORTER, new SonarTestReporter().getSQLTypeName()); + Assert.assertEquals(CustomTypes.UT_TEAMCITY_REPORTER, new TeamCityReporter().getSQLTypeName()); + Assert.assertEquals(CustomTypes.UT_XUNIT_REPORTER, new XUnitReporter().getSQLTypeName()); + } + + @Test + public void reporterFactory() { + Assert.assertTrue(ReporterFactory.createReporter(CustomTypes.UT_COVERAGE_HTML_REPORTER) + instanceof CoverageHTMLReporter); + Assert.assertTrue(ReporterFactory.createReporter(CustomTypes.UT_COVERAGE_SONAR_REPORTER) + instanceof CoverageSonarReporter); + Assert.assertTrue(ReporterFactory.createReporter(CustomTypes.UT_COVERALLS_REPORTER) + instanceof CoverallsReporter); + Assert.assertTrue(ReporterFactory.createReporter(CustomTypes.UT_DOCUMENTATION_REPORTER) + instanceof DocumentationReporter); + Assert.assertTrue(ReporterFactory.createReporter(CustomTypes.UT_SONAR_TEST_REPORTER) + instanceof SonarTestReporter); + Assert.assertTrue(ReporterFactory.createReporter(CustomTypes.UT_TEAMCITY_REPORTER) + instanceof TeamCityReporter); + Assert.assertTrue(ReporterFactory.createReporter(CustomTypes.UT_XUNIT_REPORTER) + instanceof XUnitReporter); + } + +} From 9401da7f8732633cb34c7af7cd5d0afc44d8e814 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Tue, 23 May 2017 11:25:42 -0300 Subject: [PATCH 5/6] Change TestRunner usage --- .../java/io/github/utplsql/api/DBHelper.java | 34 +++++- .../io/github/utplsql/api/TestRunner.java | 107 ++++++++++++++---- .../github/utplsql/api/OutputBufferTest.java | 22 +++- .../io/github/utplsql/api/TestRunnerTest.java | 34 +++--- 4 files changed, 146 insertions(+), 51 deletions(-) diff --git a/src/main/java/io/github/utplsql/api/DBHelper.java b/src/main/java/io/github/utplsql/api/DBHelper.java index 348472f..2d2c821 100644 --- a/src/main/java/io/github/utplsql/api/DBHelper.java +++ b/src/main/java/io/github/utplsql/api/DBHelper.java @@ -5,19 +5,45 @@ import java.sql.CallableStatement; import java.sql.Connection; import java.sql.SQLException; +import java.sql.Types; /** - * Created by Vinicius Avellar on 12/04/2017. + * Database utility functions. */ public final class DBHelper { + /** + * Return a new sys_guid from database. + * @param conn the connection + * @return the new id string + * @throws SQLException any database error + */ public static String newSysGuid(Connection conn) throws SQLException { CallableStatement callableStatement = null; try { - callableStatement = conn.prepareCall("BEGIN :id := sys_guid(); END;"); - callableStatement.registerOutParameter(":id", OracleTypes.RAW); + callableStatement = conn.prepareCall("BEGIN ? := sys_guid(); END;"); + callableStatement.registerOutParameter(1, OracleTypes.RAW); callableStatement.executeUpdate(); - return callableStatement.getString(":id"); + return callableStatement.getString(1); + } finally { + if (callableStatement != null) + callableStatement.close(); + } + } + + /** + * Return the current schema name. + * @param conn the connection + * @return the schema name + * @throws SQLException any database error + */ + public static String getCurrentSchema(Connection conn) throws SQLException { + CallableStatement callableStatement = null; + try { + callableStatement = conn.prepareCall("BEGIN ? := sys_context('userenv', 'current_schema'); END;"); + callableStatement.registerOutParameter(1, Types.VARCHAR); + callableStatement.executeUpdate(); + return callableStatement.getString(1); } finally { if (callableStatement != null) callableStatement.close(); diff --git a/src/main/java/io/github/utplsql/api/TestRunner.java b/src/main/java/io/github/utplsql/api/TestRunner.java index b491534..6532476 100644 --- a/src/main/java/io/github/utplsql/api/TestRunner.java +++ b/src/main/java/io/github/utplsql/api/TestRunner.java @@ -1,12 +1,11 @@ package io.github.utplsql.api; +import io.github.utplsql.api.reporter.DocumentationReporter; import io.github.utplsql.api.reporter.Reporter; import oracle.jdbc.OracleConnection; -import java.sql.Array; -import java.sql.CallableStatement; -import java.sql.Connection; -import java.sql.SQLException; +import java.sql.*; +import java.util.ArrayList; import java.util.List; /** @@ -14,35 +13,99 @@ */ public class TestRunner { - public TestRunner() {} + private List pathList = new ArrayList<>(); + private List reporterList = new ArrayList<>(); + private List coverageSchemes = new ArrayList<>(); + private List sourceFiles = new ArrayList<>(); + private List testFiles = new ArrayList<>(); + private List includeObjects = new ArrayList<>(); + private List excludeObjects = new ArrayList<>(); - public void run(Connection conn, String path, Reporter reporter) throws SQLException { - validateReporter(conn, reporter); - CallableStatement callableStatement = null; - try { - callableStatement = conn.prepareCall("BEGIN ut_runner.run(a_path => :path, a_reporter => :reporter); END;"); - callableStatement.setString(":path", path); - callableStatement.setObject(":reporter", reporter); - callableStatement.execute(); - } finally { - if (callableStatement != null) - callableStatement.close(); - } + public TestRunner() { + } + + public TestRunner addPath(String path) { + this.pathList.add(path); + return this; + } + + public TestRunner addPathList(List paths) { + this.pathList.addAll(paths); + return this; + } + + public TestRunner addReporter(Reporter reporter) { + this.reporterList.add(reporter); + return this; + } + + public TestRunner addReporterList(List reporterList) { + this.reporterList.addAll(reporterList); + return this; } - public void run(Connection conn, List pathList, List reporterList) throws SQLException { - for (Reporter r : reporterList) + public TestRunner addCoverageScheme(String coverageScheme) { + this.coverageSchemes.add(coverageScheme); + return this; + } + + public TestRunner withSourceFiles(List sourceFiles) { + this.sourceFiles.addAll(sourceFiles); + return this; + } + + public TestRunner withTestFiles(List testFiles) { + this.testFiles.addAll(testFiles); + return this; + } + + public TestRunner includeObject(String obj) { + this.includeObjects.add(obj); + return this; + } + + public TestRunner excludeObject(String obj) { + this.excludeObjects.add(obj); + return this; + } + + public void run(Connection conn) throws SQLException { + for (Reporter r : this.reporterList) validateReporter(conn, r); + if (this.pathList.isEmpty()) { + this.pathList.add(DBHelper.getCurrentSchema(conn)); + } + + if (this.reporterList.isEmpty()) { + this.reporterList.add(new DocumentationReporter().init(conn)); + } + OracleConnection oraConn = conn.unwrap(OracleConnection.class); - Array pathArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, pathList.toArray()); - Array reporterArray = oraConn.createARRAY(CustomTypes.UT_REPORTERS, reporterList.toArray()); + Array pathArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.pathList.toArray()); + Array reporterArray = oraConn.createARRAY(CustomTypes.UT_REPORTERS, this.reporterList.toArray()); + Array coverageSchemes = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.coverageSchemes.toArray()); + Array sourceFiles = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.sourceFiles.toArray()); + Array testFiles = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.testFiles.toArray()); + Array includeObjects = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.includeObjects.toArray()); + Array excludeObjects = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.excludeObjects.toArray()); CallableStatement callableStatement = null; try { - callableStatement = conn.prepareCall("BEGIN ut_runner.run(a_paths => ?, a_reporters => ?); END;"); + callableStatement = conn.prepareCall( + "BEGIN " + + "ut_runner.run(" + + "a_paths => ?, a_reporters => ?, a_coverage_schemes => ?," + + "a_source_files => ?, a_test_files => ?, " + + "a_include_objects => ?, a_exclude_objects => ?); " + + "END;"); callableStatement.setArray(1, pathArray); callableStatement.setArray(2, reporterArray); + callableStatement.setArray(3, coverageSchemes); + callableStatement.setArray(4, sourceFiles); + callableStatement.setArray(5, testFiles); + callableStatement.setArray(6, includeObjects); + callableStatement.setArray(7, excludeObjects); callableStatement.execute(); } finally { if (callableStatement != null) diff --git a/src/test/java/io/github/utplsql/api/OutputBufferTest.java b/src/test/java/io/github/utplsql/api/OutputBufferTest.java index 466a815..eda4734 100644 --- a/src/test/java/io/github/utplsql/api/OutputBufferTest.java +++ b/src/test/java/io/github/utplsql/api/OutputBufferTest.java @@ -1,12 +1,13 @@ package io.github.utplsql.api; -import io.github.utplsql.api.rules.DatabaseRule; -import io.github.utplsql.api.reporter.Reporter; import io.github.utplsql.api.reporter.DocumentationReporter; +import io.github.utplsql.api.reporter.Reporter; +import io.github.utplsql.api.rules.DatabaseRule; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; +import java.io.File; import java.io.FileOutputStream; import java.io.PrintStream; import java.sql.Connection; @@ -40,7 +41,10 @@ public void printAvailableLines() { Future task1 = executorService.submit(() -> { try { Connection conn = db.newConnection(); - new TestRunner().run(conn, "", reporter); + new TestRunner() + .addPath(db.getUser()) + .addReporter(reporter) + .run(conn); return Boolean.TRUE; } catch (SQLException e) { @@ -50,9 +54,10 @@ public void printAvailableLines() { Future task2 = executorService.submit(() -> { FileOutputStream fileOutStream = null; + File outFile = new File("output.txt"); try { Connection conn = db.newConnection(); - fileOutStream = new FileOutputStream("output.txt"); + fileOutStream = new FileOutputStream(outFile); List printStreams = new ArrayList<>(); printStreams.add(System.out); @@ -65,8 +70,10 @@ public void printAvailableLines() { } catch (SQLException e) { return e; } finally { - if (fileOutStream != null) + if (fileOutStream != null) { fileOutStream.close(); + outFile.delete(); + } } }); @@ -93,7 +100,10 @@ public void fetchAllLines() { try { final Reporter reporter = createReporter(); Connection conn = db.newConnection(); - new TestRunner().run(conn, "", reporter); + new TestRunner() + .addPath(db.getUser()) + .addReporter(reporter) + .run(conn); List outputLines = new OutputBuffer(reporter) .fetchAll(conn); diff --git a/src/test/java/io/github/utplsql/api/TestRunnerTest.java b/src/test/java/io/github/utplsql/api/TestRunnerTest.java index 0b33075..f7f0600 100644 --- a/src/test/java/io/github/utplsql/api/TestRunnerTest.java +++ b/src/test/java/io/github/utplsql/api/TestRunnerTest.java @@ -1,17 +1,13 @@ package io.github.utplsql.api; +import io.github.utplsql.api.reporter.*; import io.github.utplsql.api.rules.DatabaseRule; -import io.github.utplsql.api.reporter.Reporter; -import io.github.utplsql.api.reporter.CoverageHTMLReporter; -import io.github.utplsql.api.reporter.DocumentationReporter; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import java.sql.Connection; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; /** * Created by Vinicius on 13/04/2017. @@ -22,30 +18,30 @@ public class TestRunnerTest { public final DatabaseRule db = new DatabaseRule(); @Test - public void runWithDocumentationReporter() { + public void runWithDefaultParameters() { try { Connection conn = db.newConnection(); - Reporter reporter = new DocumentationReporter(); - new TestRunner().run(conn, db.getUser(), reporter); - Assert.assertNotNull(reporter.getReporterId()); + new TestRunner().run(conn); } catch (SQLException e) { Assert.fail(e.getMessage()); } } @Test - public void runWithTwoReporters() { + public void runWithManyReporters() { try { Connection conn = db.newConnection(); - - List pathList = new ArrayList<>(); - pathList.add(db.getUser()); - - List reporterList = new ArrayList<>(); - reporterList.add(new DocumentationReporter().init(conn)); - reporterList.add(new CoverageHTMLReporter().init(conn)); - - new TestRunner().run(conn, pathList, reporterList); + new TestRunner() + .addPath("ut3") + .addPath(db.getUser()) + .addReporter(new DocumentationReporter().init(conn)) + .addReporter(new CoverageHTMLReporter().init(conn)) + .addReporter(new CoverageSonarReporter().init(conn)) + .addReporter(new CoverallsReporter().init(conn)) + .addReporter(new SonarTestReporter().init(conn)) + .addReporter(new TeamCityReporter().init(conn)) + .addReporter(new XUnitReporter().init(conn)) + .run(conn); } catch (SQLException e) { Assert.fail(e.getMessage()); } From 625a25fe349f4de842ea8a25a1c1133208021844 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Moreira Date: Thu, 25 May 2017 17:02:03 -0300 Subject: [PATCH 6/6] Fix issues reported by sonarlint --- .../java/io/github/utplsql/api/DBHelper.java | 2 ++ .../io/github/utplsql/api/OutputBuffer.java | 2 +- .../io/github/utplsql/api/TestRunner.java | 23 ++++++++----------- .../utplsql/api/reporter/ReporterFactory.java | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/github/utplsql/api/DBHelper.java b/src/main/java/io/github/utplsql/api/DBHelper.java index 2d2c821..f3a880e 100644 --- a/src/main/java/io/github/utplsql/api/DBHelper.java +++ b/src/main/java/io/github/utplsql/api/DBHelper.java @@ -12,6 +12,8 @@ */ public final class DBHelper { + private DBHelper() {} + /** * Return a new sys_guid from database. * @param conn the connection diff --git a/src/main/java/io/github/utplsql/api/OutputBuffer.java b/src/main/java/io/github/utplsql/api/OutputBuffer.java index 6ef8a03..bc12010 100644 --- a/src/main/java/io/github/utplsql/api/OutputBuffer.java +++ b/src/main/java/io/github/utplsql/api/OutputBuffer.java @@ -66,7 +66,7 @@ public void fetchAvailable(Connection conn, Callback cb) throws SQLException { PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { - preparedStatement = conn.prepareCall("SELECT * FROM table(ut_output_buffer.get_lines(?))"); + preparedStatement = conn.prepareStatement("SELECT * FROM table(ut_output_buffer.get_lines(?))"); preparedStatement.setString(1, getReporter().getReporterId()); resultSet = preparedStatement.executeQuery(); diff --git a/src/main/java/io/github/utplsql/api/TestRunner.java b/src/main/java/io/github/utplsql/api/TestRunner.java index 6532476..1489fbf 100644 --- a/src/main/java/io/github/utplsql/api/TestRunner.java +++ b/src/main/java/io/github/utplsql/api/TestRunner.java @@ -21,9 +21,6 @@ public class TestRunner { private List includeObjects = new ArrayList<>(); private List excludeObjects = new ArrayList<>(); - public TestRunner() { - } - public TestRunner addPath(String path) { this.pathList.add(path); return this; @@ -84,11 +81,11 @@ public void run(Connection conn) throws SQLException { OracleConnection oraConn = conn.unwrap(OracleConnection.class); Array pathArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.pathList.toArray()); Array reporterArray = oraConn.createARRAY(CustomTypes.UT_REPORTERS, this.reporterList.toArray()); - Array coverageSchemes = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.coverageSchemes.toArray()); - Array sourceFiles = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.sourceFiles.toArray()); - Array testFiles = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.testFiles.toArray()); - Array includeObjects = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.includeObjects.toArray()); - Array excludeObjects = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.excludeObjects.toArray()); + Array coverageSchemesArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.coverageSchemes.toArray()); + Array sourceFilesArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.sourceFiles.toArray()); + Array testFilesArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.testFiles.toArray()); + Array includeObjectsArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.includeObjects.toArray()); + Array excludeObjectsArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.excludeObjects.toArray()); CallableStatement callableStatement = null; try { @@ -101,11 +98,11 @@ public void run(Connection conn) throws SQLException { "END;"); callableStatement.setArray(1, pathArray); callableStatement.setArray(2, reporterArray); - callableStatement.setArray(3, coverageSchemes); - callableStatement.setArray(4, sourceFiles); - callableStatement.setArray(5, testFiles); - callableStatement.setArray(6, includeObjects); - callableStatement.setArray(7, excludeObjects); + callableStatement.setArray(3, coverageSchemesArray); + callableStatement.setArray(4, sourceFilesArray); + callableStatement.setArray(5, testFilesArray); + callableStatement.setArray(6, includeObjectsArray); + callableStatement.setArray(7, excludeObjectsArray); callableStatement.execute(); } finally { if (callableStatement != null) diff --git a/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java b/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java index 0b920ab..2a4d27d 100644 --- a/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java +++ b/src/main/java/io/github/utplsql/api/reporter/ReporterFactory.java @@ -15,8 +15,8 @@ public static Reporter createReporter(String reporterName) { case CustomTypes.UT_COVERALLS_REPORTER: return new CoverallsReporter(); case CustomTypes.UT_COVERAGE_SONAR_REPORTER: return new CoverageSonarReporter(); case CustomTypes.UT_SONAR_TEST_REPORTER: return new SonarTestReporter(); + default: throw new RuntimeException("Reporter " + reporterName + " not implemented."); } - throw new RuntimeException("Reporter " + reporterName + " not implemented."); } }