Skip to content

Commit

Permalink
[#265]: Validator to properly shutdown, so not to fail further invoca…
Browse files Browse the repository at this point in the history
…tions on the same JVM process. (#266)
  • Loading branch information
Ruhanga committed May 21, 2024
1 parent 583aee2 commit e85cc3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -233,12 +240,16 @@ public void conclude() throws URISyntaxException {
}
Assert.assertThat(sb.toString(), Validator.errors, is(empty()));
super.getConnection();
storedApplicationContext = (ConfigurableApplicationContext) applicationContext;
}

@AfterClass
public static void tearDownAfterClass() throws Exception {
if (null != mysqlContainer) {
mysqlContainer.stop();
}
if (null != storedApplicationContext) {
storedApplicationContext.close();
}
}
}

0 comments on commit e85cc3a

Please sign in to comment.