diff --git a/api/src/test/java/org/openmrs/module/rwandareports/StandaloneContextSensitiveTest.java b/api/src/test/java/org/openmrs/module/rwandareports/StandaloneContextSensitiveTest.java index 25ddd90d..34f246ae 100644 --- a/api/src/test/java/org/openmrs/module/rwandareports/StandaloneContextSensitiveTest.java +++ b/api/src/test/java/org/openmrs/module/rwandareports/StandaloneContextSensitiveTest.java @@ -1,17 +1,57 @@ package org.openmrs.module.rwandareports; -import java.util.Properties; - import org.junit.Before; import org.openmrs.api.context.Context; import org.openmrs.test.BaseModuleContextSensitiveTest; import org.openmrs.test.SkipBaseSetup; -import org.springframework.test.context.ContextConfiguration; -@ContextConfiguration(locations = {"classpath:openmrs-servlet.xml"}, inheritLocations = true) +import java.io.File; +import java.nio.file.Files; +import java.util.Properties; + @SkipBaseSetup public abstract class StandaloneContextSensitiveTest extends BaseModuleContextSensitiveTest { + static { + loadRuntimePropertiesFromSdk(); + } + + protected static void loadRuntimeProperties() { + System.setProperty("databaseUrl", "jdbc:mysql://localhost:3308/rwinkprotest?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false"); + System.setProperty("databaseUsername", "root"); + System.setProperty("databasePassword", "root"); + System.setProperty("databaseDriver", "com.mysql.jdbc.Driver"); + System.setProperty("databaseDialect", "org.hibernate.dialect.MySQLDialect"); + System.setProperty("useInMemoryDatabase", "false"); + } + + protected static void loadRuntimePropertiesFromSdk() { + Properties props = new Properties(); + String serverId = System.getProperty("serverId"); + if (serverId != null) { + File homeDir = new File(System.getProperty("user.home")); + File sdkDir = new File(homeDir, "openmrs"); + File serverDir = new File(sdkDir, serverId); + File runtimePropertiesFile = new File(serverDir, "openmrs-runtime.properties"); + if (!runtimePropertiesFile.exists()) { + throw new RuntimeException("No runtime properties file found at: " + runtimePropertiesFile.getAbsolutePath()); + } + props = new Properties(); + try { + props.load(Files.newInputStream(runtimePropertiesFile.toPath())); + } + catch (Exception e) { + throw new RuntimeException("Error loading properties from " + runtimePropertiesFile, e); + } + } + System.setProperty("databaseUrl", props.getProperty("connection.url")); + System.setProperty("databaseUsername", props.getProperty("connection.username")); + System.setProperty("databasePassword", props.getProperty("connection.password")); + System.setProperty("databaseDriver", props.getProperty("connection.driver_class")); + System.setProperty("databaseDialect", "org.hibernate.dialect.MySQLDialect"); + System.setProperty("useInMemoryDatabase", "false"); + } + @Override public Boolean useInMemoryDatabase() { return false; @@ -23,9 +63,6 @@ public Boolean useInMemoryDatabase() { @Override public Properties getRuntimeProperties() { Properties p = super.getRuntimeProperties(); - p.setProperty("connection.url", "jdbc:mysql://localhost:3306/openmrs_rwink?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8"); - p.setProperty("connection.username", "root"); - p.setProperty("connection.password", "root"); p.setProperty("junit.username", "admin"); p.setProperty("junit.password", "Admin123"); return p; diff --git a/api/src/test/java/org/openmrs/module/rwandareports/reporting/TestStandaloneContextSensitiveTest.java b/api/src/test/java/org/openmrs/module/rwandareports/reporting/TestStandaloneContextSensitiveTest.java new file mode 100644 index 00000000..21651c2f --- /dev/null +++ b/api/src/test/java/org/openmrs/module/rwandareports/reporting/TestStandaloneContextSensitiveTest.java @@ -0,0 +1,26 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ + +package org.openmrs.module.rwandareports.reporting; + +import org.junit.Test; +import org.openmrs.module.rwandareports.StandaloneContextSensitiveTest; + +/** + * Tests that StandaloneContextSensitiveTest works properly + */ +public class TestStandaloneContextSensitiveTest extends StandaloneContextSensitiveTest { + + @Test + public void testPatientWithViralLoadAndCD4TestedCohort() { + System.out.println("Success"); + } + +} diff --git a/pom.xml b/pom.xml index 7c088287..f8fb070d 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ UTF-8 - 2.3.3-SNAPSHOT + 2.3.3 1.3.0 2.1.0-SNAPSHOT 1.10.0