JiriOndrusek commented on code in PR #3919: URL: https://github.com/apache/camel-quarkus/pull/3919#discussion_r947635754
########## integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubTest.java: ########## @@ -56,6 +74,220 @@ public void jacksonSerializer() { RestAssured.get("/google-pubsub/pojo") .then() .statusCode(200) - .body("name", is(fruitName)); + .body("name", Matchers.is(fruitName)); + + } + + @Test + @Order(3) + public void testGrouped() throws Exception { + RestAssured.given() + .queryParam("toEndpoint", GooglePubSubRoutes.GROUP_DIRECT_AGGREGATOR) + .body("body1") + .post("/google-pubsub/sendToEndpoint") + .then() + .statusCode(201); + + RestAssured.given() + .get("/google-pubsub/receive/subscription/google-pubsub.grouped-subscription-name") + .then() + .statusCode(204); + + RestAssured.given() + .queryParam("toEndpoint", GooglePubSubRoutes.GROUP_DIRECT_AGGREGATOR) + .body("body2") + .post("/google-pubsub/sendToEndpoint") + .then() + .statusCode(201); + + Set<String> results = new HashSet<>(); + results.add(RestAssured.given() + .get("/google-pubsub/receive/subscription/google-pubsub.grouped-subscription-name") + .then() + .statusCode(200).extract().asString()); + + results.add(RestAssured.given() + .get("/google-pubsub/receive/subscription/google-pubsub.grouped-subscription-name") + .then() + .statusCode(200).extract().asString()); + + Assertions.assertTrue(results.contains("body1")); + Assertions.assertTrue(results.contains("body2")); + + } + + //Disabled on real account because of https://issues.apache.org/jira/browse/CAMEL-18277 + @DisabledIfEnvironmentVariable(named = "GOOGLE_APPLICATION_CREDENTIALS", matches = ".+") + // https://github.com/apache/camel-quarkus/issues/3944 + @DisabledIfEnvironmentVariable(named = "CI", matches = "true") + @Test + @Order(4) + public void testOrdering() throws Exception { + LOG.info("Start of the ordering test"); + RestAssured.given() + .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN) + .body("1") + .post("/google-pubsub/sendToEndpoint") + .then() + .statusCode(201); + RestAssured.given() + .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN) + .body("2") + .post("/google-pubsub/sendToEndpoint") + .then() + .statusCode(201); + RestAssured.given() + .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN) + .body("3") + .post("/google-pubsub/sendToEndpoint") + .then() + .statusCode(201); + RestAssured.given() + .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN) + .body("4") + .post("/google-pubsub/sendToEndpoint") + .then() + .statusCode(201); + RestAssured.given() + .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN) + .body("5") + .post("/google-pubsub/sendToEndpoint") + .then() + .statusCode(201); + RestAssured.given() + .queryParam("toEndpoint", GooglePubSubRoutes.ORDERING_DIRECT_IN) + .body("6") + .post("/google-pubsub/sendToEndpoint") + .then() + .statusCode(201); + LOG.info("All messages were sent"); + + await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given() + .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name") + .then() + .statusCode(200) + .extract().asString(), + Matchers.is("1")); + LOG.info("Message \"1\" received."); + await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given() + .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name") + .then() + .statusCode(200) + .extract().asString(), + Matchers.is("2")); + LOG.info("Message \"2\" received."); + await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given() + .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name") + .then() + .statusCode(200) + .extract().asString(), + Matchers.is("3")); + LOG.info("Message \"3\" received."); + await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given() + .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name") + .then() + .statusCode(200) + .extract().asString(), + Matchers.is("4")); + LOG.info("Message \"4\" received."); + await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given() + .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name") + .then() + .statusCode(200) + .extract().asString(), + Matchers.is("5")); + LOG.info("Message \"5\" received."); + await().atMost(5, TimeUnit.SECONDS).until(() -> RestAssured.given() + .get("/google-pubsub/receive/subscriptionOrdering/google-pubsub.ordering-subscription-name") + .then() + .statusCode(200) + .extract().asString(), + Matchers.is("6")); + LOG.info("Message \"6\" received."); + + } + + @Test + @Order(5) + public void testAck() throws Exception { + LOG.info("Start of the acking test"); + //enable ack + RestAssured.given() + .body(false) + .post("/google-pubsub/setFail") + .then() + .statusCode(201); + //successful run + RestAssured.given() + .queryParam("toEndpoint", GooglePubSubRoutes.ACK_DIRECT_IN) + .body("1") + .post("/google-pubsub/sendToEndpoint") + .then() + .statusCode(201); + LOG.info("Message \"1\" was sent and should be Acked."); + + await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> RestAssured.given() + .get("/google-pubsub/receive/mock/" + GooglePubSubRoutes.ACK_MOCK_RESULT) + .then() + .statusCode(200) + .body(Matchers.is("1"))); + LOG.info("Message \"1\" was received."); + //once message is received, reset mock + RestAssured.given() + .get("/google-pubsub/resetMock/" + GooglePubSubRoutes.ACK_MOCK_RESULT) + .then() + .statusCode(201); + //failing run + //disable ack + RestAssured.given() + .body(true) + .post("/google-pubsub/setFail") + .then() + .statusCode(201); + + RestAssured.given() + .queryParam("toEndpoint", GooglePubSubRoutes.ACK_DIRECT_IN) + .body("2") + .post("/google-pubsub/sendToEndpoint") + .then() + .statusCode(201); + LOG.info("Message \"2\" was sent and should be Nacked."); + //wait to be sure that the nacked message was not delivered + Thread.sleep(1000); + + RestAssured.given() + .get("/google-pubsub/receive/mock/" + GooglePubSubRoutes.ACK_MOCK_RESULT) + .then() + .statusCode(200) + .body(Matchers.is("")); + LOG.info("Message \"2\" was not delivered."); + + //enable ack + RestAssured.given() + .body(false) + .post("/google-pubsub/setFail") + .then() + .statusCode(201); + LOG.info("Acking was enabled."); + + //assert redelivered message + await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> RestAssured.given() + .get("/google-pubsub/receive/mock/" + GooglePubSubRoutes.ACK_MOCK_RESULT) + .then() + .statusCode(200) + .body(Matchers.is("2"))); + + LOG.info("Message \"2\" was delivered after acking was enabled."); + } + + @Test + @Order(6) + public void stopConsumerTest() throws Exception { + RestAssured.given() Review Comment: I commented the code of the test method and pointed to the issue https://github.com/apache/camel-quarkus/issues/3957 -- 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-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org