Skip to content

Commit

Permalink
Add support for Postgis to JDBC driver (testcontainers#864)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiview authored Sep 13, 2018
1 parent 3eb73c5 commit 1d0140a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/usage/database_containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Insert `tc:` after `jdbc:` as follows. Note that the hostname, port and database

`jdbc:tc:postgresql:9.6.8://hostname/databasename`

### Using PostGIS

`jdbc:tc:postgis:9.6://hostname/databasename`

## Using an init script

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public static Iterable<Object[]> data() {
{"jdbc:tc:mysql:5.5.43://hostname/databasename", EnumSet.noneOf(Options.class)},
{"jdbc:tc:mysql:5.5.43://hostname/databasename?useSSL=false", EnumSet.noneOf(Options.class)},
{"jdbc:tc:postgresql:9.6.8://hostname/databasename", EnumSet.noneOf(Options.class)},
{"jdbc:tc:postgis://hostname/databasename", EnumSet.noneOf(Options.class)},
{"jdbc:tc:postgis:9.6://hostname/databasename", EnumSet.noneOf(Options.class)},
{"jdbc:tc:mysql:5.6://hostname/databasename?TC_MY_CNF=somepath/mysql_conf_override", EnumSet.of(Options.CustomIniFile)},
{"jdbc:tc:mariadb://hostname/databasename", EnumSet.noneOf(Options.class)},
{"jdbc:tc:mariadb:10.2.14://hostname/databasename", EnumSet.noneOf(Options.class)},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.testcontainers.containers;

/**
* Factory for PostGIS containers, which are a special flavour of PostgreSQL.
*/
public class PostgisContainerProvider extends JdbcDatabaseContainerProvider {

private static final String NAME = "postgis";
private static final String DEFAULT_TAG = "10";
private static final String DEFAULT_IMAGE = "mdillon/postgis";

@Override
public boolean supports(String databaseType) {
return databaseType.equals(NAME);
}

@Override
public JdbcDatabaseContainer newInstance() {
return newInstance(DEFAULT_TAG);
}

@Override
public JdbcDatabaseContainer newInstance(String tag) {
return new PostgreSQLContainer(DEFAULT_IMAGE + ":" + tag);
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.testcontainers.containers.PostgreSQLContainerProvider
org.testcontainers.containers.PostgreSQLContainerProvider
org.testcontainers.containers.PostgisContainerProvider

0 comments on commit 1d0140a

Please sign in to comment.