24
24
import java .util .Optional ;
25
25
import java .util .Properties ;
26
26
import java .util .stream .Stream ;
27
+
28
+ import org .springframework .context .ConfigurableApplicationContext ;
29
+ import org .springframework .test .annotation .DirtiesContext ;
27
30
import org .springframework .test .annotation .Rollback ;
28
31
import org .apache .commons .lang .StringUtils ;
29
32
import org .dbunit .DatabaseUnitException ;
53
56
import org .testcontainers .containers .MySQLContainer ;
54
57
import ch .vorburger .exec .ManagedProcessException ;
55
58
59
+ @ DirtiesContext (classMode = DirtiesContext .ClassMode .AFTER_CLASS )
56
60
public class ConfigurationTester extends DomainBaseModuleContextSensitiveTest {
57
61
58
62
protected static final Logger log = LoggerFactory .getLogger (ConfigurationTester .class );
59
63
60
64
private static MySQLContainer mysqlContainer = new MySQLContainer ("mysql:5.7.31" );
61
65
66
+ private static ConfigurableApplicationContext storedApplicationContext ;
67
+
62
68
private String configDirPath ;
63
69
64
70
private String cielFilePath ;
@@ -74,6 +80,7 @@ public static void setupMySqlDb() throws IOException {
74
80
mysqlContainer .withPassword ("" );
75
81
mysqlContainer .withCommand ("mysqld --character-set-server=utf8 --collation-server=utf8_general_ci" );
76
82
mysqlContainer .start ();
83
+
77
84
}
78
85
79
86
protected void setupDatabaseProps (Properties props ) throws ManagedProcessException , URISyntaxException {
@@ -233,12 +240,16 @@ public void conclude() throws URISyntaxException {
233
240
}
234
241
Assert .assertThat (sb .toString (), Validator .errors , is (empty ()));
235
242
super .getConnection ();
243
+ storedApplicationContext = (ConfigurableApplicationContext ) applicationContext ;
236
244
}
237
245
238
246
@ AfterClass
239
247
public static void tearDownAfterClass () throws Exception {
240
248
if (null != mysqlContainer ) {
241
249
mysqlContainer .stop ();
242
250
}
251
+ if (null != storedApplicationContext ) {
252
+ storedApplicationContext .close ();
253
+ }
243
254
}
244
255
}
0 commit comments