diff --git a/integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/Person.java b/extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/Person.java similarity index 79% rename from integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/Person.java rename to extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/Person.java index c93442cdc243a..d75f1988fbd53 100644 --- a/integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/Person.java +++ b/extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/Person.java @@ -1,4 +1,4 @@ -package io.quarkus.it.hibernate.panache.person; +package io.quarkus.hibernate.orm.panache.deployment.test.record; import jakarta.persistence.Entity; diff --git a/integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/PersonName.java b/extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/PersonName.java similarity index 69% rename from integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/PersonName.java rename to extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/PersonName.java index 6dd48b17fda5d..395bdd5e214a7 100644 --- a/integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/PersonName.java +++ b/extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/PersonName.java @@ -1,4 +1,4 @@ -package io.quarkus.it.hibernate.panache.person; +package io.quarkus.hibernate.orm.panache.deployment.test.record; import io.quarkus.runtime.annotations.RegisterForReflection; diff --git a/extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/RecordInPanacheTest.java b/extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/RecordInPanacheTest.java new file mode 100644 index 0000000000000..f8f9e5d196490 --- /dev/null +++ b/extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/RecordInPanacheTest.java @@ -0,0 +1,72 @@ +package io.quarkus.hibernate.orm.panache.deployment.test.record; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import jakarta.transaction.Transactional; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; + +class RecordInPanacheTest { + + @RegisterExtension + static QuarkusUnitTest runner = new QuarkusUnitTest() + .withApplicationRoot((jar) -> jar + .addAsResource("application-test.properties", "application.properties") + .addClasses(Person.class, PersonName.class, Status.class)); + + @Test + @Transactional + void testRecordInPanache() { + var person1 = new Person(); + person1.firstname = "Loïc"; + person1.lastname = "Mathieu"; + person1.status = Status.ALIVE; + person1.persist(); + + var person2 = new Person(); + person1.firstname = "Zombie"; + person2.lastname = "Zombie"; + person2.status = Status.DEAD; + person2.persist(); + + assertEquals(2L, Person.count()); + + } + + @Test + @Transactional + void testHqlPanacheProject() { + var mark = new Person(); + mark.firstname = "Mark"; + mark.lastname = "Mark"; + mark.persistAndFlush(); + + var hqlWithoutSpace = """ + select + firstname, + lastname + from + io.quarkus.hibernate.orm.panache.deployment.test.record.Person + where + firstname = ?1 + """; + var persistedWithoutSpace = Person.find(hqlWithoutSpace, "Mark").project(PersonName.class).firstResult(); + assertEquals("Mark", persistedWithoutSpace.firstname()); + + // We need to escape the whitespace in Java otherwise the compiler removes it. + var hqlWithSpace = """ + select\s + firstname, + lastname + from + io.quarkus.hibernate.orm.panache.deployment.test.record.Person + where + firstname = ?1 + """; + var persistedWithSpace = Person.find(hqlWithSpace, "Mark").project(PersonName.class).firstResult(); + assertEquals("Mark", persistedWithSpace.firstname()); + } +} diff --git a/integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/Status.java b/extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/Status.java similarity index 82% rename from integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/Status.java rename to extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/Status.java index 1f2b06dbc4f57..c0c9d50209cf7 100644 --- a/integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/Status.java +++ b/extensions/panache/hibernate-orm-panache/deployment/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/record/Status.java @@ -1,4 +1,4 @@ -package io.quarkus.it.hibernate.panache.person; +package io.quarkus.hibernate.orm.panache.deployment.test.record; public enum Status { DEAD("I'm a Zombie"), diff --git a/integration-tests/java-17/pom.xml b/integration-tests/java-17/pom.xml deleted file mode 100644 index 442cf8ebd9720..0000000000000 --- a/integration-tests/java-17/pom.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - 4.0.0 - - - io.quarkus - quarkus-integration-tests-parent - 999-SNAPSHOT - - - quarkus-integration-test-java-17 - - Quarkus - Integration Tests - Java 17 - - - 17 - - - - - io.quarkus - quarkus-resteasy-reactive-jackson - - - io.quarkus - quarkus-mongodb-panache - - - io.quarkus - quarkus-hibernate-orm-panache - - - io.quarkus - quarkus-jdbc-h2 - - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test - - - io.quarkus - quarkus-test-mongodb - test - - - io.quarkus - quarkus-test-h2 - test - - - - - io.quarkus - quarkus-mongodb-panache-deployment - ${project.version} - pom - test - - - * - * - - - - - io.quarkus - quarkus-hibernate-orm-panache-deployment - ${project.version} - pom - test - - - * - * - - - - - io.quarkus - quarkus-jdbc-h2-deployment - ${project.version} - pom - test - - - * - * - - - - - io.quarkus - quarkus-resteasy-reactive-jackson-deployment - ${project.version} - pom - test - - - * - * - - - - - - - - - src/main/resources - true - - - - - maven-failsafe-plugin - - true - - - - io.quarkus - quarkus-maven-plugin - - - - build - - - - - - - - \ No newline at end of file diff --git a/integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/PersonResource.java b/integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/PersonResource.java deleted file mode 100644 index 7935235a7c18b..0000000000000 --- a/integration-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/PersonResource.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.quarkus.it.hibernate.panache.person; - -import java.net.URI; -import java.util.Arrays; -import java.util.List; - -import jakarta.transaction.Transactional; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.core.Response; - -@Path("/hibernate/persons") -@Transactional -public class PersonResource { - @GET - public List getPersons() { - return Person.findAll().project(PersonName.class).list(); - } - - @POST - public Response addPerson(Person person) { - person.persist(); - String id = person.id.toString(); - return Response.created(URI.create("/persons/entity/" + id)).build(); - } - - @GET - @Path("hql-project") - @Transactional - public Response testPanacheHqlProject() { - var mark = new Person(); - mark.firstname = "Mark"; - mark.lastname = "Mark"; - mark.persistAndFlush(); - - var hqlWithoutSpace = """ - select - firstname, - lastname - from - io.quarkus.it.hibernate.panache.person.Person - where - firstname = ?1 - """; - var persistedWithoutSpace = Person.find(hqlWithoutSpace, "Mark").project(PersonName.class).firstResult(); - - // We need to escape the whitespace in Java otherwise the compiler removes it. - var hqlWithSpace = """ - select\s - firstname, - lastname - from - io.quarkus.it.hibernate.panache.person.Person - where - firstname = ?1 - """; - var persistedWithSpace = Person.find(hqlWithSpace, "Mark").project(PersonName.class).firstResult(); - - return Response.ok(Arrays.asList(persistedWithoutSpace, persistedWithSpace)).build(); - } -} diff --git a/integration-tests/java-17/src/main/resources/application.properties b/integration-tests/java-17/src/main/resources/application.properties deleted file mode 100644 index b54b42cd1b42f..0000000000000 --- a/integration-tests/java-17/src/main/resources/application.properties +++ /dev/null @@ -1,7 +0,0 @@ -quarkus.mongodb.connection-string=mongodb://localhost:27017 -quarkus.mongodb.database=persons - -quarkus.datasource.db-kind=h2 -quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test -quarkus.datasource.jdbc.max-size=8 -quarkus.hibernate-orm.database.generation=drop-and-create \ No newline at end of file diff --git a/integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/PersonName.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/PersonName.java similarity index 58% rename from integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/PersonName.java rename to integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/PersonName.java index dfadda4abc8e1..21baf3976b594 100644 --- a/integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/PersonName.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/PersonName.java @@ -1,7 +1,7 @@ -package io.quarkus.it.mongodb.panache.person; +package io.quarkus.it.mongodb.panache.record; import io.quarkus.mongodb.panache.common.ProjectionFor; -@ProjectionFor(Person.class) +@ProjectionFor(PersonWithRecord.class) public record PersonName(String firstName, String lastName) { } diff --git a/integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/PersonResource.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/PersonResource.java similarity index 71% rename from integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/PersonResource.java rename to integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/PersonResource.java index f719d5800ecf1..21b72c87cd5a8 100644 --- a/integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/PersonResource.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/PersonResource.java @@ -1,4 +1,4 @@ -package io.quarkus.it.mongodb.panache.person; +package io.quarkus.it.mongodb.panache.record; import java.net.URI; import java.util.List; @@ -12,11 +12,11 @@ public class PersonResource { @GET public List getPersons() { - return Person.findAll().project(PersonName.class).list(); + return PersonWithRecord.findAll().project(PersonName.class).list(); } @POST - public Response addPerson(Person person) { + public Response addPerson(PersonWithRecord person) { person.persist(); String id = person.id.toString(); return Response.created(URI.create("/persons/entity/" + id)).build(); diff --git a/integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/Person.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/PersonWithRecord.java similarity index 59% rename from integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/Person.java rename to integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/PersonWithRecord.java index 80479c3dab703..5aa5543d42269 100644 --- a/integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/Person.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/PersonWithRecord.java @@ -1,8 +1,8 @@ -package io.quarkus.it.mongodb.panache.person; +package io.quarkus.it.mongodb.panache.record; import io.quarkus.mongodb.panache.PanacheMongoEntity; -public class Person extends PanacheMongoEntity { +public class PersonWithRecord extends PanacheMongoEntity { public String firstname; public String lastname; public Status status = Status.ALIVE; diff --git a/integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/Status.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/Status.java similarity index 87% rename from integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/Status.java rename to integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/Status.java index 0a7180aab25e7..09ccc049a6e0a 100644 --- a/integration-tests/java-17/src/main/java/io/quarkus/it/mongodb/panache/person/Status.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/record/Status.java @@ -1,4 +1,4 @@ -package io.quarkus.it.mongodb.panache.person; +package io.quarkus.it.mongodb.panache.record; public enum Status { DEAD("I'm a Zombie"), diff --git a/integration-tests/java-17/src/test/java/io/quarkus/it/hibernate/panache/person/PersonResourceTest.java b/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/record/MongodbPanacheRecordIT.java similarity index 53% rename from integration-tests/java-17/src/test/java/io/quarkus/it/hibernate/panache/person/PersonResourceTest.java rename to integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/record/MongodbPanacheRecordIT.java index 601241f450872..1c3331c2ca996 100644 --- a/integration-tests/java-17/src/test/java/io/quarkus/it/hibernate/panache/person/PersonResourceTest.java +++ b/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/record/MongodbPanacheRecordIT.java @@ -1,4 +1,4 @@ -package io.quarkus.it.hibernate.panache.person; +package io.quarkus.it.mongodb.panache.record; import static io.restassured.RestAssured.given; import static io.restassured.RestAssured.when; @@ -6,27 +6,21 @@ import org.junit.jupiter.api.Test; -import io.quarkus.it.mongodb.panache.person.Person; -import io.quarkus.it.mongodb.panache.person.Status; -import io.quarkus.test.TestTransaction; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.h2.H2DatabaseTestResource; -import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.QuarkusIntegrationTest; import io.restassured.http.ContentType; -@QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class PersonResourceTest { - private static final String ROOT_URL = "/hibernate/persons"; +@QuarkusIntegrationTest +class MongodbPanacheRecordIT extends MongodbPanacheRecordTest { + + private static final String ROOT_URL = "/mongo/persons"; @Test - @TestTransaction void testRecordInPanache() { - var person1 = new Person(); + var person1 = new PersonWithRecord(); person1.firstname = "Loïc"; person1.lastname = "Mathieu"; person1.status = Status.ALIVE; - var person2 = new Person(); + var person2 = new PersonWithRecord(); person1.firstname = "Zombie"; person2.lastname = "Zombie"; person2.status = Status.DEAD; @@ -43,12 +37,4 @@ void testRecordInPanache() { .statusCode(200) .body("size()", is(2)); } - - @Test - @TestTransaction - void testHqlPanacheProject() { - when().get(ROOT_URL + "/hql-project") - .then().statusCode(200) - .body("size()", is(2)); - } } diff --git a/integration-tests/java-17/src/test/java/io/quarkus/it/mongodb/panache/person/PersonResourceTest.java b/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/record/MongodbPanacheRecordTest.java similarity index 78% rename from integration-tests/java-17/src/test/java/io/quarkus/it/mongodb/panache/person/PersonResourceTest.java rename to integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/record/MongodbPanacheRecordTest.java index 72c3162cdfdca..1d2920ec8551b 100644 --- a/integration-tests/java-17/src/test/java/io/quarkus/it/mongodb/panache/person/PersonResourceTest.java +++ b/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/record/MongodbPanacheRecordTest.java @@ -1,4 +1,4 @@ -package io.quarkus.it.mongodb.panache.person; +package io.quarkus.it.mongodb.panache.record; import static io.restassured.RestAssured.given; import static io.restassured.RestAssured.when; @@ -8,21 +8,22 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.mongodb.MongoTestResource; +import io.quarkus.test.mongodb.MongoReplicaSetTestResource; import io.restassured.http.ContentType; @QuarkusTest -@QuarkusTestResource(MongoTestResource.class) -class PersonResourceTest { +@QuarkusTestResource(MongoReplicaSetTestResource.class) +class MongodbPanacheRecordTest { + private static final String ROOT_URL = "/mongo/persons"; @Test void testRecordInPanache() { - var person1 = new Person(); + var person1 = new PersonWithRecord(); person1.firstname = "Loïc"; person1.lastname = "Mathieu"; person1.status = Status.ALIVE; - var person2 = new Person(); + var person2 = new PersonWithRecord(); person1.firstname = "Zombie"; person2.lastname = "Zombie"; person2.status = Status.DEAD; @@ -39,5 +40,4 @@ void testRecordInPanache() { .statusCode(200) .body("size()", is(2)); } - } diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 125140f43cb10..f5dfb87b32557 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -404,20 +404,6 @@ - - - java-17 - - - !no-test-modules - - [17,) - - - java-17 - - -