Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ebean-test: Modify postgis platform to support both net.postgis and og.postgis #3449

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ ebean:
test:
# useDocker: false
# shutdown: stop # stop | remove
platform: netpostgis
platform: postgis
ddlMode: dropCreate # none | dropCreate | create | migration | createOnly | migrationDropCreate
dbName: mynetgisapp

netpostgis:
containerName: ebeanbuild_postgisnet
postgis:
containerName: ebeanbuild_postgis2
port: 9433
image: ghcr.io/baosystems/postgis:15
# extensions: postgis
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class PlatformAutoConfig {
KNOWN_PLATFORMS.put("sqlite", new SqliteSetup());
KNOWN_PLATFORMS.put("postgres", new PostgresSetup());
KNOWN_PLATFORMS.put("postgis", new PostgisSetup());
KNOWN_PLATFORMS.put("netpostgis", new NetPostgisSetup());
KNOWN_PLATFORMS.put("nuodb", new NuoDBSetup());
KNOWN_PLATFORMS.put("mysql", new MySqlSetup());
KNOWN_PLATFORMS.put("mariadb", new MariaDBSetup());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/
class PostgisSetup implements PlatformSetup {

private static final String NET_POSTGIS_DRIVER = "net.postgis.jdbc.DriverWrapperLW";
private static final String ORG_POSTGIS_DRIVER = "org.postgis.DriverWrapperLW";

@Override
public Properties setup(Config config) {
int defaultPort = config.isUseDocker() ? 7432 : 5432;
Expand All @@ -17,9 +20,8 @@ public Properties setup(Config config) {
config.setDefaultPort(defaultPort);
config.setUsernameDefault();
config.setPasswordDefault();
config.setDriver("org.postgis.DriverWrapperLW");
config.setDriver(driver(config));
config.setUrl("jdbc:postgresql_lwgis://${host}:${port}/${databaseName}");

String schema = config.getSchema();
if (schema != null && !schema.equals(config.getUsername())) {
config.urlAppend("?currentSchema=" + schema);
Expand All @@ -28,6 +30,19 @@ public Properties setup(Config config) {
return dockerProperties(config);
}

private String driver(Config config) {
String driver = config.getPlatformKey("driver", "");
if (!driver.isEmpty()) {
return driver;
}
try {
Class.forName(NET_POSTGIS_DRIVER);
return NET_POSTGIS_DRIVER;
} catch (ClassNotFoundException e){
return ORG_POSTGIS_DRIVER;
}
}

private Properties dockerProperties(Config config) {
if (!config.isUseDocker()) {
return new Properties();
Expand Down