Skip to content

Commit

Permalink
Feature/151 homogenisierung testcode (#166)
Browse files Browse the repository at this point in the history
* wip: homogenizing tests

Signed-off-by: Daniel Kubányi <[email protected]>

* wip: homogenizing tests

Signed-off-by: Daniel Kubányi <[email protected]>

* feat: improve code quality

Signed-off-by: Daniel Kubányi <[email protected]>

* wip: homogenisierung testcode

* wip: homogenisierung testcode

* feat: improve code quality

Signed-off-by: Daniel Kubányi <[email protected]>

* wip: improve code quality

Signed-off-by: Daniel Kubányi <[email protected]>

* wip: improve code quality

Signed-off-by: Daniel Kubányi <[email protected]>

* wip: improve code quality

Signed-off-by: Daniel Kubányi <[email protected]>

* wip: improve code quality

Signed-off-by: Daniel Kubányi <[email protected]>

* feat: homogenize test code

Signed-off-by: Daniel Kubányi <[email protected]>

* chore: cleanup

Signed-off-by: Daniel Kubányi <[email protected]>

---------

Signed-off-by: Daniel Kubányi <[email protected]>
  • Loading branch information
dkubanyi authored Jun 28, 2024
1 parent 2f47488 commit 3eccb00
Show file tree
Hide file tree
Showing 51 changed files with 1,882 additions and 2,462 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.so.agi.gretl.jobs;

import ch.so.agi.gretl.testutil.TestUtil;
import ch.so.agi.gretl.util.GradleVariable;
import ch.so.agi.gretl.util.IntegrationTestUtil;
import ch.so.agi.gretl.util.IntegrationTestUtilSql;
Expand All @@ -17,15 +18,14 @@
import java.sql.Statement;

public class CsvExportTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
(PostgreSQLContainer) new PostgisContainerProvider()
.newInstance().withDatabaseName("gretl")
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void exportOk() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.so.agi.gretl.jobs;

import ch.so.agi.gretl.testutil.TestUtil;
import ch.so.agi.gretl.util.GradleVariable;
import ch.so.agi.gretl.util.IntegrationTestUtil;
import ch.so.agi.gretl.util.IntegrationTestUtilSql;
Expand All @@ -20,15 +21,14 @@
import org.junit.ClassRule;

public class CsvImportTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
(PostgreSQLContainer) new PostgisContainerProvider()
.newInstance().withDatabaseName("gretl")
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void importOk() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.sql.Connection;
import java.sql.Statement;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.PostgisContainerProvider;
Expand All @@ -15,15 +16,14 @@
import ch.so.agi.gretl.util.IntegrationTestUtilSql;

public class DatabaseDocumentExportTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
(PostgreSQLContainer) new PostgisContainerProvider()
.newInstance().withDatabaseName("gretl")
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void exportOk() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.so.agi.gretl.jobs;

import ch.so.agi.gretl.testutil.TestUtil;
import ch.so.agi.gretl.util.GradleVariable;
import ch.so.agi.gretl.util.IntegrationTestUtil;
import ch.so.agi.gretl.util.IntegrationTestUtilSql;
Expand All @@ -15,18 +16,15 @@
import java.sql.SQLException;
import java.sql.Statement;



public class Db2DbTaskTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
(PostgreSQLContainer) new PostgisContainerProvider()
.newInstance().withDatabaseName("gretl")
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

/*
* Tests if fetchSize parameter is working.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ch.ehi.ili2gpkg.Gpkg2iox;
import ch.interlis.iom.IomObject;
import ch.so.agi.gretl.testutil.TestUtil;
import ch.so.agi.gretl.util.GradleVariable;
import ch.so.agi.gretl.util.IntegrationTestUtil;
import ch.so.agi.gretl.util.IntegrationTestUtilSql;
Expand All @@ -24,15 +25,14 @@
import org.junit.ClassRule;

public class GpkgExportTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
(PostgreSQLContainer) new PostgisContainerProvider()
.newInstance().withDatabaseName("gretl")
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void exportTableOk() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.so.agi.gretl.jobs;

import ch.so.agi.gretl.testutil.TestUtil;
import ch.so.agi.gretl.util.GradleVariable;
import ch.so.agi.gretl.util.IntegrationTestUtil;
import ch.so.agi.gretl.util.IntegrationTestUtilSql;
Expand All @@ -19,15 +20,14 @@
import org.junit.ClassRule;

public class GpkgImportTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
(PostgreSQLContainer) new PostgisContainerProvider()
.newInstance().withDatabaseName("gretl")
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void importOk() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.sql.Statement;
import java.util.HashSet;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.PostgisContainerProvider;
Expand All @@ -19,7 +20,6 @@
import ch.so.agi.gretl.util.IntegrationTestUtilSql;

public class Ili2pgDeleteDatasetsTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
Expand All @@ -28,7 +28,7 @@ public class Ili2pgDeleteDatasetsTest {
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withPassword(IntegrationTestUtilSql.PG_CON_DDLPASS)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void deleteOk() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.sql.ResultSet;
import java.sql.Statement;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.PostgisContainerProvider;
Expand All @@ -24,7 +25,6 @@
import ch.ehi.ili2pg.PgMain;

public class Ili2pgDeleteTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
Expand All @@ -33,7 +33,7 @@ public class Ili2pgDeleteTest {
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withPassword(IntegrationTestUtilSql.PG_CON_DDLPASS)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void deleteDataset_Ok() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.sql.Statement;
import java.util.HashSet;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.PostgisContainerProvider;
Expand All @@ -28,7 +29,6 @@
import ch.so.agi.gretl.util.IntegrationTestUtilSql;

public class Ili2pgExportDatasetsTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
Expand All @@ -37,7 +37,7 @@ public class Ili2pgExportDatasetsTest {
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withPassword(IntegrationTestUtilSql.PG_CON_DDLPASS)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void exportOk() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.sql.Statement;
import java.util.HashSet;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.PostgisContainerProvider;
Expand All @@ -19,7 +20,6 @@
import ch.so.agi.gretl.util.IntegrationTestUtilSql;

public class Ili2pgImportFileSetTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
Expand All @@ -28,7 +28,7 @@ public class Ili2pgImportFileSetTest {
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withPassword(IntegrationTestUtilSql.PG_CON_DDLPASS)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void importOk() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.sql.ResultSet;
import java.sql.Statement;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.PostgisContainerProvider;
Expand All @@ -18,7 +19,6 @@
import ch.so.agi.gretl.util.IntegrationTestUtilSql;

public class Ili2pgImportSchemaTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
Expand All @@ -27,7 +27,7 @@ public class Ili2pgImportSchemaTest {
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withPassword(IntegrationTestUtilSql.PG_CON_DDLPASS)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void schemaImportOk() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.sql.Statement;
import java.util.HashSet;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.PostgisContainerProvider;
Expand All @@ -19,7 +20,6 @@
import ch.so.agi.gretl.util.IntegrationTestUtilSql;

public class Ili2pgReplaceFileTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
Expand All @@ -28,7 +28,7 @@ public class Ili2pgReplaceFileTest {
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withPassword(IntegrationTestUtilSql.PG_CON_DDLPASS)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void importLocalFile_Ok() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.PostgisContainerProvider;
Expand All @@ -17,7 +18,6 @@
import ch.so.agi.gretl.util.IntegrationTestUtilSql;

public class Ili2pgValidateDatasetTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
Expand All @@ -26,7 +26,7 @@ public class Ili2pgValidateDatasetTest {
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withPassword(IntegrationTestUtilSql.PG_CON_DDLPASS)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void validateSingleDataset_Ok() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.PostgisContainerProvider;
Expand All @@ -17,7 +18,6 @@
import ch.so.agi.gretl.util.IntegrationTestUtilSql;

public class Ili2pgValidateTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

@ClassRule
public static PostgreSQLContainer postgres =
Expand All @@ -26,7 +26,7 @@ public class Ili2pgValidateTest {
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withPassword(IntegrationTestUtilSql.PG_CON_DDLPASS)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void validateData_Ok() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.sql.ResultSet;
import java.sql.Statement;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
Expand All @@ -20,7 +21,6 @@
import ch.so.agi.gretl.util.IntegrationTestUtilSql;

public class JsonImportTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";

private static String dbusr = "ddluser";
private static String dbpwd = "ddluser";
Expand All @@ -33,7 +33,7 @@ public class JsonImportTest {
.withUsername(dbusr)
.withPassword(dbpwd)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void importJsonObject_Ok() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.so.agi.gretl.jobs;

import ch.so.agi.gretl.testutil.TestUtil;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Rule;
Expand All @@ -20,15 +21,14 @@
import static org.junit.Assert.assertEquals;

public class PostgisRasterExportTest {
static String WAIT_PATTERN = ".*database system is ready to accept connections.*\\s";


@ClassRule
public static PostgreSQLContainer postgres =
(PostgreSQLContainer) new PostgisContainerProvider()
.newInstance().withDatabaseName("gretl")
.withUsername(IntegrationTestUtilSql.PG_CON_DDLUSER)
.withInitScript("init_postgresql.sql")
.waitingFor(Wait.forLogMessage(WAIT_PATTERN, 2));
.waitingFor(Wait.forLogMessage(TestUtil.WAIT_PATTERN, 2));

@Test
public void exportTiff() throws Exception {
Expand Down
Loading

0 comments on commit 3eccb00

Please sign in to comment.