File tree Expand file tree Collapse file tree 2 files changed +26
-33
lines changed
src/test/java/com/answerdigital/answerking/utility Expand file tree Collapse file tree 2 files changed +26
-33
lines changed Original file line number Diff line number Diff line change 1+ package com .answerdigital .answerking .utility ;
2+
3+ import org .springframework .test .context .ActiveProfiles ;
4+ import org .springframework .test .context .DynamicPropertyRegistry ;
5+ import org .springframework .test .context .DynamicPropertySource ;
6+ import org .testcontainers .containers .MySQLContainer ;
7+
8+ @ ActiveProfiles ("test" )
9+ public abstract class AbstractContainerBaseTest {
10+ static final MySQLContainer MY_SQL_CONTAINER ;
11+
12+ static {
13+ MY_SQL_CONTAINER =
14+ new MySQLContainer <>("mysql:8.0.31" )
15+ .withReuse (true );
16+ MY_SQL_CONTAINER .start ();
17+ }
18+
19+ @ DynamicPropertySource
20+ private static void overrideProps (DynamicPropertyRegistry registry ) {
21+ registry .add ("spring.datasource.url" , MY_SQL_CONTAINER ::getJdbcUrl );
22+ registry .add ("spring.datasource.username" , MY_SQL_CONTAINER ::getUsername );
23+ registry .add ("spring.datasource.password" , MY_SQL_CONTAINER ::getPassword );
24+ registry .add ("spring.datasource.name" , MY_SQL_CONTAINER ::getDatabaseName );
25+ }
26+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments