Add test for close()

This commit is contained in:
김선우 2025-01-27 19:19:34 +09:00
parent dae15ef0e3
commit 1125e51a59
2 changed files with 17 additions and 0 deletions

View file

@ -49,6 +49,7 @@ public abstract class LimboConnection implements Connection {
return;
}
this._close(this.connectionPtr);
this.closed = true;
}
private native void _close(long connectionPtr);

View file

@ -65,4 +65,20 @@ class JDBC4ConnectionTest {
void prepare_simple_create_table() throws Exception {
connection.prepare("CREATE TABLE users (id INT PRIMARY KEY, username TEXT)");
}
@Test
void calling_close_multiple_times_throws_no_exception() throws Exception {
connection.close();
connection.close();
}
@Test
void calling_methods_on_closed_connection_should_throw_exception() throws Exception {
connection.close();
assertThrows(
SQLException.class,
() ->
connection.createStatement(
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, -1));
}
}