Skip to content

Commit

Permalink
Ensure StandaloneContextSensitiveTest works with current version of O…
Browse files Browse the repository at this point in the history
…penMRS
  • Loading branch information
mseaton committed Jul 30, 2024
1 parent 50ca821 commit 32cfb0f
Showing 1 changed file with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class StandaloneContextSensitiveTest extends BaseModuleContextSe
}

protected static void loadRuntimeProperties() {
System.setProperty("databaseUrl", "jdbc:mysql://localhost:3308/rwinkprotest?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false");
System.setProperty("databaseUrl", "jdbc:mysql://localhost:3306/openmrs?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false");
System.setProperty("databaseUsername", "root");
System.setProperty("databasePassword", "root");
System.setProperty("databaseDriver", "com.mysql.jdbc.Driver");
Expand All @@ -28,22 +28,23 @@ protected static void loadRuntimeProperties() {
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);
}
if (serverId == null) {
throw new RuntimeException("serverId is required as a system property");
}
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());
}
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"));
Expand Down

0 comments on commit 32cfb0f

Please sign in to comment.