File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
java/id/my/hendisantika/books Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ package id .my .hendisantika .books ;
2
+
3
+ import org .testcontainers .containers .PostgreSQLContainer ;
4
+
5
+ /**
6
+ * Created by IntelliJ IDEA.
7
+ * Project : books
8
+ * User: hendisantika
9
+ * Email: hendisantika@gmail.com
10
+ * Telegram : @hendisantika34
11
+ * Date: 01/11/24
12
+ * Time: 08.16
13
+ * To change this template use File | Settings | File Templates.
14
+ */
15
+ public class HendiPostgresqlContainer extends PostgreSQLContainer <HendiPostgresqlContainer > {
16
+ private static final String IMAGE_VERSION = "postgres:17-alpine3.20" ;
17
+ private static HendiPostgresqlContainer container ;
18
+
19
+ private HendiPostgresqlContainer () {
20
+ super (IMAGE_VERSION );
21
+ }
22
+
23
+ public static HendiPostgresqlContainer getInstance () {
24
+ if (container == null ) {
25
+ container = new HendiPostgresqlContainer ();
26
+ }
27
+ return container ;
28
+ }
29
+
30
+ @ Override
31
+ public void start () {
32
+ super .start ();
33
+ System .setProperty ("DB_URL" , container .getJdbcUrl ());
34
+ System .setProperty ("DB_USERNAME" , container .getUsername ());
35
+ System .setProperty ("DB_PASSWORD" , container .getPassword ());
36
+ }
37
+
38
+ @ Override
39
+ public void stop () {
40
+ //do nothing, JVM handles shut down
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ spring :
2
+ datasource :
3
+ url : jdbc:tc:postgresql:17-alpine3.20:///integration-tests-db
4
+ driver-class-name : org.testcontainers.jdbc.ContainerDatabaseDriver
5
+ jpa :
6
+ hibernate :
7
+ ddl-auto : validate
You can’t perform that action at this time.
0 commit comments