You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/08/26 15:48:04 UTC

[GitHub] [camel-quarkus] osmman commented on a diff in pull request #4053: Fix #4007 increase JPA extension test coverage

osmman commented on code in PR #4053:
URL: https://github.com/apache/camel-quarkus/pull/4053#discussion_r956180190


##########
integration-tests/jpa/src/test/java/org/apache/camel/quarkus/component/jpa/it/JpaTest.java:
##########
@@ -16,63 +16,153 @@
  */
 package org.apache.camel.quarkus.component.jpa.it;
 
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.h2.H2DatabaseTestResource;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.jpa.it.model.Fruit;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
+import static org.awaitility.Awaitility.await;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.hasItems;
 import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
 
 @QuarkusTest
-@QuarkusTestResource(H2DatabaseTestResource.class)
 class JpaTest {
 
-    @Test
-    public void testJpaComponent() {
-        String[] fruits = new String[] { "Orange", "Lemon", "Plum" };
+    static final String[] FRUITS = new String[] { "Orange", "Lemon", "Plum" };
 
-        // Create Fruit entities
-        for (String fruit : fruits) {
+    @BeforeAll
+    public static void storeFruits() {
+        final Config config = ConfigProvider.getConfig();
+        int port = config.getValue("quarkus.http.test-port", int.class);
+        RestAssured.port = port;
+        for (String fruit : FRUITS) {
             RestAssured.given()
-                    .contentType(ContentType.TEXT)
-                    .body(fruit)
-                    .post("/jpa/post")
+                    .contentType(ContentType.JSON)
+                    .body(new Fruit(fruit))
+                    .post("/jpa/fruit")
                     .then()
                     .statusCode(201);
         }
+    }
+
+    @Test
+    public void testProducerQuery() {
+        RestAssured.get("/jpa/fruit")
+                .then()
+                .statusCode(200)
+                .body("name", containsInAnyOrder(FRUITS));
+    }
+
+    @Test
+    public void testProducerNamedQuery() {
+        RestAssured.get("/jpa/fruit/named/" + FRUITS[0])
+                .then()
+                .statusCode(200)
+                .body("name", contains(FRUITS[0]));
+    }
+
+    @Test
+    public void testProducerNativeQuery() {
+        RestAssured.get("/jpa/fruit/native/2")
+                .then()
+                .statusCode(200)
+                .body("name", contains(FRUITS[1]));
+    }
+
+    @Test
+    public void testConsumer() {

Review Comment:
   It tests `from("jpa:Fruit?namedQuery=unprocessed)` route with usage of `@Consumed` and `@PreConsumed` annotations. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org