3131import org .junit .jupiter .params .provider .MethodSource ;
3232import org .mockito .MockedStatic ;
3333import org .mockito .Mockito ;
34+ import org .sqlite .SQLiteDataSource ;
3435import org .testcontainers .containers .*;
3536import org .testcontainers .junit .jupiter .Testcontainers ;
3637import org .testcontainers .utility .DockerImageName ;
@@ -52,9 +53,8 @@ static Stream<Arguments> dialectProvider() {
5253 Arguments .of (SqlDialect .ORACLE , "oracle" ),
5354 Arguments .of (SqlDialect .POSTGRESQL , "postgresql" ),
5455 Arguments .of (SqlDialect .MARIADB , "mariadb" ),
55- Arguments .of (SqlDialect .H2 , "h2" )
56- //Disabled due to issues with file-based databases in CI environments
57- //Arguments.of(SqlDialect.SQLITE, "sqlite")
56+ Arguments .of (SqlDialect .H2 , "h2" ),
57+ Arguments .of (SqlDialect .SQLITE , "sqlite" )
5858 );
5959 }
6060
@@ -73,21 +73,25 @@ private TestContext setupTest(SqlDialect sqlDialect, String dialectName) throws
7373 }
7474
7575 if ("sqlite" .equals (dialectName )) {
76- HikariConfig config = new HikariConfig ();
7776 String dbFile = "test_" + System .currentTimeMillis () + ".db" ;
78- config .setJdbcUrl ("jdbc:sqlite:" + dbFile );
79- config .setDriverClassName ("org.sqlite.JDBC" );
80- config .setMaximumPoolSize (1 );
81- config .setMinimumIdle (1 );
82- config .setConnectionTimeout (30000 );
83- config .setMaxLifetime (0 );
8477
85- config .setConnectionInitSql ("PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000;" );
78+ // Use a shared in-memory DB or file DB, but single connection
79+ String jdbcUrl = "jdbc:sqlite:" + dbFile ;
8680
87- DataSource dataSource = new HikariDataSource (config );
88- SqlAuditTestHelper .createTables (dataSource , sqlDialect );
81+ // Create a single-connection DataSource for SQLite
82+ SQLiteDataSource ds = new SQLiteDataSource ();
83+ ds .setUrl (jdbcUrl );
84+
85+ try (Connection conn = ds .getConnection ();
86+ Statement stmt = conn .createStatement ()) {
87+ stmt .execute ("PRAGMA journal_mode=WAL;" );
88+ stmt .execute ("PRAGMA busy_timeout=5000;" );
89+ }
90+
91+ // Run table creation with this same DataSource
92+ SqlAuditTestHelper .createTables (ds , sqlDialect );
8993
90- return new TestContext (dataSource , null , SqlDialect .SQLITE );
94+ return new TestContext (ds , null , SqlDialect .SQLITE );
9195 }
9296
9397 JdbcDatabaseContainer <?> container = SqlAuditTestHelper .createContainer (dialectName );
0 commit comments