diff --git a/README.md b/README.md index 6eb49b22..fd3fd117 100644 --- a/README.md +++ b/README.md @@ -197,8 +197,9 @@ See the [documentation on Initializer's logging properties](readme/rtprops.md#lo #### Version 2.7.0 * Added support for 'queues' domain. * Added support for 'addresshierarchy' domain. -* Fix for Liquibase Loader to ensure compatibility with OpenMRS versions 2.5.5+ -* Fix for OCL Loader to ensure it throws an Exception if the OCL import fails +* Fix for Liquibase Loader to ensure compatibility with OpenMRS versions 2.5.5+. +* Fix for OCL Loader to ensure it throws an Exception if the OCL import fails. +* Fix for Validator to not encounter failure upon repeated execution on the same JVM process. #### Version 2.6.0 * Added support for 'cohorttypes' and 'cohortattributetypes' domains. diff --git a/validator/src/main/java/org/openmrs/module/initializer/validator/ConfigurationTester.java b/validator/src/main/java/org/openmrs/module/initializer/validator/ConfigurationTester.java index 442f816a..585467bb 100644 --- a/validator/src/main/java/org/openmrs/module/initializer/validator/ConfigurationTester.java +++ b/validator/src/main/java/org/openmrs/module/initializer/validator/ConfigurationTester.java @@ -24,6 +24,9 @@ import java.util.Optional; import java.util.Properties; import java.util.stream.Stream; + +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Rollback; import org.apache.commons.lang.StringUtils; import org.dbunit.DatabaseUnitException; @@ -53,12 +56,15 @@ import org.testcontainers.containers.MySQLContainer; import ch.vorburger.exec.ManagedProcessException; +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class ConfigurationTester extends DomainBaseModuleContextSensitiveTest { protected static final Logger log = LoggerFactory.getLogger(ConfigurationTester.class); private static MySQLContainer mysqlContainer = new MySQLContainer("mysql:5.7.31"); + private static ConfigurableApplicationContext storedApplicationContext; + private String configDirPath; private String cielFilePath; @@ -74,6 +80,7 @@ public static void setupMySqlDb() throws IOException { mysqlContainer.withPassword(""); mysqlContainer.withCommand("mysqld --character-set-server=utf8 --collation-server=utf8_general_ci"); mysqlContainer.start(); + } protected void setupDatabaseProps(Properties props) throws ManagedProcessException, URISyntaxException { @@ -233,6 +240,7 @@ public void conclude() throws URISyntaxException { } Assert.assertThat(sb.toString(), Validator.errors, is(empty())); super.getConnection(); + storedApplicationContext = (ConfigurableApplicationContext) applicationContext; } @AfterClass @@ -240,5 +248,8 @@ public static void tearDownAfterClass() throws Exception { if (null != mysqlContainer) { mysqlContainer.stop(); } + if (null != storedApplicationContext) { + storedApplicationContext.close(); + } } }