-
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.
Fail deployment on presence of an hibernate.properties resource
- Loading branch information
Showing
2 changed files
with
61 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
42 changes: 42 additions & 0 deletions
42
...m/deployment/src/test/java/io/quarkus/hibernate/orm/config/NoHibernatePropertiesTest.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,42 @@ | ||
package io.quarkus.hibernate.orm.config; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
/** | ||
* Since we decided that we're no longer supporting to read an hibernate.properties resource, | ||
* let's also test that this is made explicit. | ||
* N.B. while we no longer parse the file during boot, there are other components in Hibernate ORM | ||
* that look for it so this would lead to inconsistencies. | ||
*/ | ||
public class NoHibernatePropertiesTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.assertException(t -> { | ||
assertThat(t) | ||
.isInstanceOf(IllegalStateException.class) | ||
.hasMessageContainingAll( | ||
"The Hibernate ORM configuration in Quarkus does not support sourcing configuration properties from resources named `hibernate.properties`"); | ||
}) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(MyEntity.class) | ||
.addAsResource(new StringAsset(""), "hibernate.properties") | ||
.addAsResource("application.properties")) | ||
.overrideConfigKey("quarkus.datasource.devservices", "false"); | ||
|
||
@Test | ||
public void testInvalidConfiguration() { | ||
// deployment exception should happen first | ||
Assertions.fail(); | ||
} | ||
|
||
} |