forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case to make sure DDL scripts are not created in append mode
The test uses `QuarkusDevModeTest` to make sure the DDL generation is executed individually for both test method executions. Fixes quarkusio#17924
- Loading branch information
1 parent
e2bbdc8
commit 7fa4a56
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...ent/src/test/java/io/quarkus/hibernate/orm/scripts/GenerateScriptNotAppendedTestCase.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,31 @@ | ||
package io.quarkus.hibernate.orm.scripts; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.regex.Pattern; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.RepeatedTest; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.hibernate.orm.MyEntity; | ||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class GenerateScriptNotAppendedTestCase { | ||
|
||
@RegisterExtension | ||
static QuarkusDevModeTest runner = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource("application-generate-script.properties", "application.properties") | ||
.addClasses(MyEntity.class)); | ||
|
||
@RepeatedTest(2) | ||
public void verifyScriptIsOverwritten() throws Exception { | ||
String script = Files.readString(Path.of(GenerateScriptNotAppendedTestCase.class.getResource("/create.sql").toURI())); | ||
assertEquals(1, Pattern.compile("create table MyEntity").matcher(script).results().count()); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...nsions/hibernate-orm/deployment/src/test/resources/application-generate-script.properties
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,9 @@ | ||
quarkus.datasource.db-kind=h2 | ||
quarkus.datasource.jdbc.url=jdbc:h2:mem:test | ||
|
||
quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect | ||
quarkus.hibernate-orm.log.sql=true | ||
quarkus.hibernate-orm.database.generation=drop-and-create | ||
|
||
quarkus.hibernate-orm.scripts.generation=create | ||
quarkus.hibernate-orm.scripts.generation.create-target=target/test-classes/create.sql |