|
30 | 30 | import org.junit.jupiter.params.provider.Arguments; |
31 | 31 | import org.junit.jupiter.params.provider.MethodSource; |
32 | 32 |
|
| 33 | +import java.io.BufferedReader; |
33 | 34 | import java.io.ByteArrayInputStream; |
34 | 35 | import java.io.StringReader; |
35 | 36 | import java.nio.charset.StandardCharsets; |
@@ -590,7 +591,7 @@ void testUpdatableResultSet(String scrollableCursorPropertyValue) throws Excepti |
590 | 591 | counter++; |
591 | 592 | } |
592 | 593 |
|
593 | | - assertEquals(counter - 1, recordCount, "Should process " + recordCount + " rows"); |
| 594 | + assertEquals(recordCount, counter - 1, "Should process " + recordCount + " rows"); |
594 | 595 |
|
595 | 596 | // check the insertRow() feature |
596 | 597 | int newId = recordCount + 1; |
@@ -625,9 +626,9 @@ void testUpdatableResultSet(String scrollableCursorPropertyValue) throws Excepti |
625 | 626 | if (SCROLLABLE_CURSOR_SERVER.equals(scrollableCursorPropertyValue) |
626 | 627 | && isPureJavaType().matches(GDS_TYPE) |
627 | 628 | && getDefaultSupportInfo().supportsScrollableCursors()) { |
628 | | - assertEquals(counter - 1, recordCount + 1); |
| 629 | + assertEquals(recordCount + 1, counter - 1); |
629 | 630 | } else { |
630 | | - assertEquals(counter - 1, recordCount); |
| 631 | + assertEquals(recordCount, counter - 1); |
631 | 632 | } |
632 | 633 | } |
633 | 634 |
|
@@ -1445,6 +1446,7 @@ void testIsAfterLast_bug689() throws Exception { |
1445 | 1446 | */ |
1446 | 1447 | @ParameterizedTest |
1447 | 1448 | @MethodSource |
| 1449 | + @SuppressWarnings("MagicConstant") |
1448 | 1450 | void testIsBeforeFirst_isAfterLast_emptyResultSet_bug807(int resultSetType, int resultSetConcurrency, |
1449 | 1451 | String scrollableCursorPropertyValue) throws SQLException { |
1450 | 1452 | try (Connection connection = createConnection(scrollableCursorPropertyValue)) { |
@@ -1477,6 +1479,7 @@ static Stream<Arguments> testIsBeforeFirst_isAfterLast_emptyResultSet_bug807() { |
1477 | 1479 |
|
1478 | 1480 | @ParameterizedTest |
1479 | 1481 | @MethodSource |
| 1482 | + @SuppressWarnings("MagicConstant") |
1480 | 1483 | void wasNull_onInsertRow(int resultSetType, String scrollableCursorPropertyValue) throws Exception { |
1481 | 1484 | try (Connection connection = createConnection(scrollableCursorPropertyValue)) { |
1482 | 1485 | executeCreateTable(connection, CREATE_TABLE_STATEMENT); |
@@ -1574,6 +1577,37 @@ && canSupportServerSideScrollable() |
1574 | 1577 | } |
1575 | 1578 | } |
1576 | 1579 |
|
| 1580 | + @Test |
| 1581 | + void clobRemainsOpenAfterNext() throws Exception { |
| 1582 | + try (Connection connection = getConnectionViaDriverManager()) { |
| 1583 | + executeCreateTable(connection, CREATE_TABLE_STATEMENT); |
| 1584 | + connection.setAutoCommit(false); |
| 1585 | + createTestData(2, i -> "clob-value-" + i, connection, "blob_str"); |
| 1586 | + connection.commit(); |
| 1587 | + |
| 1588 | + Clob secondClob; |
| 1589 | + |
| 1590 | + try (Statement stmt = connection.createStatement()) { |
| 1591 | + ResultSet rs = stmt.executeQuery("select id, blob_str from test_table order by id"); |
| 1592 | + assertNextRow(rs); |
| 1593 | + Clob firstClob = rs.getClob(2); |
| 1594 | + assertNextRow(rs); |
| 1595 | + try (BufferedReader firstReader = new BufferedReader( |
| 1596 | + assertDoesNotThrow(() -> firstClob.getCharacterStream(), |
| 1597 | + "should be able to get character stream from clob after next"))) { |
| 1598 | + assertEquals("clob-value-1", firstReader.readLine()); |
| 1599 | + } |
| 1600 | + secondClob = rs.getClob(2); |
| 1601 | + assertNoNextRow(rs); |
| 1602 | + } |
| 1603 | + try (BufferedReader secondReader = new BufferedReader( |
| 1604 | + assertDoesNotThrow(() -> secondClob.getCharacterStream(), |
| 1605 | + "should be able to get character stream from clob after statement close"))) { |
| 1606 | + assertEquals("clob-value-2", secondReader.readLine()); |
| 1607 | + } |
| 1608 | + } |
| 1609 | + } |
| 1610 | + |
1577 | 1611 | private static boolean canSupportServerSideScrollable() { |
1578 | 1612 | return "PURE_JAVA".equalsIgnoreCase(GDS_TYPE) |
1579 | 1613 | && getDefaultSupportInfo().supportsScrollableCursors(); |
|
0 commit comments