From 6c8cf0c5b78c2402ed796c8aafb9cb0100449bf7 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 9 Mar 2018 10:34:25 +1300 Subject: [PATCH] #1343 - Update for ... #1283 ENH: Support simplified test configuration (with docker setup typically via application-test.yml) DefaultContainer with config.loadFromProperties(PropertiesLoader.load()); effectively runs eval twice on properties which is unnecessary. Additionally add ServerConfig.setRunMigration() because I think it makes more sense / easier to find. Remote PropertiesLoader.setProperty() as it is no longer required for the ebean-test-config plugin. --- src/main/java/io/ebean/config/ServerConfig.java | 10 ++++++++++ .../io/ebean/config/properties/PropertiesLoader.java | 11 ----------- .../ebeaninternal/server/core/DefaultContainer.java | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/ebean/config/ServerConfig.java b/src/main/java/io/ebean/config/ServerConfig.java index 28728cd22..51221e96f 100644 --- a/src/main/java/io/ebean/config/ServerConfig.java +++ b/src/main/java/io/ebean/config/ServerConfig.java @@ -1956,6 +1956,16 @@ public class ServerConfig { this.durationWithNanos = durationWithNanos; } + /** + * Set to true to run DB migrations on server start. + *

+ * This is the same as serverConfig.getMigrationConfig().setRunMigration(). We have added this method here + * as it is often the only thing we need to configure for migrations. + */ + public void setRunMigration(boolean runMigration){ + migrationConfig.setRunMigration(runMigration); + } + /** * Set to true to generate the "create all" DDL on startup. *

diff --git a/src/main/java/io/ebean/config/properties/PropertiesLoader.java b/src/main/java/io/ebean/config/properties/PropertiesLoader.java index 560d255e5..3df479919 100644 --- a/src/main/java/io/ebean/config/properties/PropertiesLoader.java +++ b/src/main/java/io/ebean/config/properties/PropertiesLoader.java @@ -56,17 +56,6 @@ public class PropertiesLoader { return properties; } - /** - * Set (override) a configuration property. - * - * This is expected to be only called by test configuration logic - * (ala automatic test configuration via ebean-test-config). - */ - public static synchronized void setProperty(String key, String value) { - load(); - properties.setProperty(key, value); - } - /** * Return a copy of the properties with 'eval' run on all the values. * This resolves expressions like ${HOME} etc. diff --git a/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java b/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java index 7f4d94422..e1e923dea 100644 --- a/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java +++ b/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java @@ -83,7 +83,7 @@ public class DefaultContainer implements SpiContainer { ServerConfig config = new ServerConfig(); config.setName(name); - config.loadFromProperties(PropertiesLoader.load()); + config.loadFromProperties(); return createServer(config); }