55import org .jooq .DSLContext ;
66import org .jooq .SQLDialect ;
77import org .jooq .impl .DSL ;
8+ import org .junit .jupiter .api .AfterEach ;
89import org .junit .jupiter .api .BeforeEach ;
910import org .testcontainers .containers .PostgreSQLContainer ;
1011import org .testcontainers .junit .jupiter .Container ;
@@ -23,20 +24,27 @@ public class PostgresBackendImplIntegrationTest extends AbstractKVStoreIntegrati
2324 .withUsername ("postgres" )
2425 .withPassword ("postgres" );
2526
27+ private Connection connection ;
28+
2629 @ BeforeEach
27- public void initEach () throws Exception {
30+ void initEach () throws Exception {
2831
2932 // This is required to get postgres driver in classpath before we attempt to fetch a connection
3033 Class .forName ("org.postgresql.Driver" );
31- Connection conn = DriverManager .getConnection (postgreSQLContainer .getJdbcUrl (),
34+ this . connection = DriverManager .getConnection (postgreSQLContainer .getJdbcUrl (),
3235 postgreSQLContainer .getUsername (), postgreSQLContainer .getPassword ());
33- DSLContext dslContext = DSL .using (conn , SQLDialect .POSTGRES );
36+ DSLContext dslContext = DSL .using (connection , SQLDialect .POSTGRES );
3437
3538 this .kvStore = new PostgresBackendImpl (dslContext );
3639
3740 createTable (dslContext );
3841 }
3942
43+ @ AfterEach
44+ void destroy () throws Exception {
45+ this .connection .close ();
46+ }
47+
4048 private void createTable (DSLContext dslContext ) {
4149 dslContext .execute ("CREATE TABLE vss_db ("
4250 + "store_id character varying(120) NOT NULL CHECK (store_id <> ''),"
0 commit comments