|
20 | 20 | import static org.hamcrest.MatcherAssert.assertThat; |
21 | 21 | import static org.junit.jupiter.api.Assertions.assertAll; |
22 | 22 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 23 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 24 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
23 | 25 |
|
24 | 26 | import java.nio.charset.StandardCharsets; |
25 | 27 | import java.sql.Connection; |
@@ -83,6 +85,19 @@ public void testSimpleQueryNoParameterBinding() throws SQLException { |
83 | 85 | } |
84 | 86 | } |
85 | 87 |
|
| 88 | + @Test |
| 89 | + public void testSimpleQueryNoParameterBindingWithExecute() throws SQLException { |
| 90 | + final String query = CoreMockedSqlProducers.LEGACY_REGULAR_SQL_CMD; |
| 91 | + try (final PreparedStatement preparedStatement = connection.prepareStatement(query)) { |
| 92 | + boolean isResultSet = preparedStatement.execute(); |
| 93 | + assertTrue(isResultSet); |
| 94 | + final ResultSet resultSet = preparedStatement.getResultSet(); |
| 95 | + CoreMockedSqlProducers.assertLegacyRegularSqlResultSet(resultSet); |
| 96 | + assertFalse(preparedStatement.getMoreResults()); |
| 97 | + assertEquals(-1, preparedStatement.getUpdateCount()); |
| 98 | + } |
| 99 | + } |
| 100 | + |
86 | 101 | @Test |
87 | 102 | public void testQueryWithParameterBinding() throws SQLException { |
88 | 103 | final String query = "Fake query with parameters"; |
@@ -174,6 +189,20 @@ public void testUpdateQuery() throws SQLException { |
174 | 189 | } |
175 | 190 | } |
176 | 191 |
|
| 192 | + @Test |
| 193 | + public void testUpdateQueryWithExecute() throws SQLException { |
| 194 | + String query = "Fake update with execute"; |
| 195 | + PRODUCER.addUpdateQuery(query, /*updatedRows*/ 42); |
| 196 | + try (final PreparedStatement stmt = connection.prepareStatement(query)) { |
| 197 | + boolean isResultSet = stmt.execute(); |
| 198 | + assertFalse(isResultSet); |
| 199 | + int updated = stmt.getUpdateCount(); |
| 200 | + assertEquals(42, updated); |
| 201 | + assertFalse(stmt.getMoreResults()); |
| 202 | + assertEquals(-1, stmt.getUpdateCount()); |
| 203 | + } |
| 204 | + } |
| 205 | + |
177 | 206 | @Test |
178 | 207 | public void testUpdateQueryWithParameters() throws SQLException { |
179 | 208 | String query = "Fake update with parameters"; |
|
0 commit comments