diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24ce410..acb9d0f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,7 +77,7 @@ jobs: MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - name: Publish unit test results - uses: EnricoMi/publish-unit-test-result-action@v1.24 + uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: files: target/**/TEST**.xml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index df550ad..de3bcaf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,11 +38,11 @@ jobs: - name: Install demo project run: sh ${{ github.workspace }}/scripts/2_install_demo_project.sh - - name: Set up JDK 11 + - name: Set up JDK 21 uses: actions/setup-java@v5 with: - java-version: '11' - distribution: 'adopt' + java-version: '21' + distribution: 'temurin' server-id: central server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD @@ -65,7 +65,7 @@ jobs: MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - name: Publish unit test results - uses: EnricoMi/publish-unit-test-result-action@v1.24 + uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: files: target/**/TEST**.xml diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index c257d25..1a60da7 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/pom.xml b/pom.xml index 39808b2..8f9f477 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.utplsql utplsql-java-api - 3.1.17-SNAPSHOT + 3.2.01-SNAPSHOT utPLSQL Java API Java API for running Unit Tests with utPLSQL v3+. @@ -12,10 +12,10 @@ UTF-8 - 1.8 - 1.8 - 5.5.2 - 19.3.0.0 + 11 + 11 + 5.12.2 + 23.7.0.25.01 utplsql https://sonarcloud.io @@ -48,17 +48,17 @@ org.slf4j slf4j-api - 1.7.36 + 2.0.17 com.oracle.database.jdbc - ojdbc8 - 19.3.0.0 + ojdbc11 + ${oracle.jdbc.version} com.oracle.database.nls orai18n - 19.3.0.0 + ${oracle.jdbc.version} com.google.code.findbugs @@ -75,12 +75,14 @@ org.hamcrest hamcrest - 2.1 + 2.2 + test org.mockito mockito-core - 3.0.0 + 5.17.0 + test @@ -92,14 +94,20 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.0 + org.apache.maven.plugins maven-surefire-plugin - 3.1.2 + 3.5.3 org.apache.maven.plugins maven-failsafe-plugin + 3.5.3 @@ -109,10 +117,15 @@ + + org.sonarsource.scanner.maven + sonar-maven-plugin + 5.1.0.4751 + com.amashchenko.maven.plugin gitflow-maven-plugin - 1.18.0 + 1.21.0 true @@ -131,7 +144,7 @@ org.jacoco jacoco-maven-plugin - 0.8.7 + 0.8.13 prepare-agent @@ -162,7 +175,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.3.1 + 3.11.2 attach-javadocs @@ -175,7 +188,7 @@ org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.1 attach-sources @@ -189,7 +202,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.0.1 + 3.2.7 sign-artifacts diff --git a/src/main/java/org/utplsql/api/outputBuffer/AbstractOutputBuffer.java b/src/main/java/org/utplsql/api/outputBuffer/AbstractOutputBuffer.java index 5354db6..86f8e68 100644 --- a/src/main/java/org/utplsql/api/outputBuffer/AbstractOutputBuffer.java +++ b/src/main/java/org/utplsql/api/outputBuffer/AbstractOutputBuffer.java @@ -92,7 +92,7 @@ public void fetchAvailable(Connection conn, Consumer onLineFetched) thro cstmt.execute(); cstmt.setFetchSize(fetchSize); - try (ResultSet resultSet = (ResultSet) cstmt.getObject(1)) { + try (ResultSet resultSet = (ResultSet) cstmt.getObject("lines_cursor")) { while (resultSet.next()) { onLineFetched.accept(resultSet.getString("text")); } @@ -114,7 +114,7 @@ public List fetchAll(Connection conn) throws SQLException { cstmt.execute(); cstmt.setFetchSize(fetchSize); - try (ResultSet resultSet = (ResultSet) cstmt.getObject(1)) { + try (ResultSet resultSet = (ResultSet) cstmt.getObject("lines_cursor")) { List outputLines = new ArrayList<>(); while (resultSet.next()) { diff --git a/src/main/java/org/utplsql/api/outputBuffer/CompatibilityOutputBufferPre310.java b/src/main/java/org/utplsql/api/outputBuffer/CompatibilityOutputBufferPre310.java index 423ed03..ad080e3 100644 --- a/src/main/java/org/utplsql/api/outputBuffer/CompatibilityOutputBufferPre310.java +++ b/src/main/java/org/utplsql/api/outputBuffer/CompatibilityOutputBufferPre310.java @@ -20,9 +20,9 @@ class CompatibilityOutputBufferPre310 extends AbstractOutputBuffer { @Override protected CallableStatement getLinesCursorStatement(Connection conn) throws SQLException { - CallableStatement cstmt = conn.prepareCall("BEGIN ? := ut_output_buffer.get_lines_cursor(?); END;"); - cstmt.registerOutParameter(1, OracleTypes.CURSOR); - cstmt.setString(2, getReporter().getId()); + CallableStatement cstmt = conn.prepareCall("begin :lines_cursor := ut_output_buffer.get_lines_cursor(:reporter_id); end;"); + cstmt.registerOutParameter("lines_cursor", OracleTypes.CURSOR); + cstmt.setString("reporter_id", getReporter().getId()); return cstmt; } } diff --git a/src/main/java/org/utplsql/api/outputBuffer/DefaultOutputBuffer.java b/src/main/java/org/utplsql/api/outputBuffer/DefaultOutputBuffer.java index ccf829c..2c31e5e 100644 --- a/src/main/java/org/utplsql/api/outputBuffer/DefaultOutputBuffer.java +++ b/src/main/java/org/utplsql/api/outputBuffer/DefaultOutputBuffer.java @@ -1,7 +1,6 @@ package org.utplsql.api.outputBuffer; import oracle.jdbc.OracleCallableStatement; -import oracle.jdbc.OracleConnection; import oracle.jdbc.OracleTypes; import org.utplsql.api.reporter.Reporter; @@ -28,10 +27,16 @@ class DefaultOutputBuffer extends AbstractOutputBuffer { @Override protected CallableStatement getLinesCursorStatement(Connection conn) throws SQLException { - OracleConnection oraConn = conn.unwrap(OracleConnection.class); - OracleCallableStatement cstmt = (OracleCallableStatement) oraConn.prepareCall("{? = call ?.get_lines_cursor() }"); - cstmt.registerOutParameter(1, OracleTypes.CURSOR); - cstmt.setORAData(2, getReporter()); + Reporter reporter = getReporter(); + String plsql = "declare" + + " l_rep " + reporter.getTypeName() + " := " + reporter.getTypeName() + "(); " + + "begin" + + " l_rep.set_reporter_id(:reporter_id); " + + " :lines_cursor := l_rep.get_lines_cursor(); " + + "end;"; + OracleCallableStatement cstmt = (OracleCallableStatement) conn.prepareCall(plsql); + cstmt.setString("reporter_id", reporter.getId()); + cstmt.registerOutParameter("lines_cursor", OracleTypes.CURSOR); return cstmt; } } diff --git a/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector310.java b/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector310.java index 091e0f4..d591a85 100644 --- a/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector310.java +++ b/src/main/java/org/utplsql/api/reporter/inspect/ReporterInspector310.java @@ -1,16 +1,8 @@ package org.utplsql.api.reporter.inspect; -import oracle.jdbc.OracleCallableStatement; -import oracle.jdbc.OracleConnection; -import oracle.jdbc.OracleType; -import org.utplsql.api.compatibility.CompatibilityProxy; -import org.utplsql.api.reporter.Reporter; import org.utplsql.api.reporter.ReporterFactory; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.util.*; /** @@ -48,7 +40,7 @@ private ReporterInfo getReporterInfo(String reporterNameWithOwner) throws SQLExc String reporterName = reporterNameWithOwner.substring(reporterNameWithOwner.indexOf(".") + 1).toUpperCase(); ReporterInfo.Type type = ReporterInfo.Type.SQL; - String description = getDescription(reporterName); + String description = getDescription(reporterNameWithOwner); if (registeredReporterFactoryMethods.containsKey(reporterName)) { type = ReporterInfo.Type.SQL_WITH_JAVA; @@ -58,16 +50,12 @@ private ReporterInfo getReporterInfo(String reporterNameWithOwner) throws SQLExc return new ReporterInfo(reporterName, type, description); } - private String getDescription(String reporterName) throws SQLException { - CompatibilityProxy compatibilityProxy = new CompatibilityProxy(connection); - Reporter reporter = reporterFactory.createReporter(reporterName).init(connection, compatibilityProxy, reporterFactory); - OracleConnection oraCon = connection.unwrap(OracleConnection.class); - - try (OracleCallableStatement stmt = (OracleCallableStatement) oraCon.prepareCall("{ ? = call ?.get_description() }")) { - stmt.registerOutParameter(1, OracleType.VARCHAR2); - stmt.setORAData(2, reporter); + private String getDescription(String reporterNameWithOwner) throws SQLException { + String plsql = "DECLARE l_obj " + reporterNameWithOwner + " := " + reporterNameWithOwner + "(); " + + "BEGIN :1 := l_obj.get_description(); END;"; + try (CallableStatement stmt = connection.prepareCall(plsql)) { + stmt.registerOutParameter(1, Types.VARCHAR); stmt.execute(); - return stmt.getString(1); } } diff --git a/src/test/java/org/utplsql/api/JavaApiVersionTest.java b/src/test/java/org/utplsql/api/JavaApiVersionTest.java index 820b71d..afa8e23 100644 --- a/src/test/java/org/utplsql/api/JavaApiVersionTest.java +++ b/src/test/java/org/utplsql/api/JavaApiVersionTest.java @@ -9,6 +9,6 @@ class JavaApiVersionTest { @Test void getJavaApiVersion() { - assertThat(JavaApiVersionInfo.getVersion(), startsWith("3.1")); + assertThat(JavaApiVersionInfo.getVersion(), startsWith("3.2")); } }