|
16 | 16 | */ |
17 | 17 | package org.apache.arrow.driver.jdbc; |
18 | 18 |
|
| 19 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
19 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; |
20 | 21 | import static org.junit.jupiter.api.Assertions.assertFalse; |
21 | 22 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
@@ -698,4 +699,40 @@ public String visit(String value) { |
698 | 699 | assertEquals(catalog, actualCatalog); |
699 | 700 | } |
700 | 701 | } |
| 702 | + |
| 703 | + @Test |
| 704 | + public void testStatementsClosedOnConnectionClose() throws Exception { |
| 705 | + // create a connection |
| 706 | + final Properties properties = new Properties(); |
| 707 | + properties.put(ArrowFlightConnectionProperty.HOST.camelName(), "localhost"); |
| 708 | + properties.put( |
| 709 | + ArrowFlightConnectionProperty.PORT.camelName(), FLIGHT_SERVER_TEST_EXTENSION.getPort()); |
| 710 | + properties.put(ArrowFlightConnectionProperty.USER.camelName(), userTest); |
| 711 | + properties.put(ArrowFlightConnectionProperty.PASSWORD.camelName(), passTest); |
| 712 | + properties.put("useEncryption", false); |
| 713 | + |
| 714 | + Connection connection = |
| 715 | + DriverManager.getConnection( |
| 716 | + "jdbc:arrow-flight-sql://" |
| 717 | + + FLIGHT_SERVER_TEST_EXTENSION.getHost() |
| 718 | + + ":" |
| 719 | + + FLIGHT_SERVER_TEST_EXTENSION.getPort(), |
| 720 | + properties); |
| 721 | + |
| 722 | + // create some statements |
| 723 | + int numStatements = 3; |
| 724 | + Statement[] statements = new Statement[numStatements]; |
| 725 | + for (int i = 0; i < numStatements; i++) { |
| 726 | + statements[i] = connection.createStatement(); |
| 727 | + assertFalse(statements[i].isClosed()); |
| 728 | + } |
| 729 | + |
| 730 | + // close the connection |
| 731 | + connection.close(); |
| 732 | + |
| 733 | + // assert the statements are closed |
| 734 | + for (int i = 0; i < numStatements; i++) { |
| 735 | + assertTrue(statements[i].isClosed()); |
| 736 | + } |
| 737 | + } |
701 | 738 | } |
0 commit comments