From 14fc7d34791576e3295b6adb00bf48d2301c1a7d Mon Sep 17 00:00:00 2001 From: ndr_brt Date: Tue, 9 Jul 2024 11:55:25 +0200 Subject: [PATCH] adapt to new version --- .../postgresql-migration-lib/build.gradle.kts | 2 -- .../catalog-tests/build.gradle.kts | 3 +++ .../edc-controlplane/fixtures/build.gradle.kts | 7 +++---- .../runtimes/ParticipantRuntimeExtension.java | 5 ----- .../edc/tests/runtimes/PgRuntimeExtension.java | 16 ++++++++++++---- .../runtime/runtime-postgresql/build.gradle.kts | 1 + 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/edc-extensions/migrations/postgresql-migration-lib/build.gradle.kts b/edc-extensions/migrations/postgresql-migration-lib/build.gradle.kts index 1a4b8e044..e993eec8b 100644 --- a/edc-extensions/migrations/postgresql-migration-lib/build.gradle.kts +++ b/edc-extensions/migrations/postgresql-migration-lib/build.gradle.kts @@ -36,6 +36,4 @@ dependencies { // so we need to add PG support explicitly // https://documentation.red-gate.com/flyway/release-notes-and-older-versions/release-notes-for-flyway-engine runtimeOnly(libs.flyway.database.postgres) - - testImplementation(testFixtures(libs.edc.sql.core)) } diff --git a/edc-tests/edc-controlplane/catalog-tests/build.gradle.kts b/edc-tests/edc-controlplane/catalog-tests/build.gradle.kts index 42771ae1d..eb3345c80 100644 --- a/edc-tests/edc-controlplane/catalog-tests/build.gradle.kts +++ b/edc-tests/edc-controlplane/catalog-tests/build.gradle.kts @@ -29,6 +29,9 @@ dependencies { testImplementation(libs.edc.junit) testImplementation(libs.restAssured) testImplementation(libs.awaitility) + + testCompileOnly(project(":edc-tests:runtime:runtime-memory")) + testCompileOnly(project(":edc-tests:runtime:runtime-postgresql")) } // do not publish diff --git a/edc-tests/edc-controlplane/fixtures/build.gradle.kts b/edc-tests/edc-controlplane/fixtures/build.gradle.kts index 36972578b..b40ec289a 100644 --- a/edc-tests/edc-controlplane/fixtures/build.gradle.kts +++ b/edc-tests/edc-controlplane/fixtures/build.gradle.kts @@ -47,15 +47,14 @@ dependencies { testFixturesImplementation(libs.edc.identity.trust.sts.embedded) testFixturesImplementation(libs.edc.core.token) testFixturesImplementation(libs.edc.spi.identity.did) - testFixturesImplementation(testFixtures(libs.edc.sql.core)) + testFixturesImplementation(libs.postgres) testFixturesImplementation(libs.testcontainers.postgres) - - testCompileOnly(project(":edc-tests:runtime:runtime-memory")) - testFixturesImplementation(libs.assertj) testFixturesImplementation(libs.junit.jupiter.api) testFixturesImplementation(project(":edc-extensions:bpn-validation:bpn-validation-spi")) + testCompileOnly(project(":edc-tests:runtime:runtime-memory")) + testCompileOnly(project(":edc-tests:runtime:runtime-postgresql")) } // do not publish diff --git a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/ParticipantRuntimeExtension.java b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/ParticipantRuntimeExtension.java index 3931f00bb..32bb4e180 100644 --- a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/ParticipantRuntimeExtension.java +++ b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/ParticipantRuntimeExtension.java @@ -19,7 +19,6 @@ package org.eclipse.tractusx.edc.tests.runtimes; -import org.eclipse.edc.junit.extensions.EmbeddedRuntime; import org.eclipse.edc.junit.extensions.RuntimePerClassExtension; import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.ExtensionContext; @@ -40,10 +39,6 @@ public ParticipantRuntimeExtension(String moduleName, String runtimeName, String } } - public ParticipantRuntimeExtension(EmbeddedRuntime embeddedRuntime) { - super(embeddedRuntime); - } - @Override public void afterEach(ExtensionContext extensionContext) { ((ParticipantRuntime) runtime).getWiper().clearPersistence(); diff --git a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java index 6472aebee..3d2e8a86a 100644 --- a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java +++ b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java @@ -19,11 +19,12 @@ package org.eclipse.tractusx.edc.tests.runtimes; -import org.eclipse.edc.sql.testfixtures.PostgresqlLocalInstance; import org.junit.jupiter.api.extension.ExtensionContext; import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.containers.wait.strategy.Wait; +import java.sql.DriverManager; +import java.sql.SQLException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -45,7 +46,7 @@ public class PgRuntimeExtension extends ParticipantRuntimeExtension { private final String dbName; public PgRuntimeExtension(String moduleName, String runtimeName, String bpn, Map properties) { - super(new ParticipantRuntime(moduleName, runtimeName, bpn, properties)); + super(moduleName, runtimeName, bpn, properties, null); this.dbName = runtimeName.toLowerCase(); postgreSqlContainer = new PostgreSQLContainer<>(POSTGRES_IMAGE_NAME) .withLabel("runtime", dbName) @@ -62,8 +63,7 @@ public void beforeAll(ExtensionContext context) { postgreSqlContainer.waitingFor(Wait.forHealthcheck()); var config = postgresqlConfiguration(dbName); config.forEach(System::setProperty); - PostgresqlLocalInstance helper = new PostgresqlLocalInstance(postgreSqlContainer.getUsername(), postgreSqlContainer.getPassword(), baseJdbcUrl(), postgreSqlContainer.getDatabaseName()); - helper.createDatabase(); + createDatabase(); super.beforeAll(context); } @@ -95,6 +95,14 @@ public String jdbcUrl(String name) { return baseJdbcUrl() + name + "?currentSchema=" + DB_SCHEMA_NAME; } + private void createDatabase() { + try (var connection = DriverManager.getConnection(baseJdbcUrl() + "postgres", postgreSqlContainer.getUsername(), postgreSqlContainer.getPassword())) { + connection.createStatement().execute(String.format("create database %s;", postgreSqlContainer.getDatabaseName())); + } catch (SQLException ignored) { + + } + } + public String baseJdbcUrl() { return format("jdbc:postgresql://%s:%s/", postgreSqlContainer.getHost(), postgreSqlContainer.getFirstMappedPort()); } diff --git a/edc-tests/runtime/runtime-postgresql/build.gradle.kts b/edc-tests/runtime/runtime-postgresql/build.gradle.kts index f05dad383..b4071b82d 100644 --- a/edc-tests/runtime/runtime-postgresql/build.gradle.kts +++ b/edc-tests/runtime/runtime-postgresql/build.gradle.kts @@ -49,6 +49,7 @@ dependencies { implementation(libs.edc.core.controlplane) // for the controller implementation(libs.jakarta.rsApi) + runtimeOnly(libs.edc.transaction.local) } application {