1919import com .zaxxer .hikari .HikariDataSource ;
2020import io .flamingock .internal .common .sql .SqlDialect ;
2121import org .testcontainers .containers .*;
22+ import org .testcontainers .containers .wait .strategy .Wait ;
23+ import org .testcontainers .containers .wait .strategy .WaitAllStrategy ;
2224import org .testcontainers .utility .DockerImageName ;
2325
2426import javax .sql .DataSource ;
2527import java .sql .Connection ;
2628import java .sql .PreparedStatement ;
2729import java .sql .ResultSet ;
2830import java .sql .SQLException ;
31+ import java .time .Duration ;
2932
3033import static org .junit .jupiter .api .Assertions .assertTrue ;
3134
3235public class SqlAuditTestHelper {
3336
37+ private static OracleContainer oracleInstance ;
38+
3439 public static JdbcDatabaseContainer <?> createContainer (String dialectName ) {
3540 boolean isCi = System .getenv ("CI" ) != null || System .getenv ("GITHUB_ACTIONS" ) != null ;
3641
@@ -47,24 +52,28 @@ public static JdbcDatabaseContainer<?> createContainer(String dialectName) {
4752 .withPassword ("TestPass123!" )
4853 .withReuse (true );
4954 case "oracle" : {
50- OracleContainer oracle = new OracleContainer (
51- DockerImageName .parse ("gvenzl/oracle-free:23-slim-faststart" )
52- .asCompatibleSubstituteFor ("gvenzl/oracle-xe" )) {
53- @ Override
54- public String getDatabaseName () {
55- return "FREEPDB1" ;
55+ if (oracleInstance == null ) {
56+ oracleInstance = new OracleContainer (
57+ DockerImageName .parse ("gvenzl/oracle-free:23-slim-faststart" )
58+ .asCompatibleSubstituteFor ("gvenzl/oracle-xe" )) {
59+ @ Override
60+ public String getDatabaseName () {
61+ return "FREEPDB1" ;
62+ }
63+ }
64+ .withPassword ("oracle123" )
65+ .withSharedMemorySize (1073741824L )
66+ .withStartupTimeout (Duration .ofMinutes (20 ))
67+ .waitingFor (new WaitAllStrategy ()
68+ .withStrategy (Wait .forListeningPort ())
69+ .withStrategy (Wait .forLogMessage (".*DATABASE IS READY TO USE.*\\ n" , 1 ))
70+ )
71+ .withEnv ("ORACLE_CHARACTERSET" , "AL32UTF8" );
72+ if (!isCi ) {
73+ oracleInstance .withReuse (true );
5674 }
5775 }
58- .withPassword ("oracle123" )
59- .withSharedMemorySize (1073741824L )
60- .withStartupTimeoutSeconds (900 )
61- .withEnv ("ORACLE_CHARACTERSET" , "AL32UTF8" );
62-
63- if (!isCi ) {
64- oracle .withReuse (true );
65- }
66-
67- return oracle ;
76+ return oracleInstance ;
6877 }
6978 case "postgresql" :
7079 return new PostgreSQLContainer <>(DockerImageName .parse ("postgres:15" ))
0 commit comments