mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2101 - Refactor to make ebean-migration optional dependency
This commit is contained in:
@@ -3,7 +3,7 @@ package io.ebean.config;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import io.ebean.migration.MigrationConfig;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -13,12 +13,13 @@ public class DbMigrationConfigTest {
|
||||
@Test
|
||||
public void testLoad() {
|
||||
|
||||
ServerConfig config = new ServerConfig();
|
||||
DatabaseConfig config = new DatabaseConfig();
|
||||
config.setName("h2other");
|
||||
config.loadFromProperties();
|
||||
config.setDefaultServer(false);
|
||||
|
||||
DbMigrationConfig migrationConfig = config.getMigrationConfig();
|
||||
MigrationConfig migrationConfig = new MigrationConfig();
|
||||
migrationConfig.load(config.getProperties());
|
||||
|
||||
assertThat(migrationConfig.getMigrationPath()).isEqualTo("dbmigration/myapp");
|
||||
}
|
||||
@@ -27,20 +28,18 @@ public class DbMigrationConfigTest {
|
||||
public void loadProperties_migration() {
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("ebean.migration.dbusername", "banana");
|
||||
properties.setProperty("ebean.migration.dbpassword", "apple");
|
||||
properties.setProperty("ebean.migration.username", "banana");
|
||||
properties.setProperty("ebean.migration.password", "apple");
|
||||
properties.setProperty("ebean.migration.patchInsertOn", "1.3,my_views");
|
||||
properties.setProperty("ebean.migration.patchResetChecksumOn", "foo");
|
||||
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "db", properties, null);
|
||||
|
||||
DbMigrationConfig migrationConfig = new DbMigrationConfig();
|
||||
migrationConfig.loadSettings(wrapper, "db");
|
||||
MigrationConfig migrationConfig = new MigrationConfig();
|
||||
migrationConfig.load(properties);
|
||||
|
||||
assertEquals(migrationConfig.getDbUsername(),"banana");
|
||||
assertEquals(migrationConfig.getDbPassword(),"apple");
|
||||
assertEquals(migrationConfig.getPatchInsertOn(),"1.3,my_views");
|
||||
assertEquals(migrationConfig.getPatchResetChecksumOn(),"foo");
|
||||
assertThat(migrationConfig.getPatchInsertOn()).containsOnly("1.3","my_views");
|
||||
assertThat(migrationConfig.getPatchResetChecksumOn()).containsOnly("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -50,29 +49,12 @@ public class DbMigrationConfigTest {
|
||||
properties.setProperty("datasource.db.username", "banana");
|
||||
properties.setProperty("datasource.db.password", "apple");
|
||||
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "db", properties, null);
|
||||
|
||||
DbMigrationConfig migrationConfig = new DbMigrationConfig();
|
||||
migrationConfig.loadSettings(wrapper, "db");
|
||||
MigrationConfig migrationConfig = new MigrationConfig();
|
||||
migrationConfig.load(properties);
|
||||
|
||||
// runnerConfig will fall back itsel to the correct password
|
||||
assertEquals(migrationConfig.getDbUsername(),null);
|
||||
assertEquals(migrationConfig.getDbPassword(),null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadProperties_datasource_adminusername() {
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("datasource.db.adminusername", "banana");
|
||||
properties.setProperty("datasource.db.adminpassword", "apple");
|
||||
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "db", properties, null);
|
||||
|
||||
DbMigrationConfig migrationConfig = new DbMigrationConfig();
|
||||
migrationConfig.loadSettings(wrapper, "db");
|
||||
|
||||
assertEquals(migrationConfig.getDbUsername(),"banana");
|
||||
assertEquals(migrationConfig.getDbPassword(),"apple");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user