mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-27 00:02:42 +00:00
#1342 - Refactor and rename DbTypeConfig to Platform config to support multi-platform db migration
This commit is contained in:
@@ -32,7 +32,7 @@ public class DbMigrationConfigTest {
|
||||
properties.setProperty("ebean.migration.patchInsertOn", "1.3,my_views");
|
||||
properties.setProperty("ebean.migration.patchResetChecksumOn", "foo");
|
||||
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "db", properties);
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "db", properties, null);
|
||||
|
||||
DbMigrationConfig migrationConfig = new DbMigrationConfig();
|
||||
migrationConfig.loadSettings(wrapper, "db");
|
||||
@@ -50,7 +50,7 @@ public class DbMigrationConfigTest {
|
||||
properties.setProperty("datasource.db.username", "banana");
|
||||
properties.setProperty("datasource.db.password", "apple");
|
||||
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "db", properties);
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "db", properties, null);
|
||||
|
||||
DbMigrationConfig migrationConfig = new DbMigrationConfig();
|
||||
migrationConfig.loadSettings(wrapper, "db");
|
||||
@@ -67,7 +67,7 @@ public class DbMigrationConfigTest {
|
||||
properties.setProperty("datasource.db.adminusername", "banana");
|
||||
properties.setProperty("datasource.db.adminpassword", "apple");
|
||||
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "db", properties);
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "db", properties, null);
|
||||
|
||||
DbMigrationConfig migrationConfig = new DbMigrationConfig();
|
||||
migrationConfig.loadSettings(wrapper, "db");
|
||||
|
||||
@@ -5,7 +5,9 @@ import org.junit.Test;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class DocStoreConfigTest {
|
||||
|
||||
@@ -23,7 +25,7 @@ public class DocStoreConfigTest {
|
||||
properties.setProperty("ebean.docstore.username", "fred");
|
||||
properties.setProperty("ebean.docstore.password", "rock");
|
||||
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", null, properties);
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", null, properties, null);
|
||||
|
||||
config.loadSettings(wrapper);
|
||||
|
||||
@@ -47,7 +49,7 @@ public class DocStoreConfigTest {
|
||||
properties.setProperty("ebean.docstore.generateMapping", "true");
|
||||
properties.setProperty("ebean.docstore.dropCreate", "true");
|
||||
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", null, properties);
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", null, properties, null);
|
||||
config.loadSettings(wrapper);
|
||||
|
||||
assertTrue(config.isGenerateMapping());
|
||||
@@ -64,7 +66,7 @@ public class DocStoreConfigTest {
|
||||
properties.setProperty("ebean.docstore.generateMapping", "true");
|
||||
properties.setProperty("ebean.docstore.create", "true");
|
||||
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", null, properties);
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", null, properties, null);
|
||||
config.loadSettings(wrapper);
|
||||
|
||||
assertTrue(config.isGenerateMapping());
|
||||
|
||||
@@ -20,7 +20,7 @@ public class MatchingNamingConventionTest {
|
||||
|
||||
SqlServer17Platform platform = new SqlServer17Platform();
|
||||
|
||||
ServerConfig config = new ServerConfig();
|
||||
PlatformConfig config = new PlatformConfig();
|
||||
config.setAllQuotedIdentifiers(true);
|
||||
platform.configure(config);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class PropertiesWrapperTest {
|
||||
@Test
|
||||
public void testGetServerName() {
|
||||
|
||||
PropertiesWrapper pw = new PropertiesWrapper(null, "myserver", new Properties());
|
||||
PropertiesWrapper pw = new PropertiesWrapper(null, "myserver", new Properties(), null);
|
||||
assertEquals("myserver", pw.getServerName());
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class PropertiesWrapperTest {
|
||||
Properties properties = new Properties();
|
||||
properties.put("platform", "postgres");
|
||||
|
||||
PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", properties);
|
||||
PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", properties, null);
|
||||
assertEquals(Platform.POSTGRES, pw.getEnum(Platform.class, "platform", Platform.H2));
|
||||
assertEquals(Platform.H2, pw.getEnum(Platform.class, "junk", Platform.H2));
|
||||
assertNull(pw.getEnum(Platform.class, "junk", null));
|
||||
@@ -40,7 +40,7 @@ public class PropertiesWrapperTest {
|
||||
properties.put("noTrimReqr", "jim");
|
||||
properties.put("includeSpaces", " jim bob ");
|
||||
|
||||
PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", properties);
|
||||
PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", properties, null);
|
||||
assertEquals(" hello ", pw.get("someBasic"));
|
||||
assertEquals(42, pw.getInt("someInt", 1));
|
||||
assertNull(pw.get("doesNotExist", null));
|
||||
@@ -62,14 +62,14 @@ public class PropertiesWrapperTest {
|
||||
properties.put("someSystemProp", "/aaa/${java.io.tmpdir}/bbb");
|
||||
|
||||
Properties evalCopy = PropertiesLoader.eval(properties);
|
||||
PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", evalCopy);
|
||||
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(tmpDir, "/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp"));
|
||||
|
||||
pw = new PropertiesWrapper(evalCopy);
|
||||
pw = new PropertiesWrapper(evalCopy, null);
|
||||
|
||||
assertEquals(42, pw.getInt("someInt", 99));
|
||||
assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D))));
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ServerConfigTest {
|
||||
assertEquals(IdType.SEQUENCE, serverConfig.getIdType());
|
||||
assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatch());
|
||||
assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatchOnCascade());
|
||||
assertEquals(ServerConfig.DbUuid.BINARY, serverConfig.getDbTypeConfig().getDbUuid());
|
||||
assertEquals(PlatformConfig.DbUuid.BINARY, serverConfig.getPlatformConfig().getDbUuid());
|
||||
assertEquals(JsonConfig.DateTime.ISO8601, serverConfig.getJsonDateTime());
|
||||
|
||||
assertEquals(42, serverConfig.getJdbcFetchSizeFindEach());
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.ebean.config.dbplatform;
|
||||
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.DbTypeConfig;
|
||||
import io.ebean.config.MatchingNamingConvention;
|
||||
import io.ebean.config.PlatformConfig;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
|
||||
@@ -21,7 +21,7 @@ public class DatabasePlatformTest {
|
||||
config.setNamingConvention(new MatchingNamingConvention());
|
||||
|
||||
DatabasePlatform dbPlatform = new SqlServer17Platform();
|
||||
dbPlatform.configure(config.getDbTypeConfig(), config.isAllQuotedIdentifiers());
|
||||
dbPlatform.configure(config.getPlatformConfig(), config.isAllQuotedIdentifiers());
|
||||
|
||||
assertEquals(dbPlatform.convertQuotedIdentifiers("order"),"[order]");
|
||||
assertEquals(dbPlatform.convertQuotedIdentifiers("`order`"),"[order]");
|
||||
@@ -34,7 +34,7 @@ public class DatabasePlatformTest {
|
||||
ServerConfig config = new ServerConfig();
|
||||
|
||||
DatabasePlatform dbPlatform = new SqlServer17Platform();
|
||||
dbPlatform.configure(config.getDbTypeConfig(), config.isAllQuotedIdentifiers());
|
||||
dbPlatform.configure(config.getPlatformConfig(), config.isAllQuotedIdentifiers());
|
||||
|
||||
assertEquals(dbPlatform.convertQuotedIdentifiers("order"),"order");
|
||||
assertEquals(dbPlatform.convertQuotedIdentifiers("`order`"),"[order]");
|
||||
@@ -56,7 +56,7 @@ public class DatabasePlatformTest {
|
||||
@Test
|
||||
public void configure_customType() throws Exception {
|
||||
|
||||
DbTypeConfig config = new DbTypeConfig();
|
||||
PlatformConfig config = new PlatformConfig();
|
||||
config.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES);
|
||||
config.addCustomMapping(DbType.DECIMAL, "decimal(24,4)");
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.ebean.config.dbplatform;
|
||||
|
||||
import io.ebean.config.DbTypeConfig;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.PlatformConfig;
|
||||
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.platform.PlatformDdl;
|
||||
import io.ebeaninternal.server.core.PlatformDdlBuilder;
|
||||
@@ -28,7 +27,7 @@ public class MySqlPlatformTest {
|
||||
public void uuid_default() {
|
||||
|
||||
MySqlPlatform platform = new MySqlPlatform();
|
||||
platform.configure(new DbTypeConfig(), false);
|
||||
platform.configure(new PlatformConfig(), false);
|
||||
|
||||
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
|
||||
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar(40)");
|
||||
@@ -39,8 +38,8 @@ public class MySqlPlatformTest {
|
||||
public void uuid_as_binary() {
|
||||
|
||||
MySqlPlatform platform = new MySqlPlatform();
|
||||
DbTypeConfig config = new DbTypeConfig();
|
||||
config.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY);
|
||||
PlatformConfig config = new PlatformConfig();
|
||||
config.setDbUuid(PlatformConfig.DbUuid.AUTO_BINARY);
|
||||
platform.configure(config, false);
|
||||
|
||||
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.ebean.config.dbplatform;
|
||||
|
||||
import io.ebean.config.DbTypeConfig;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.PlatformConfig;
|
||||
import io.ebean.config.dbplatform.oracle.OraclePlatform;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.platform.PlatformDdl;
|
||||
import io.ebeaninternal.server.core.PlatformDdlBuilder;
|
||||
@@ -37,7 +36,7 @@ public class OraclePlatformTest {
|
||||
public void uuid_default() {
|
||||
|
||||
OraclePlatform platform = new OraclePlatform();
|
||||
platform.configure(new DbTypeConfig(), false);
|
||||
platform.configure(new PlatformConfig(), false);
|
||||
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
|
||||
|
||||
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar2(40)");
|
||||
@@ -48,8 +47,8 @@ public class OraclePlatformTest {
|
||||
public void uuid_as_binary() {
|
||||
|
||||
OraclePlatform platform = new OraclePlatform();
|
||||
DbTypeConfig config = new DbTypeConfig();
|
||||
config.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY);
|
||||
PlatformConfig config = new PlatformConfig();
|
||||
config.setDbUuid(PlatformConfig.DbUuid.AUTO_BINARY);
|
||||
|
||||
platform.configure(config, false);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.ebean.config.dbplatform;
|
||||
|
||||
import io.ebean.config.DbTypeConfig;
|
||||
import io.ebean.config.PlatformConfig;
|
||||
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.platform.PlatformDdl;
|
||||
import io.ebeaninternal.server.core.PlatformDdlBuilder;
|
||||
@@ -37,7 +37,7 @@ public class PostgresPlatformTest {
|
||||
public void testUuidType() {
|
||||
|
||||
PostgresPlatform platform = new PostgresPlatform();
|
||||
platform.configure(new DbTypeConfig(), false);
|
||||
platform.configure(new PlatformConfig(), false);
|
||||
|
||||
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
|
||||
String columnDefn = dbType.renderType(0, 0);
|
||||
|
||||
Reference in New Issue
Block a user