1111
1212import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
1313
14- public class ConnectionPoolTest {
14+ class ConnectionPoolTest {
1515
1616 private ConnectionPool pool ;
1717
@@ -20,7 +20,6 @@ public class ConnectionPoolTest {
2020 }
2121
2222 private ConnectionPool createPool () {
23-
2423 DataSourceConfig config = new DataSourceConfig ();
2524 config .setUrl ("jdbc:h2:mem:tests" );
2625 config .setUsername ("sa" );
@@ -32,13 +31,12 @@ private ConnectionPool createPool() {
3231 }
3332
3433 @ AfterEach
35- public void after () {
34+ void after () {
3635 pool .shutdown ();
3736 }
3837
3938 @ Test
40- public void getConnection_expect_poolGrowsAboveMin () throws SQLException {
41-
39+ void getConnection_expect_poolGrowsAboveMin () throws SQLException {
4240 Connection con1 = pool .getConnection ();
4341 Connection con2 = pool .getConnection ();
4442
@@ -68,8 +66,7 @@ public void getConnection_expect_poolGrowsAboveMin() throws SQLException {
6866 }
6967
7068 @ Test
71- public void getConnection_explicitUserPassword () throws SQLException {
72-
69+ void getConnection_explicitUserPassword () throws SQLException {
7370 Connection connection = pool .getConnection ("sa" , "" );
7471 PreparedStatement statement = connection .prepareStatement ("create user testing password '123'" );
7572 statement .execute ();
@@ -81,8 +78,7 @@ public void getConnection_explicitUserPassword() throws SQLException {
8178 }
8279
8380 @ Test
84- public void unwrapConnection () throws SQLException {
85-
81+ void unwrapConnection () throws SQLException {
8682 Connection connection = pool .getConnection ();
8783 Connection underlying = connection .unwrap (Connection .class );
8884
@@ -91,8 +87,7 @@ public void unwrapConnection() throws SQLException {
9187 }
9288
9389 @ Test
94- public void getDelegate () throws SQLException {
95-
90+ void getDelegate () throws SQLException {
9691 Connection connection = pool .getConnection ();
9792 PooledConnection pc = (PooledConnection )connection ;
9893 Connection underlying = pc .delegate ();
@@ -102,7 +97,16 @@ public void getDelegate() throws SQLException {
10297 }
10398
10499 @ Test
105- public void testSchemaSwitch () throws SQLException {
100+ void isClosed_afterClose () throws SQLException {
101+ Connection connection = pool .getConnection ();
102+ assertThat (connection .isClosed ()).isFalse ();
103+
104+ connection .close ();
105+ assertThat (connection .isClosed ()).isTrue ();
106+ }
107+
108+ @ Test
109+ void testSchemaSwitch () throws SQLException {
106110 Connection conn = pool .getConnection ();
107111 Statement stmt = conn .createStatement ();
108112 stmt .executeUpdate ("CREATE SCHEMA TENANT_1" );
0 commit comments