Changesets · Branches · Tags · Compare
| Changeset | 3cd7a22d5fb761b761e4edd724dfaa02689013d74ae9b926fafae42bdedbe2fd |
|---|---|
| Author | Paul Latzelsperger <43503240+paullatzelsperger@users.noreply.github.com> · 2024-07-05 07:54 +02:00 |
| Committer | GitHub <noreply@github.com> · 2024-07-05 07:54 +02:00 |
| Parents | 119681864e62 |
5 files changed
modified extensions/common/sql/sql-core/src/main/java/org/eclipse/edc/sql/SqlCoreExtension.java +14 −0
| @@ -15,10 +15,14 @@ | ||
| 15 | 15 | package org.eclipse.edc.sql; |
| 16 | 16 | |
| 17 | 17 | import org.eclipse.edc.runtime.metamodel.annotation.Extension; |
| 18 | +import org.eclipse.edc.runtime.metamodel.annotation.Inject; | |
| 18 | 19 | import org.eclipse.edc.runtime.metamodel.annotation.Provider; |
| 19 | 20 | import org.eclipse.edc.runtime.metamodel.annotation.Setting; |
| 21 | +import org.eclipse.edc.spi.EdcException; | |
| 20 | 22 | import org.eclipse.edc.spi.system.ServiceExtension; |
| 21 | 23 | import org.eclipse.edc.spi.system.ServiceExtensionContext; |
| 24 | +import org.eclipse.edc.transaction.spi.NoopTransactionContext; | |
| 25 | +import org.eclipse.edc.transaction.spi.TransactionContext; | |
| 22 | 26 | |
| 23 | 27 | import static java.lang.Integer.parseInt; |
| 24 | 28 | |
| @@ -31,11 +35,21 @@ | ||
| 31 | 35 | @Setting(value = "Fetch size value used in SQL queries", defaultValue = DEFAULT_EDC_SQL_FETCH_SIZE) |
| 32 | 36 | public static final String EDC_SQL_FETCH_SIZE = "edc.sql.fetch.size"; |
| 33 | 37 | |
| 38 | + @Inject | |
| 39 | + private TransactionContext transactionContext; | |
| 40 | + | |
| 34 | 41 | @Override |
| 35 | 42 | public String name() { |
| 36 | 43 | return NAME; |
| 37 | 44 | } |
| 38 | 45 | |
| 46 | + @Override | |
| 47 | + public void initialize(ServiceExtensionContext context) { | |
| 48 | + if (transactionContext instanceof NoopTransactionContext) { | |
| 49 | + throw new EdcException("The EDC SQL implementations cannot be used with a '%s'. Please provide a TransactionContext implementation.".formatted(NoopTransactionContext.class.getName())); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 39 | 53 | @Provider |
| 40 | 54 | public QueryExecutor sqlQueryExecutor(ServiceExtensionContext context) { |
| 41 | 55 | var fetchSize = context.getSetting(EDC_SQL_FETCH_SIZE, parseInt(DEFAULT_EDC_SQL_FETCH_SIZE)); |
added extensions/common/sql/sql-core/src/test/java/org/eclipse/edc/sql/SqlCoreExtensionTest.java +45 −0
| @@ -0,0 +1,45 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | |
| 3 | + * | |
| 4 | + * This program and the accompanying materials are made available under the | |
| 5 | + * terms of the Apache License, Version 2.0 which is available at | |
| 6 | + * https://www.apache.org/licenses/LICENSE-2.0 | |
| 7 | + * | |
| 8 | + * SPDX-License-Identifier: Apache-2.0 | |
| 9 | + * | |
| 10 | + * Contributors: | |
| 11 | + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | |
| 12 | + * | |
| 13 | + */ | |
| 14 | + | |
| 15 | +package org.eclipse.edc.sql; | |
| 16 | + | |
| 17 | +import org.eclipse.edc.junit.annotations.ComponentTest; | |
| 18 | +import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; | |
| 19 | +import org.eclipse.edc.spi.EdcException; | |
| 20 | +import org.eclipse.edc.spi.system.ServiceExtensionContext; | |
| 21 | +import org.eclipse.edc.transaction.spi.NoopTransactionContext; | |
| 22 | +import org.eclipse.edc.transaction.spi.TransactionContext; | |
| 23 | +import org.junit.jupiter.api.BeforeEach; | |
| 24 | +import org.junit.jupiter.api.Test; | |
| 25 | +import org.junit.jupiter.api.extension.ExtendWith; | |
| 26 | + | |
| 27 | +import static org.assertj.core.api.Assertions.assertThatThrownBy; | |
| 28 | + | |
| 29 | +@ComponentTest | |
| 30 | +@ExtendWith(DependencyInjectionExtension.class) | |
| 31 | +class SqlCoreExtensionTest { | |
| 32 | + private ServiceExtensionContext context; | |
| 33 | + | |
| 34 | + @BeforeEach | |
| 35 | + void setup(ServiceExtensionContext context) { | |
| 36 | + this.context = context; | |
| 37 | + context.registerService(TransactionContext.class, new NoopTransactionContext()); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Test | |
| 41 | + void initialize(SqlCoreExtension extension) { | |
| 42 | + assertThatThrownBy(() -> extension.initialize(context)).isInstanceOf(EdcException.class) | |
| 43 | + .hasMessage("The EDC SQL implementations cannot be used with a '%s'. Please provide a TransactionContext implementation.".formatted(NoopTransactionContext.class.getName())); | |
| 44 | + } | |
| 45 | +} | |
| No newline at the end of the file |
modified system-tests/e2e-transfer-test/runner/build.gradle.kts +1 −0
| @@ -20,6 +20,7 @@ | ||
| 20 | 20 | testImplementation(project(":spi:control-plane:transfer-spi")) |
| 21 | 21 | testImplementation(project(":spi:data-plane:data-plane-spi")) |
| 22 | 22 | testImplementation(project(":extensions:common:sql:sql-core")) |
| 23 | + testImplementation(project(":extensions:common:transaction:transaction-local")) | |
| 23 | 24 | |
| 24 | 25 | testImplementation(project(":spi:common:web-spi")) |
| 25 | 26 | testImplementation(project(":core:common:connector-core")) |
modified system-tests/management-api/management-api-test-runner/build.gradle.kts +1 −0
| @@ -39,6 +39,7 @@ | ||
| 39 | 39 | testImplementation(libs.awaitility) |
| 40 | 40 | testImplementation(libs.junit.jupiter.api) |
| 41 | 41 | testImplementation(testFixtures(project(":extensions:common:sql:sql-core"))) |
| 42 | + testImplementation(project(":extensions:common:transaction:transaction-local")) | |
| 42 | 43 | testImplementation(libs.testcontainers.junit) |
| 43 | 44 | testImplementation(libs.testcontainers.postgres) |
| 44 | 45 | } |
modified system-tests/version-api/version-api-test-runner/build.gradle.kts +1 −0
| @@ -42,6 +42,7 @@ | ||
| 42 | 42 | testImplementation(libs.awaitility) |
| 43 | 43 | testImplementation(libs.junit.jupiter.api) |
| 44 | 44 | testImplementation(testFixtures(project(":extensions:common:sql:sql-core"))) |
| 45 | + testImplementation(project(":extensions:common:transaction:transaction-local")) | |
| 45 | 46 | testImplementation(libs.testcontainers.junit) |
| 46 | 47 | testImplementation(libs.testcontainers.postgres) |
| 47 | 48 | } |