Skip to content

Commit

Permalink
#85 - Add PostgisContainer to make it more easy/obvious when using Po…
Browse files Browse the repository at this point in the history
…stGIS
  • Loading branch information
rbygrave committed Jun 13, 2022
1 parent 5e452de commit e6cbe4b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
4 changes: 4 additions & 0 deletions src/main/java/io/ebean/test/containers/ContainerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ private void init() {
if (pgVersion != null) {
containers.add(PostgresContainer.builder(pgVersion).properties(properties).build());
}
String pgisVersion = runWithVersion("postgis");
if (pgisVersion != null) {
containers.add(PostgisContainer.builder(pgisVersion).properties(properties).build());
}
String mysqlVersion = runWithVersion("mysql");
if (mysqlVersion != null) {
containers.add(MySqlContainer.builder(mysqlVersion).properties(properties).build());
Expand Down
34 changes: 12 additions & 22 deletions src/test/java/io/ebean/test/containers/ContainerFactoryTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.ebean.test.containers;

import io.ebean.test.containers.Container;
import io.ebean.test.containers.ContainerFactory;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

Expand All @@ -12,28 +10,28 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

public class ContainerFactoryTest {
class ContainerFactoryTest {

static final String MYSQL_VER = "8.0";

@Test
public void runWith() {

void runWith() {
Properties properties = new Properties();
properties.setProperty("postgres.version", "9.6");
properties.setProperty("mysql.version", MYSQL_VER);
properties.setProperty("sqlserver.version", "2017-CE");
properties.setProperty("postgis.version", "14-3.2");

ContainerFactory factory = new ContainerFactory(properties);

assertEquals("9.6", factory.runWithVersion("postgres"));
assertEquals(MYSQL_VER, factory.runWithVersion("mysql"));
assertEquals("2017-CE", factory.runWithVersion("sqlserver"));
assertEquals("14-3.2", factory.runWithVersion("postgis"));
}

@Test
public void runWithNuoDB() {

void runWithNuoDB() {
Properties properties = new Properties();
properties.setProperty("nuodb.version", "4.0.0");
properties.setProperty("nuodb.schema", "junk");
Expand All @@ -48,8 +46,7 @@ public void runWithNuoDB() {

@Disabled
@Test
public void runWith_Cockroach() {

void runWith_Cockroach() {
Properties properties = new Properties();
properties.setProperty("cockroach.version", "v21.2.9");

Expand All @@ -61,8 +58,7 @@ public void runWith_Cockroach() {
}

@Test
public void runWith_Yugabyte() {

void runWith_Yugabyte() {
Properties properties = new Properties();
properties.setProperty("yugabyte.version", "2.11.2.0-b89");

Expand All @@ -74,8 +70,7 @@ public void runWith_Yugabyte() {
}

@Test
public void runWithHana() {

void runWithHana() {
assumeThat(System.getProperty("os.name").toLowerCase()).contains("linux");

Properties properties = new Properties();
Expand All @@ -93,8 +88,7 @@ public void runWithHana() {
}

@Test
public void runWith_specifiedWithComma() {

void runWith_specifiedWithComma() {
Properties properties = new Properties();
properties.setProperty("postgres.version", "9.6");
properties.setProperty("mysql.version", MYSQL_VER);
Expand All @@ -110,8 +104,7 @@ public void runWith_specifiedWithComma() {
}

@Test
public void runWith_specifiedOne() {

void runWith_specifiedOne() {
Properties properties = new Properties();
properties.setProperty("postgres.version", "9.6");
properties.setProperty("mysql.version", MYSQL_VER);
Expand All @@ -127,16 +120,14 @@ public void runWith_specifiedOne() {
}

@Test
public void runWith_specified_viaEnv() {

void runWith_specified_viaEnv() {
Properties properties = new Properties();
properties.setProperty("postgres.version", "9.6");
properties.setProperty("mysql.version", MYSQL_VER);
properties.setProperty("sqlserver.version", "2017-CE");
properties.setProperty("hana.version", "2.00.033.00.20180925.2");
properties.setProperty("yugabyte.version", "2.8");


System.setProperty("docker_run_with", "mysql");
try {
ContainerFactory factory = new ContainerFactory(properties);
Expand All @@ -153,8 +144,7 @@ public void runWith_specified_viaEnv() {
}

@Test
public void create() throws Exception {

void create() throws Exception {
Properties properties = new Properties();
properties.setProperty("postgres.version", "11");
properties.setProperty("postgres.containerName", "junk_postgres11");
Expand Down

0 comments on commit e6cbe4b

Please # to comment.