Skip to content

Commit a503061

Browse files
committed
For PostgisContainer add useLW(true) support
This allows the connection jdbc url to have the prefix of jdbc:postgresql_lwgis rather than the usual jdbc:postgresql
1 parent 484c1ad commit a503061

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@
135135
<scope>test</scope>
136136
</dependency>
137137

138+
<dependency>
139+
<groupId>net.postgis</groupId>
140+
<artifactId>postgis-jdbc</artifactId>
141+
<version>2023.1.0</version>
142+
<scope>test</scope>
143+
</dependency>
144+
138145
<dependency>
139146
<groupId>ru.yandex.clickhouse</groupId>
140147
<artifactId>clickhouse-jdbc</artifactId>

src/main/java/io/ebean/test/containers/PostgisContainer.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ private PostgisContainer(Builder config) {
3535
*/
3636
public static class Builder extends BaseDbBuilder<PostgisContainer, Builder> {
3737

38+
private boolean useLW;
39+
3840
private Builder(String version) {
3941
super("postgis", 6432, 5432, version);
4042
this.image = "ghcr.io/baosystems/postgis:" + version;
@@ -44,19 +46,32 @@ private Builder(String version) {
4446
this.extraDbExtensions = extensions;
4547
}
4648

49+
private String prefix() {
50+
return useLW ? "jdbc:postgresql_lwgis://" : "jdbc:postgresql://";
51+
}
52+
4753
@Override
4854
protected String buildJdbcUrl() {
49-
return "jdbc:postgresql://" + host + ":" + port + "/" + dbName;
55+
return prefix() + host + ":" + port + "/" + dbName;
5056
}
5157

5258
@Override
5359
protected String buildJdbcAdminUrl() {
54-
return "jdbc:postgresql://" + host + ":" + port + "/postgres";
60+
return prefix() + host + ":" + port + "/postgres";
5561
}
5662

5763
@Override
5864
protected String buildExtraJdbcUrl() {
59-
return "jdbc:postgresql://" + host + ":" + port + "/" + extraDb;
65+
return prefix() + host + ":" + port + "/" + extraDb;
66+
}
67+
68+
/**
69+
* Set to use HexWKB and DriverWrapperLW. The JDBC URL will prefix with
70+
* <code>jdbc:postgresql_lwgis://</code> instead of <code>jdbc:postgresql://</code>.
71+
*/
72+
Builder useLW(boolean useLW) {
73+
this.useLW = useLW;
74+
return this;
6075
}
6176

6277
@Override

src/test/java/io/ebean/test/containers/PostgisContainerTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class PostgisContainerTest {
1616
void extraDb() throws java.sql.SQLException {
1717
PostgisContainer container = PostgisContainer.builder("15")
1818
.port(0)
19+
.useLW(true)
1920
.extraDb("myextra")
2021
.build();
2122

@@ -27,6 +28,7 @@ void extraDb() throws java.sql.SQLException {
2728

2829
String jdbcUrl = container.config().jdbcUrl();
2930
assertThat(jdbcUrl).contains(":" + containerConfig.port());
31+
assertThat(jdbcUrl).startsWith("jdbc:postgresql_lwgis://");
3032
runSomeSql(container);
3133

3234
DataSourcePool dataSource = container.ebean().dataSourceBuilder().build();

0 commit comments

Comments
 (0)