-
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.
Merge pull request #20488 from mschnitzler/20177-multiple-sql-load-sc…
…ripts Add support for multiple sql load scripts
- Loading branch information
Showing
8 changed files
with
133 additions
and
53 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
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
29 changes: 29 additions & 0 deletions
29
...quarkus/hibernate/orm/sql_load_script/ImportMultipleSqlLoadScriptsFileAbsentTestCase.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,29 @@ | ||
package io.quarkus.hibernate.orm.sql_load_script; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
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.deployment.configuration.ConfigurationError; | ||
import io.quarkus.hibernate.orm.MyEntity; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class ImportMultipleSqlLoadScriptsFileAbsentTestCase { | ||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.setExpectedException(ConfigurationError.class) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(MyEntity.class, SqlLoadScriptTestResource.class) | ||
.addAsResource("application-import-multiple-load-scripts-test.properties", "application.properties") | ||
.addAsResource("import-multiple-load-scripts-1.sql", "import-1.sql")); | ||
|
||
@Test | ||
public void testImportMultipleSqlLoadScriptsTest() { | ||
// should not be called, deployment exception should happen first: | ||
// it's illegal to have Hibernate sql-load-script configuration property set | ||
// to an absent file | ||
Assertions.fail(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...t/java/io/quarkus/hibernate/orm/sql_load_script/ImportMultipleSqlLoadScriptsTestCase.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,30 @@ | ||
package io.quarkus.hibernate.orm.sql_load_script; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.hibernate.orm.MyEntity; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class ImportMultipleSqlLoadScriptsTestCase { | ||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(MyEntity.class, SqlLoadScriptTestResource.class) | ||
.addAsResource("application-import-multiple-load-scripts-test.properties", "application.properties") | ||
.addAsResource("import-multiple-load-scripts-1.sql", "import-1.sql") | ||
.addAsResource("import-multiple-load-scripts-2.sql", "import-2.sql")); | ||
|
||
@Test | ||
public void testImportMultipleSqlLoadScriptsTest() { | ||
String name1 = "import-1.sql load script entity"; | ||
String name2 = "import-2.sql load script entity"; | ||
|
||
RestAssured.when().get("/orm-sql-load-script/1").then().body(Matchers.is(name1)); | ||
RestAssured.when().get("/orm-sql-load-script/2").then().body(Matchers.is(name2)); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...rm/deployment/src/test/resources/application-import-multiple-load-scripts-test.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,7 @@ | ||
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.sql-load-script=import-1.sql,import-2.sql |
1 change: 1 addition & 0 deletions
1
extensions/hibernate-orm/deployment/src/test/resources/import-multiple-load-scripts-1.sql
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 @@ | ||
INSERT INTO MyEntity(id, name) VALUES(1, 'import-1.sql load script entity'); |
1 change: 1 addition & 0 deletions
1
extensions/hibernate-orm/deployment/src/test/resources/import-multiple-load-scripts-2.sql
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 @@ | ||
INSERT INTO MyEntity(id, name) VALUES(2, 'import-2.sql load script entity'); |
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