Skip to content

Commit fc320eb

Browse files
committed
Add test
1 parent 825e40d commit fc320eb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ConnectionTest.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.arrow.driver.jdbc;
1818

19+
import static org.junit.jupiter.api.Assertions.assertFalse;
1920
import static org.junit.jupiter.api.Assertions.assertEquals;
2021
import static org.junit.jupiter.api.Assertions.assertFalse;
2122
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -698,4 +699,40 @@ public String visit(String value) {
698699
assertEquals(catalog, actualCatalog);
699700
}
700701
}
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+
}
701738
}

0 commit comments

Comments
 (0)