Skip to content

Commit 7f24b92

Browse files
committed
test: remove expected error from test
1 parent 28c3160 commit 7f24b92

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSimpleStatementsTest.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
package com.google.cloud.spanner.jdbc.it;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20+
import static org.junit.Assert.assertArrayEquals;
2021
import static org.junit.Assert.assertEquals;
2122
import static org.junit.Assert.assertFalse;
2223
import static org.junit.Assert.assertThrows;
2324
import static org.junit.Assert.assertTrue;
24-
import static org.junit.Assert.fail;
2525
import static org.junit.Assume.assumeFalse;
2626

2727
import com.google.cloud.spanner.Database;
@@ -102,12 +102,6 @@ public void testSelect1PreparedStatement() throws SQLException {
102102

103103
@Test
104104
public void testPreparedStatement() throws SQLException {
105-
// skipping the test when dialect is POSTGRESQL because of exception below
106-
// INVALID_ARGUMENT: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Statements with set
107-
// operations in subqueries are not supported
108-
assumeFalse(
109-
"select array of structs is not supported on POSTGRESQL",
110-
dialect.dialect == Dialect.POSTGRESQL);
111105
String sql =
112106
"select * from (select 1 as number union all select 2 union all select 3) numbers where number=?";
113107
try (Connection connection = createConnection(env, database)) {
@@ -188,15 +182,16 @@ public void testBatchedDdlStatements() throws SQLException {
188182
}
189183

190184
@Test
191-
public void testAddBatchWhenAlreadyInBatch() {
185+
public void testAddBatchWhenAlreadyInBatch() throws SQLException {
192186
try (Connection connection = createConnection(env, database)) {
193-
connection.createStatement().execute("START BATCH DML");
194-
connection.createStatement().addBatch("INSERT INTO Singers (SingerId) VALUES (-1)");
195-
fail("missing expected exception");
196-
} catch (SQLException e) {
197-
assertThat(e.getMessage())
198-
.contains(
199-
"Calling addBatch() is not allowed when a DML or DDL batch has been started on the connection.");
187+
try (Statement statement = connection.createStatement()) {
188+
statement.execute("START BATCH DML");
189+
statement.addBatch("INSERT INTO Singers (SingerId) VALUES (-1)");
190+
statement.addBatch("INSERT INTO Singers (SingerId) VALUES (-2)");
191+
// The returned update count for DML statements in a batch is -1.
192+
assertArrayEquals(new int[] {-1, -1}, statement.executeBatch());
193+
// Note: The 'Singers' table does not actually exist, so we're not executing the batch.
194+
}
200195
}
201196
}
202197

0 commit comments

Comments
 (0)