mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
ADD.profile and autodetect code
This commit is contained in:
@@ -6,8 +6,8 @@ datasource.default=h2
|
||||
|
||||
datasource.h2.username=sa
|
||||
datasource.h2.password=
|
||||
datasource.h2.url=jdbc:h2:mem:tests
|
||||
datasource.h2.url=jdbc:h2:mem:tests;NON_KEYWORDS=KEY
|
||||
|
||||
datasource.pg.username=sa
|
||||
datasource.pg.password=
|
||||
datasource.pg.url=jdbc:h2:mem:tests
|
||||
datasource.pg.url=jdbc:h2:mem:tests;NON_KEYWORDS=KEY
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* Automatically configure ServerConfig for testing purposes.
|
||||
* <p>
|
||||
@@ -47,6 +49,29 @@ public class AutoConfigureForTesting implements AutoConfigure {
|
||||
@Override
|
||||
public void postConfigure(DatabaseConfig config) {
|
||||
setupProviders(config);
|
||||
|
||||
if (org.h2.engine.Constants.VERSION_MAJOR == 1) {
|
||||
// This code may be removed later, when droppinv H2 1.xxx compatibility
|
||||
System.err.println("Running tests in H2 1.xxx compatibility mode");
|
||||
System.setProperty("ebean.h2.useV1Syntax", "true");
|
||||
makeV1Compatible(config.getDataSourceConfig());
|
||||
makeV1Compatible(config.getReadOnlyDataSourceConfig());
|
||||
}
|
||||
}
|
||||
|
||||
private void makeV1Compatible(DataSourceConfig ds) {
|
||||
if (ds == null) {
|
||||
return;
|
||||
}
|
||||
String url = ds.getUrl();
|
||||
if (url == null || !url.startsWith("jdbc:h2:")) {
|
||||
return;
|
||||
}
|
||||
// remove illegal URL options
|
||||
url = url.replace(";MODE=LEGACY", "");
|
||||
url = url.replace(";NON_KEYWORDS=KEY,VALUE", "");
|
||||
url = url.replace(";NON_KEYWORDS=KEY", "");
|
||||
ds.setUrl(url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -101,7 +101,7 @@ public class PlatformNoGeneratedKeysTest {
|
||||
config.setDatabasePlatform(platform);
|
||||
config.getDataSourceConfig().setUsername("sa");
|
||||
config.getDataSourceConfig().setPassword("");
|
||||
config.getDataSourceConfig().setUrl("jdbc:h2:mem:withPCQuery");
|
||||
config.getDataSourceConfig().setUrl("jdbc:h2:mem:withPCQuery;MODE=LEGACY");
|
||||
config.getDataSourceConfig().setDriver("org.h2.Driver");
|
||||
|
||||
config.setDisableLazyLoading(true);
|
||||
@@ -112,7 +112,7 @@ public class PlatformNoGeneratedKeysTest {
|
||||
config.setDdlRun(true);
|
||||
config.getClasses().add(EBasicVer.class);
|
||||
config.getClasses().add(BasicDraftableBean.class);
|
||||
|
||||
config.loadFromProperties(); // trigger auto config for H2 1.x
|
||||
|
||||
return DatabaseFactory.create(config);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ datasource.db.databaseDriver=org.h2.Driver
|
||||
|
||||
datasource.h2.username=sa
|
||||
datasource.h2.password=
|
||||
datasource.h2.url=jdbc:h2:mem:testsMem;DB_CLOSE_ON_EXIT=FALSE
|
||||
datasource.h2.url=jdbc:h2:mem:testsMem;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE
|
||||
datasource.h2.poolListener=org.tests.basic.MyTestDataSourcePoolListener
|
||||
#datasource.h2.minConnections=1
|
||||
#datasource.h2.maxConnections=25
|
||||
|
||||
@@ -8,5 +8,5 @@ ebean.jodaLocalTimeMode=normal
|
||||
|
||||
datasource.someotherdb.username=sa
|
||||
datasource.someotherdb.password=
|
||||
datasource.someotherdb.databaseUrl=jdbc:h2:mem:someotherdb
|
||||
datasource.someotherdb.databaseUrl=jdbc:h2:mem:someotherdb;NON_KEYWORDS=KEY,VALUE
|
||||
datasource.someotherdb.databaseDriver=org.h2.Driver
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<properties>
|
||||
<nexus.staging.autoReleaseAfterClose>false</nexus.staging.autoReleaseAfterClose>
|
||||
<jackson.version>2.12.1</jackson.version>
|
||||
<h2database.version>1.4.199</h2database.version>
|
||||
<h2database.version>2.1.210</h2database.version>
|
||||
<ebean-ddl-runner.version>1.2</ebean-ddl-runner.version>
|
||||
<ebean-migration-auto.version>1.1</ebean-migration-auto.version>
|
||||
<ebean-migration.version>12.13.1</ebean-migration.version>
|
||||
@@ -99,6 +99,12 @@
|
||||
<profile>
|
||||
<id>release</id>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>h2v1</id>
|
||||
<properties>
|
||||
<h2database.version>1.4.199</h2database.version>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>default</id>
|
||||
<activation>
|
||||
|
||||
Reference in New Issue
Block a user