diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7b3f71b..89ce60a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -49,7 +49,7 @@ jobs:
with:
java-version: '21'
distribution: 'temurin'
- server-id: central
+ server-id: central-snapshots
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 19ea48f..3720936 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -124,3 +124,12 @@ jobs:
tag_name: "v${{ inputs.release_version }}"
name: "Release ${{ inputs.release_version }}"
generate_release_notes: true
+
+ - name: Announce release in org discussions and on utplsql.github.io
+ uses: utPLSQL/.github/actions/announce-release@v1
+ with:
+ project-name: utPLSQL-java-api
+ tag: v${{ inputs.release_version }}
+ discussion-token: ${{ secrets.API_TOKEN_GITHUB }}
+ site-token: ${{ secrets.API_TOKEN_GITHUB }}
+ site-category: utplsql-java-api
diff --git a/pom.xml b/pom.xml
index 35c501d..a45987d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.utplsql
utplsql-java-api
- 3.2.5
+ 3.2.6-SNAPSHOT
utPLSQL Java API
Java API for running Unit Tests with utPLSQL v3+.
@@ -290,7 +290,7 @@
org.sonatype.central
central-publishing-maven-plugin
- 0.10.0
+ 0.12.0
true
central
@@ -305,12 +305,8 @@
- central
+ central-snapshots
https://central.sonatype.com/repository/maven-snapshots/
-
- central
- https://central.sonatype.com
-
diff --git a/src/main/java/org/utplsql/api/TestRunner.java b/src/main/java/org/utplsql/api/TestRunner.java
index 3a3f6e1..448311c 100644
--- a/src/main/java/org/utplsql/api/TestRunner.java
+++ b/src/main/java/org/utplsql/api/TestRunner.java
@@ -170,6 +170,11 @@ public TestRunner oraStuckTimeout(Integer oraStuckTimeout) {
return this;
}
+ public TestRunner supportInfo(boolean supportInfo) {
+ this.options.supportInfo = supportInfo;
+ return this;
+ }
+
public TestRunnerOptions getOptions() {
return options;
}
diff --git a/src/main/java/org/utplsql/api/TestRunnerOptions.java b/src/main/java/org/utplsql/api/TestRunnerOptions.java
index 615e308..ea7851e 100644
--- a/src/main/java/org/utplsql/api/TestRunnerOptions.java
+++ b/src/main/java/org/utplsql/api/TestRunnerOptions.java
@@ -35,6 +35,7 @@ public class TestRunnerOptions {
public Integer randomTestOrderSeed;
public final Set tags = new LinkedHashSet<>();
public Integer oraStuckTimeout = 0;
+ public boolean supportInfo = true;
public String getTagsAsString() {
return String.join(",", tags);
diff --git a/src/main/java/org/utplsql/api/compatibility/OptionalFeatures.java b/src/main/java/org/utplsql/api/compatibility/OptionalFeatures.java
index 8462b95..d210c3c 100644
--- a/src/main/java/org/utplsql/api/compatibility/OptionalFeatures.java
+++ b/src/main/java/org/utplsql/api/compatibility/OptionalFeatures.java
@@ -14,7 +14,8 @@ public enum OptionalFeatures {
CLIENT_CHARACTER_SET("3.1.2.2130", null),
RANDOM_EXECUTION_ORDER("3.1.7.2795", null),
TAGS("3.1.7.3006", null),
- EXPR("3.1.13", null);
+ EXPR("3.1.13", null),
+ SUPPORT_INFO("3.2.4.4648", null);
private final Version minVersion;
private final Version maxVersion;
diff --git a/src/main/java/org/utplsql/api/outputBuffer/AbstractOutputBuffer.java b/src/main/java/org/utplsql/api/outputBuffer/AbstractOutputBuffer.java
index 86f8e68..13608ff 100644
--- a/src/main/java/org/utplsql/api/outputBuffer/AbstractOutputBuffer.java
+++ b/src/main/java/org/utplsql/api/outputBuffer/AbstractOutputBuffer.java
@@ -1,5 +1,6 @@
package org.utplsql.api.outputBuffer;
+import oracle.jdbc.OracleTypes;
import org.utplsql.api.reporter.Reporter;
import java.io.PrintStream;
@@ -79,6 +80,27 @@ public void printAvailable(Connection conn, List printStreams) thro
protected abstract CallableStatement getLinesCursorStatement(Connection conn) throws SQLException;
+ /**
+ * Prepares the given PL/SQL block and binds the :reporter_id and :lines_cursor parameters.
+ * The returned statement must be closed by the caller. It is closed here if binding fails.
+ *
+ * @param conn DB connection
+ * @param plsql PL/SQL block using the :reporter_id and :lines_cursor bind variables
+ * @return the prepared statement
+ * @throws SQLException any sql errors
+ */
+ protected CallableStatement prepareLinesCursorStatement(Connection conn, String plsql) throws SQLException {
+ CallableStatement cstmt = conn.prepareCall(plsql);
+ try {
+ cstmt.setString("reporter_id", reporter.getId());
+ cstmt.registerOutParameter("lines_cursor", OracleTypes.CURSOR);
+ return cstmt;
+ } catch (SQLException | RuntimeException e) {
+ cstmt.close();
+ throw e;
+ }
+ }
+
/**
* Print the lines as soon as they are produced and call the callback passing the new line.
*
diff --git a/src/main/java/org/utplsql/api/outputBuffer/CompatibilityOutputBufferPre310.java b/src/main/java/org/utplsql/api/outputBuffer/CompatibilityOutputBufferPre310.java
index ad080e3..6fd6025 100644
--- a/src/main/java/org/utplsql/api/outputBuffer/CompatibilityOutputBufferPre310.java
+++ b/src/main/java/org/utplsql/api/outputBuffer/CompatibilityOutputBufferPre310.java
@@ -1,6 +1,5 @@
package org.utplsql.api.outputBuffer;
-import oracle.jdbc.OracleTypes;
import org.utplsql.api.reporter.Reporter;
import java.sql.CallableStatement;
@@ -20,9 +19,6 @@ class CompatibilityOutputBufferPre310 extends AbstractOutputBuffer {
@Override
protected CallableStatement getLinesCursorStatement(Connection conn) throws SQLException {
- 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;
+ return prepareLinesCursorStatement(conn, "begin :lines_cursor := ut_output_buffer.get_lines_cursor(:reporter_id); end;");
}
}
diff --git a/src/main/java/org/utplsql/api/outputBuffer/DefaultOutputBuffer.java b/src/main/java/org/utplsql/api/outputBuffer/DefaultOutputBuffer.java
index 2c31e5e..9bb212e 100644
--- a/src/main/java/org/utplsql/api/outputBuffer/DefaultOutputBuffer.java
+++ b/src/main/java/org/utplsql/api/outputBuffer/DefaultOutputBuffer.java
@@ -1,7 +1,5 @@
package org.utplsql.api.outputBuffer;
-import oracle.jdbc.OracleCallableStatement;
-import oracle.jdbc.OracleTypes;
import org.utplsql.api.reporter.Reporter;
import java.sql.CallableStatement;
@@ -34,9 +32,6 @@ protected CallableStatement getLinesCursorStatement(Connection conn) throws SQLE
" 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;
+ return prepareLinesCursorStatement(conn, plsql);
}
}
diff --git a/src/main/java/org/utplsql/api/reporter/Reporter.java b/src/main/java/org/utplsql/api/reporter/Reporter.java
index 6e91062..f48b3bf 100644
--- a/src/main/java/org/utplsql/api/reporter/Reporter.java
+++ b/src/main/java/org/utplsql/api/reporter/Reporter.java
@@ -67,13 +67,14 @@ public Reporter init(Connection con) throws SQLException {
* @throws SQLException if there are problems with the database access
*/
private void initDbReporter(OracleConnection oraConn, ReporterFactory reporterFactory) throws SQLException {
- OracleCallableStatement callableStatement = (OracleCallableStatement) oraConn.prepareCall("{? = call " + selfType + "()}");
- callableStatement.registerOutParameter(1, OracleTypes.STRUCT, "UT_REPORTER_BASE");
- callableStatement.execute();
+ try (OracleCallableStatement callableStatement = (OracleCallableStatement) oraConn.prepareCall("{? = call " + selfType + "()}")) {
+ callableStatement.registerOutParameter(1, OracleTypes.STRUCT, "UT_REPORTER_BASE");
+ callableStatement.execute();
- Reporter obj = (Reporter) callableStatement.getORAData(1, reporterFactory);
+ Reporter obj = (Reporter) callableStatement.getORAData(1, reporterFactory);
- setAttributes(obj.getAttributes());
+ setAttributes(obj.getAttributes());
+ }
logger.debug("Database-reporter initialized, Type: {}, ID: {}", selfType, id);
}
diff --git a/src/main/java/org/utplsql/api/testRunner/DynamicTestRunnerStatement.java b/src/main/java/org/utplsql/api/testRunner/DynamicTestRunnerStatement.java
index 71fe893..4fe6190 100644
--- a/src/main/java/org/utplsql/api/testRunner/DynamicTestRunnerStatement.java
+++ b/src/main/java/org/utplsql/api/testRunner/DynamicTestRunnerStatement.java
@@ -68,6 +68,9 @@ private DynamicParameterList initParameterList() throws SQLException {
.addIfNotEmpty("a_exclude_schema_expr", options.excludeSchemaExpr)
.addIfNotEmpty("a_exclude_object_expr", options.excludeObjectExpr);
}
+ if (OptionalFeatures.SUPPORT_INFO.isAvailableFor(utPlSQlVersion)) {
+ builder.addIfNotEmpty("a_support_info", options.supportInfo);
+ }
return builder.build();
}
diff --git a/src/test/java/org/utplsql/api/outputBuffer/DefaultOutputBufferTest.java b/src/test/java/org/utplsql/api/outputBuffer/DefaultOutputBufferTest.java
new file mode 100644
index 0000000..2e9bf8b
--- /dev/null
+++ b/src/test/java/org/utplsql/api/outputBuffer/DefaultOutputBufferTest.java
@@ -0,0 +1,80 @@
+package org.utplsql.api.outputBuffer;
+
+import oracle.jdbc.OracleTypes;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.utplsql.api.reporter.Reporter;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.sameInstance;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.*;
+
+/**
+ * Connection pools (e.g. HikariCP) return their own proxy statements, which are not
+ * {@link oracle.jdbc.OracleCallableStatement} instances. The output buffer must work with plain JDBC statements.
+ */
+class DefaultOutputBufferTest {
+
+ private Reporter reporter;
+ private Connection connection;
+ private CallableStatement callableStatement;
+
+ @BeforeEach
+ void setUp() throws SQLException {
+ reporter = mock(Reporter.class);
+ when(reporter.isInit()).thenReturn(true);
+ when(reporter.getTypeName()).thenReturn("UT_DOCUMENTATION_REPORTER");
+ when(reporter.getId()).thenReturn("ABC123");
+
+ ResultSet resultSet = mock(ResultSet.class);
+ when(resultSet.next()).thenReturn(true, true, false);
+ when(resultSet.getString("text")).thenReturn("line 1", "line 2");
+
+ // A plain CallableStatement, as returned by a connection pool proxy
+ callableStatement = mock(CallableStatement.class);
+ when(callableStatement.getObject("lines_cursor")).thenReturn(resultSet);
+
+ connection = mock(Connection.class);
+ when(connection.prepareCall(anyString())).thenReturn(callableStatement);
+ }
+
+ @Test
+ void fetchAllWorksWithNonOracleCallableStatement() throws SQLException {
+ List lines = new DefaultOutputBuffer(reporter).fetchAll(connection);
+
+ assertThat(lines, contains("line 1", "line 2"));
+ verify(callableStatement).setString("reporter_id", "ABC123");
+ verify(callableStatement).registerOutParameter("lines_cursor", OracleTypes.CURSOR);
+ verify(callableStatement).close();
+ }
+
+ @Test
+ void printAvailableWorksWithNonOracleCallableStatement() throws SQLException {
+ new DefaultOutputBuffer(reporter).setFetchSize(1).printAvailable(connection, mock(java.io.PrintStream.class));
+
+ verify(callableStatement).setFetchSize(1);
+ verify(callableStatement).execute();
+ verify(callableStatement).close();
+ }
+
+ @Test
+ void statementIsClosedWhenBindingFails() throws SQLException {
+ SQLException bindError = new SQLException("bind failed");
+ doThrow(bindError).when(callableStatement).setString(anyString(), anyString());
+
+ SQLException thrown = assertThrows(SQLException.class, () -> new DefaultOutputBuffer(reporter).fetchAll(connection));
+
+ assertThat(thrown, sameInstance(bindError));
+ verify(callableStatement).close();
+ verify(callableStatement, never()).execute();
+ }
+}
diff --git a/src/test/java/org/utplsql/api/reporter/ReporterInitTest.java b/src/test/java/org/utplsql/api/reporter/ReporterInitTest.java
new file mode 100644
index 0000000..9b2ffce
--- /dev/null
+++ b/src/test/java/org/utplsql/api/reporter/ReporterInitTest.java
@@ -0,0 +1,39 @@
+package org.utplsql.api.reporter;
+
+import oracle.jdbc.OracleCallableStatement;
+import oracle.jdbc.OracleConnection;
+import org.junit.jupiter.api.Test;
+import org.utplsql.api.compatibility.CompatibilityProxy;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+class ReporterInitTest {
+
+ @Test
+ void initClosesReporterStatement() throws SQLException {
+ OracleCallableStatement callableStatement = mock(OracleCallableStatement.class);
+ Reporter dbReporter = new DefaultReporter("UT_DOCUMENTATION_REPORTER",
+ new Object[]{"UT_DOCUMENTATION_REPORTER", new byte[]{0x0A, 0x0B}});
+ when(callableStatement.getORAData(eq(1), any())).thenReturn(dbReporter);
+
+ OracleConnection oracleConnection = mock(OracleConnection.class);
+ when(oracleConnection.prepareCall(anyString())).thenReturn(callableStatement);
+
+ // Connection as handed out by a connection pool
+ Connection connection = mock(Connection.class);
+ when(connection.unwrap(OracleConnection.class)).thenReturn(oracleConnection);
+
+ Reporter reporter = new DefaultReporter("UT_DOCUMENTATION_REPORTER", null)
+ .init(connection, mock(CompatibilityProxy.class), new ReporterFactory());
+
+ assertThat(reporter.isInit(), equalTo(true));
+ assertThat(reporter.getId(), equalTo("0A0B"));
+ verify(callableStatement).close();
+ }
+}
diff --git a/src/test/java/org/utplsql/api/testRunner/DynamicTestRunnerStatementTest.java b/src/test/java/org/utplsql/api/testRunner/DynamicTestRunnerStatementTest.java
index 739dbcf..89789a8 100644
--- a/src/test/java/org/utplsql/api/testRunner/DynamicTestRunnerStatementTest.java
+++ b/src/test/java/org/utplsql/api/testRunner/DynamicTestRunnerStatementTest.java
@@ -49,6 +49,7 @@ void version_3_0_2_parameters() throws SQLException {
checkRandomTestOrder(false);
checkTags(false);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -61,6 +62,7 @@ void version_3_0_3_parameters() throws SQLException {
checkRandomTestOrder(false);
checkTags(false);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -73,6 +75,7 @@ void version_3_0_4_parameters() throws SQLException {
checkRandomTestOrder(false);
checkTags(false);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -85,6 +88,7 @@ void version_3_1_0_parameters() throws SQLException {
checkRandomTestOrder(false);
checkTags(false);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -97,6 +101,7 @@ void version_3_1_1_parameters() throws SQLException {
checkRandomTestOrder(false);
checkTags(false);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -109,6 +114,7 @@ void version_3_1_2_parameters() throws SQLException {
checkRandomTestOrder(false);
checkTags(false);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -121,6 +127,7 @@ void version_3_1_3_parameters() throws SQLException {
checkRandomTestOrder(false);
checkTags(false);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -133,6 +140,7 @@ void version_3_1_4_parameters() throws SQLException {
checkRandomTestOrder(false);
checkTags(false);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -145,6 +153,7 @@ void version_3_1_5_parameters() throws SQLException {
checkRandomTestOrder(false);
checkTags(false);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -157,6 +166,7 @@ void version_3_1_6_parameters() throws SQLException {
checkRandomTestOrder(false);
checkTags(false);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -169,6 +179,7 @@ void version_3_1_7_parameters() throws SQLException {
checkRandomTestOrder(true);
checkTags(true);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -181,6 +192,7 @@ void version_3_1_8_parameters() throws SQLException {
checkRandomTestOrder(true);
checkTags(true);
checkExpr(false);
+ checkSupportInfo(false);
}
@Test
@@ -193,6 +205,33 @@ void version_3_1_13_parameters() throws SQLException {
checkRandomTestOrder(true);
checkTags(true);
checkExpr(true);
+ checkSupportInfo(false);
+ }
+
+ @Test
+ void version_3_2_4_before_support_info_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.create("3.2.4.4647"));
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(true);
+ checkRandomTestOrder(true);
+ checkTags(true);
+ checkExpr(true);
+ checkSupportInfo(false);
+ }
+
+ @Test
+ void version_3_2_4_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.create("3.2.4.4648"));
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(true);
+ checkRandomTestOrder(true);
+ checkTags(true);
+ checkExpr(true);
+ checkSupportInfo(true);
}
private OracleConnection getMockedOracleConnection(Object[] expectedFileMapping) throws SQLException {
@@ -311,4 +350,11 @@ private void checkExpr(boolean shouldBeThere) throws SQLException {
assertThat(sql, doesOrDoesNotContainString("a_exclude_object_expr => ?", shouldBeThere));
verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setString(17, "ut3:*_package*");
}
+
+ private void checkSupportInfo(boolean shouldBeThere) throws SQLException {
+ String sql = testRunnerStatement.getSql();
+
+ assertThat(sql, doesOrDoesNotContainString("a_support_info => (case ? when 1 then true else false end)", shouldBeThere));
+ verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setInt(18, 0);
+ }
}
diff --git a/src/test/java/org/utplsql/api/testRunner/TestRunnerStatementProviderIT.java b/src/test/java/org/utplsql/api/testRunner/TestRunnerStatementProviderIT.java
index 2676c38..bfc469a 100644
--- a/src/test/java/org/utplsql/api/testRunner/TestRunnerStatementProviderIT.java
+++ b/src/test/java/org/utplsql/api/testRunner/TestRunnerStatementProviderIT.java
@@ -36,6 +36,7 @@ public static TestRunnerOptions getCompletelyFilledOptions() {
options.includeObjectExpr = "a_*";
options.excludeSchemaExpr = "ut3:*_package*";
options.excludeObjectExpr = "ut3:*_package*";
+ options.supportInfo = false;
return options;
}