-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prevent using SQL modules with the NoopTransactionContext (#4326)
* feat: prevent using SQL modules with the NoopTransactionContext * DEPENDENCIES * add txlocal to test runner
- Loading branch information
1 parent
baf2e2b
commit 2cf9bf2
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
extensions/common/sql/sql-core/src/test/java/org/eclipse/edc/sql/SqlCoreExtensionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.sql; | ||
|
||
import org.eclipse.edc.junit.annotations.ComponentTest; | ||
import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; | ||
import org.eclipse.edc.spi.EdcException; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
import org.eclipse.edc.transaction.spi.NoopTransactionContext; | ||
import org.eclipse.edc.transaction.spi.TransactionContext; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
@ComponentTest | ||
@ExtendWith(DependencyInjectionExtension.class) | ||
class SqlCoreExtensionTest { | ||
private ServiceExtensionContext context; | ||
|
||
@BeforeEach | ||
void setup(ServiceExtensionContext context) { | ||
this.context = context; | ||
context.registerService(TransactionContext.class, new NoopTransactionContext()); | ||
} | ||
|
||
@Test | ||
void initialize(SqlCoreExtension extension) { | ||
assertThatThrownBy(() -> extension.initialize(context)).isInstanceOf(EdcException.class) | ||
.hasMessage("The EDC SQL implementations cannot be used with a '%s'. Please provide a TransactionContext implementation.".formatted(NoopTransactionContext.class.getName())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters