Skip to content

Commit 850b8f4

Browse files
committed
feat: improve sql audit store test
1 parent fd4b577 commit 850b8f4

File tree

2 files changed

+12
-54
lines changed

2 files changed

+12
-54
lines changed

community/flamingock-auditstore-sql/src/test/java/io/flamingock/community/sql/SqlAuditStoreTest.java

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.sqlite.SQLiteDataSource;
3838
import org.testcontainers.containers.*;
3939
import org.testcontainers.junit.jupiter.Testcontainers;
40-
import org.testcontainers.utility.DockerImageName;
4140

4241
import javax.sql.DataSource;
4342
import java.sql.*;
@@ -142,53 +141,6 @@ private TestContext setupTest(SqlDialect sqlDialect, String dialectName) throws
142141
return new TestContext(dataSource, container, sqlDialect);
143142
}
144143

145-
private JdbcDatabaseContainer<?> createContainer(String dialectName) {
146-
switch (dialectName) {
147-
case "mysql":
148-
return new MySQLContainer<>("mysql:8.0")
149-
.withDatabaseName("testdb")
150-
.withUsername("testuser")
151-
.withPassword("testpass");
152-
case "sqlserver":
153-
return new MSSQLServerContainer<>("mcr.microsoft.com/mssql/server:2019-CU18-ubuntu-20.04")
154-
.acceptLicense()
155-
.withPassword("TestPass123!");
156-
case "oracle":
157-
OracleContainer oracleContainer = new OracleContainer(
158-
DockerImageName.parse("gvenzl/oracle-free:23-slim-faststart")
159-
.asCompatibleSubstituteFor("gvenzl/oracle-xe"))
160-
.withPassword("oracle123")
161-
.withSharedMemorySize(1073741824L)
162-
.withStartupTimeoutSeconds(900)
163-
.withEnv("ORACLE_CHARACTERSET", "AL32UTF8");
164-
165-
return new OracleContainer(
166-
DockerImageName.parse("gvenzl/oracle-free:23-slim-faststart")
167-
.asCompatibleSubstituteFor("gvenzl/oracle-xe")) {
168-
@Override
169-
public String getDatabaseName() {
170-
return "FREEPDB1";
171-
}
172-
}
173-
.withPassword("oracle123")
174-
.withSharedMemorySize(1073741824L)
175-
.withStartupTimeoutSeconds(900)
176-
.withEnv("ORACLE_CHARACTERSET", "AL32UTF8");
177-
case "postgresql":
178-
return new PostgreSQLContainer<>(DockerImageName.parse("postgres:15"))
179-
.withDatabaseName("testdb")
180-
.withUsername("test")
181-
.withPassword("test");
182-
case "mariadb":
183-
return new MariaDBContainer<>("mariadb:11.3.2")
184-
.withDatabaseName("testdb")
185-
.withUsername("testuser")
186-
.withPassword("testpass");
187-
default:
188-
throw new IllegalArgumentException("Unsupported dialect: " + dialectName);
189-
}
190-
}
191-
192144
private Class<?>[] getChangeClasses(String dialectName, String scenario) {
193145
switch (dialectName) {
194146
case "mysql":

community/flamingock-auditstore-sql/src/test/java/io/flamingock/community/sql/SqlAuditTestHelper.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,22 @@ public static JdbcDatabaseContainer<?> createContainer(String dialectName) {
3737
return new MySQLContainer<>("mysql:8.0")
3838
.withDatabaseName("testdb")
3939
.withUsername("testuser")
40-
.withPassword("testpass");
40+
.withPassword("testpass")
41+
.withReuse(true);
4142
case "sqlserver":
4243
return new MSSQLServerContainer<>("mcr.microsoft.com/mssql/server:2019-CU18-ubuntu-20.04")
4344
.acceptLicense()
44-
.withPassword("TestPass123!");
45+
.withPassword("TestPass123!")
46+
.withReuse(true);
4547
case "oracle":
4648
OracleContainer oracleContainer = new OracleContainer(
4749
DockerImageName.parse("gvenzl/oracle-free:23-slim-faststart")
4850
.asCompatibleSubstituteFor("gvenzl/oracle-xe"))
4951
.withPassword("oracle123")
5052
.withSharedMemorySize(1073741824L)
5153
.withStartupTimeoutSeconds(900)
52-
.withEnv("ORACLE_CHARACTERSET", "AL32UTF8");
54+
.withEnv("ORACLE_CHARACTERSET", "AL32UTF8")
55+
.withReuse(true);
5356

5457
return new OracleContainer(
5558
DockerImageName.parse("gvenzl/oracle-free:23-slim-faststart")
@@ -62,17 +65,20 @@ public String getDatabaseName() {
6265
.withPassword("oracle123")
6366
.withSharedMemorySize(1073741824L)
6467
.withStartupTimeoutSeconds(900)
65-
.withEnv("ORACLE_CHARACTERSET", "AL32UTF8");
68+
.withEnv("ORACLE_CHARACTERSET", "AL32UTF8")
69+
.withReuse(true);
6670
case "postgresql":
6771
return new PostgreSQLContainer<>(DockerImageName.parse("postgres:15"))
6872
.withDatabaseName("testdb")
6973
.withUsername("test")
70-
.withPassword("test");
74+
.withPassword("test")
75+
.withReuse(true);
7176
case "mariadb":
7277
return new MariaDBContainer<>("mariadb:11.3.2")
7378
.withDatabaseName("testdb")
7479
.withUsername("testuser")
75-
.withPassword("testpass");
80+
.withPassword("testpass")
81+
.withReuse(true);
7682
default:
7783
throw new IllegalArgumentException("Unsupported dialect: " + dialectName);
7884
}

0 commit comments

Comments
 (0)