File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
src/test/java/com/answerdigital/answerking/utility Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .answerdigital .answerking .utility ;
2+
3+ import org .junit .jupiter .api .AfterAll ;
4+ import org .junit .jupiter .api .BeforeAll ;
5+ import org .springframework .test .context .ActiveProfiles ;
6+ import org .springframework .test .context .DynamicPropertyRegistry ;
7+ import org .springframework .test .context .DynamicPropertySource ;
8+ import org .testcontainers .containers .MySQLContainer ;
9+
10+ @ ActiveProfiles ("test" )
11+ public abstract class ContainerisedTest {
12+ private static final MySQLContainer container =
13+ new MySQLContainer <>("mysql:8.0.31" )
14+ .withDatabaseName ("answer_king_test" )
15+ .withUsername ("test_user" )
16+ .withPassword ("GS3ef_fsd^!" )
17+ .withReuse (true );
18+
19+ @ BeforeAll
20+ public static void startup () {
21+ container .start ();
22+ }
23+
24+ @ AfterAll
25+ public static void shutdown () {
26+ container .stop ();
27+ }
28+
29+ @ DynamicPropertySource
30+ private static void overrideProps (DynamicPropertyRegistry registry ) {
31+ registry .add ("spring.datasource.url" , container ::getJdbcUrl );
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments