Skip to content

Commit e85cc3a

Browse files
authored
[#265]: Validator to properly shutdown, so not to fail further invocations on the same JVM process. (#266)
1 parent 583aee2 commit e85cc3a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ See the [documentation on Initializer's logging properties](readme/rtprops.md#lo
197197
#### Version 2.7.0
198198
* Added support for 'queues' domain.
199199
* Added support for 'addresshierarchy' domain.
200-
* Fix for Liquibase Loader to ensure compatibility with OpenMRS versions 2.5.5+
201-
* Fix for OCL Loader to ensure it throws an Exception if the OCL import fails
200+
* Fix for Liquibase Loader to ensure compatibility with OpenMRS versions 2.5.5+.
201+
* Fix for OCL Loader to ensure it throws an Exception if the OCL import fails.
202+
* Fix for Validator to not encounter failure upon repeated execution on the same JVM process.
202203

203204
#### Version 2.6.0
204205
* Added support for 'cohorttypes' and 'cohortattributetypes' domains.

validator/src/main/java/org/openmrs/module/initializer/validator/ConfigurationTester.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
import java.util.Optional;
2525
import java.util.Properties;
2626
import java.util.stream.Stream;
27+
28+
import org.springframework.context.ConfigurableApplicationContext;
29+
import org.springframework.test.annotation.DirtiesContext;
2730
import org.springframework.test.annotation.Rollback;
2831
import org.apache.commons.lang.StringUtils;
2932
import org.dbunit.DatabaseUnitException;
@@ -53,12 +56,15 @@
5356
import org.testcontainers.containers.MySQLContainer;
5457
import ch.vorburger.exec.ManagedProcessException;
5558

59+
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
5660
public class ConfigurationTester extends DomainBaseModuleContextSensitiveTest {
5761

5862
protected static final Logger log = LoggerFactory.getLogger(ConfigurationTester.class);
5963

6064
private static MySQLContainer mysqlContainer = new MySQLContainer("mysql:5.7.31");
6165

66+
private static ConfigurableApplicationContext storedApplicationContext;
67+
6268
private String configDirPath;
6369

6470
private String cielFilePath;
@@ -74,6 +80,7 @@ public static void setupMySqlDb() throws IOException {
7480
mysqlContainer.withPassword("");
7581
mysqlContainer.withCommand("mysqld --character-set-server=utf8 --collation-server=utf8_general_ci");
7682
mysqlContainer.start();
83+
7784
}
7885

7986
protected void setupDatabaseProps(Properties props) throws ManagedProcessException, URISyntaxException {
@@ -233,12 +240,16 @@ public void conclude() throws URISyntaxException {
233240
}
234241
Assert.assertThat(sb.toString(), Validator.errors, is(empty()));
235242
super.getConnection();
243+
storedApplicationContext = (ConfigurableApplicationContext) applicationContext;
236244
}
237245

238246
@AfterClass
239247
public static void tearDownAfterClass() throws Exception {
240248
if (null != mysqlContainer) {
241249
mysqlContainer.stop();
242250
}
251+
if (null != storedApplicationContext) {
252+
storedApplicationContext.close();
253+
}
243254
}
244255
}

0 commit comments

Comments
 (0)