mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge remote-tracking branch 'upstream/master' into ebean-new
This commit is contained in:
@@ -27,16 +27,17 @@ public class DatabaseConfigTest {
|
||||
@Test
|
||||
public void evalPropertiesInput() {
|
||||
|
||||
String home = System.getenv("HOME");
|
||||
String home = System.getProperty("user.home");
|
||||
String fileSeparator = System.getProperty("file.separator");
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty("ddl.initSql", "${HOME}/initSql");
|
||||
props.setProperty("ddl.initSql", "${user.home}" + fileSeparator + "initSql");
|
||||
|
||||
DatabaseConfig config = new DatabaseConfig();
|
||||
config.loadFromProperties(props);
|
||||
|
||||
String ddlInitSql = config.getDdlInitSql();
|
||||
assertThat(ddlInitSql).isEqualTo(home+"/initSql");
|
||||
assertThat(ddlInitSql).isEqualTo(home + fileSeparator + "initSql");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -50,30 +50,31 @@ public class PropertiesWrapperTest {
|
||||
@Test
|
||||
public void testGetProperties() {
|
||||
|
||||
String home = System.getenv("HOME");
|
||||
String home = System.getProperty("user.home");
|
||||
String tmpDir = System.getProperty("java.io.tmpdir");
|
||||
String fileSeparator = System.getProperty("file.separator");
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put("someBasic", "hello");
|
||||
properties.put("someInt", "42");
|
||||
properties.put("someDouble", "5.5");
|
||||
properties.put("somePath", "${HOME}/hello");
|
||||
properties.put("someSystemProp", "/aaa/${java.io.tmpdir}/bbb");
|
||||
properties.put("somePath", "${user.home}" + fileSeparator + "hello");
|
||||
properties.put("someSystemProp", fileSeparator + "aaa" + fileSeparator + "${java.io.tmpdir}" + fileSeparator + "bbb");
|
||||
|
||||
Properties evalCopy = Config.asConfiguration().eval(properties);
|
||||
PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", evalCopy, null);
|
||||
|
||||
assertEquals(42, pw.getInt("someInt", 99));
|
||||
assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D))));
|
||||
assertEquals(home + "/hello", pw.get("somePath", null));
|
||||
assertEquals("/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp"));
|
||||
assertEquals(home + fileSeparator + "hello", pw.get("somePath", null));
|
||||
assertEquals(fileSeparator + "aaa" + fileSeparator + tmpDir + fileSeparator + "bbb", pw.get("someSystemProp"));
|
||||
|
||||
pw = new PropertiesWrapper(evalCopy, null);
|
||||
|
||||
assertEquals(42, pw.getInt("someInt", 99));
|
||||
assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D))));
|
||||
assertEquals(home + "/hello", pw.get("somePath", null));
|
||||
assertEquals("/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp"));
|
||||
assertEquals(home + fileSeparator + "hello", pw.get("somePath", null));
|
||||
assertEquals(fileSeparator + "aaa" + fileSeparator + tmpDir + fileSeparator + "bbb", pw.get("someSystemProp"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user