-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align Hibernate Reactive datasource tests on Hibernate ORM
- Loading branch information
Showing
4 changed files
with
96 additions
and
9 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...ive/config/datasource/EntitiesInDefaultPUWithExplicitDatasourceConfigActiveFalseTest.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,39 @@ | ||
package io.quarkus.hibernate.reactive.config.datasource; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.hibernate.reactive.config.MyEntity; | ||
import io.quarkus.runtime.configuration.ConfigurationException; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class EntitiesInDefaultPUWithExplicitDatasourceConfigActiveFalseTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClass(MyEntity.class)) | ||
.overrideConfigKey("quarkus.hibernate-orm.datasource", "ds-1") | ||
.overrideConfigKey("quarkus.hibernate-orm.database.generation", "drop-and-create") | ||
.overrideConfigKey("quarkus.datasource.\"ds-1\".active", "false") | ||
// We need at least one build-time property for the datasource, | ||
// otherwise it's considered unconfigured at build time... | ||
.overrideConfigKey("quarkus.datasource.\"ds-1\".db-kind", "h2") | ||
.assertException(t -> assertThat(t) | ||
.isInstanceOf(ConfigurationException.class) | ||
.hasMessageContainingAll( | ||
// Hibernate Reactive doesn't support explicitly setting the datasource (yet), | ||
// so it will just notice the default datasource is not configured! | ||
"The default datasource must be configured for Hibernate Reactive", | ||
"Refer to https://quarkus.io/guides/datasource for guidance.")); | ||
|
||
@Test | ||
public void testInvalidConfiguration() { | ||
// deployment exception should happen first | ||
Assertions.fail(); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...tive/config/datasource/EntitiesInDefaultPUWithExplicitDatasourceConfigUrlMissingTest.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,40 @@ | ||
package io.quarkus.hibernate.reactive.config.datasource; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.hibernate.reactive.config.MyEntity; | ||
import io.quarkus.runtime.configuration.ConfigurationException; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class EntitiesInDefaultPUWithExplicitDatasourceConfigUrlMissingTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClass(MyEntity.class)) | ||
.overrideConfigKey("quarkus.hibernate-orm.datasource", "ds-1") | ||
.overrideConfigKey("quarkus.hibernate-orm.database.generation", "drop-and-create") | ||
// The URL won't be missing if dev services are enabled | ||
.overrideConfigKey("quarkus.devservices.enabled", "false") | ||
// We need at least one build-time property for the datasource, | ||
// otherwise it's considered unconfigured at build time... | ||
.overrideConfigKey("quarkus.datasource.ds-1.db-kind", "h2") | ||
.assertException(t -> assertThat(t) | ||
.isInstanceOf(ConfigurationException.class) | ||
.hasMessageContainingAll( | ||
// Hibernate Reactive doesn't support explicitly setting the datasource (yet), | ||
// so it will just notice the default datasource is not configured! | ||
"The default datasource must be configured for Hibernate Reactive", | ||
"Refer to https://quarkus.io/guides/datasource for guidance.")); | ||
|
||
@Test | ||
public void testInvalidConfiguration() { | ||
// deployment exception should happen first | ||
Assertions.fail(); | ||
} | ||
|
||
} |
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