Skip to content

Commit

Permalink
Merge branch 'refs/heads/feature/134-update-junit' into feature/136-t…
Browse files Browse the repository at this point in the history
…estcontainers
  • Loading branch information
Daniel Kubanyi committed Jul 19, 2024
2 parents 22ad88d + 063ee4a commit 6300049
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import ch.so.agi.gretl.testutil.TestTags;
import ch.so.agi.gretl.testutil.TestUtil;
import org.interlis2.validator.Validator;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.*;
import org.testcontainers.containers.PostgisContainerProvider;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.Wait;
Expand All @@ -38,7 +35,7 @@ public class PublisherStepDb2LocalTest {
private static final Path localTestOut = Paths.get("build").resolve("out");

@Container
public PostgreSQLContainer<?> postgres = System.getProperty("dbUrl") == null
public static PostgreSQLContainer<?> postgres = System.getProperty("dbUrl") == null
? (PostgreSQLContainer<?>) new PostgisContainerProvider().newInstance()
.withDatabaseName(TestUtil.PG_DB_NAME)
.withUsername(TestUtil.PG_DDLUSR_USR)
Expand All @@ -47,19 +44,22 @@ public class PublisherStepDb2LocalTest {
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2))
: null;

private String dbUrl;
private String dbUser;
private String dbPassword;
private String dbSchema;
private static String dbUrl;
private static String dbUser;
private static String dbPassword;
private static String dbSchema;
private Config config;

@BeforeAll
public static void beforeAll() {
dbUrl = System.getProperty("dbUrl", postgres != null ? postgres.getJdbcUrl() : null);
dbUser = System.getProperty("dbusr", TestUtil.PG_DDLUSR_USR);
dbPassword = System.getProperty("dbPassword", TestUtil.PG_DDLUSR_PWD);
dbSchema = "publisher";
}

@BeforeEach
public void before() {
this.dbUrl = System.getProperty("dbUrl", postgres != null ? postgres.getJdbcUrl() : null);
this.dbUser = System.getProperty("dbusr", TestUtil.PG_DDLUSR_USR);
this.dbPassword = System.getProperty("dbPassword", TestUtil.PG_DDLUSR_PWD);
this.dbSchema = "publisher";

this.config = new Config();
config.setModeldir(Ili2db.ILI_FROM_DB+ch.interlis.ili2c.Main.ILIDIR_SEPARATOR + AbstractPublisherStepTest.ILI_DIRS);
config.setDburl(dbUrl);
Expand All @@ -86,7 +86,7 @@ public void after() {
}

@Test
@Tag("dbTest")
@Tag(TestTags.DB_TEST)
public void db_allNew() throws Exception {
Path targetFolder = localTestOut.resolve(AbstractPublisherStepTest.SRC_DATA_IDENT);
String datasetName = "av";
Expand Down

0 comments on commit 6300049

Please sign in to comment.