This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new e5b1d0b21d Poll for consumer results in 
GooglePubsubTest.pubsubTopicProduceConsume
e5b1d0b21d is described below

commit e5b1d0b21d62cdcdf4f71acc0ac898fba9c17ea5
Author: James Netherton <[email protected]>
AuthorDate: Tue May 5 07:12:42 2026 +0100

    Poll for consumer results in GooglePubsubTest.pubsubTopicProduceConsume
---
 .../google/pubsub/it/GooglePubsubResource.java     | 28 ++++++++++++----------
 .../google/pubsub/it/GooglePubsubTest.java         | 18 ++++++++------
 2 files changed, 27 insertions(+), 19 deletions(-)

diff --git 
a/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubResource.java
 
b/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubResource.java
index 86367bac71..d5bf78f466 100644
--- 
a/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubResource.java
+++ 
b/integration-tests/google-pubsub/src/main/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubResource.java
@@ -67,18 +67,22 @@ public class GooglePubsubResource {
     public Response consumeStringFromTopic() {
         Exchange exchange = consumerTemplate
                 
.receive("google-pubsub:{{project.id}}:{{google-pubsub.subscription-name}}?synchronousPull=true",
 5000L);
-        //convert timestamp to long to avoid serializiong problems
-        Map<String, Object> retVal = new HashMap<>();
-        retVal.put("body", exchange.getIn().getBody(String.class));
-        
retVal.putAll(exchange.getIn().getHeaders().entrySet().stream().collect(Collectors.toMap(
-                e -> e.getKey().replaceFirst("\\.", "_"),
-                e -> {
-                    if (GooglePubsubConstants.PUBLISH_TIME.equals(e.getKey()) 
&& e.getValue() instanceof Timestamp) {
-                        return ((Timestamp) e.getValue()).getSeconds() * 1000;
-                    }
-                    return e.getValue();
-                })));
-        return Response.ok(retVal).build();
+
+        if (exchange != null) {
+            //convert timestamp to long to avoid serialization problems
+            Map<String, Object> retVal = new HashMap<>();
+            retVal.put("body", exchange.getMessage().getBody(String.class));
+            
retVal.putAll(exchange.getMessage().getHeaders().entrySet().stream().collect(Collectors.toMap(
+                    e -> e.getKey().replaceFirst("\\.", "_"),
+                    e -> {
+                        if 
(GooglePubsubConstants.PUBLISH_TIME.equals(e.getKey()) && e.getValue() 
instanceof Timestamp) {
+                            return ((Timestamp) e.getValue()).getSeconds() * 
1000;
+                        }
+                        return e.getValue();
+                    })));
+            return Response.ok(retVal).build();
+        }
+        return Response.noContent().build();
     }
 
     @Path("/pojo")
diff --git 
a/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubTest.java
 
b/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubTest.java
index 3ad2948224..4045a36bd8 100644
--- 
a/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubTest.java
+++ 
b/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubsubTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.quarkus.component.google.pubsub.it;
 
+import java.time.Duration;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
@@ -25,6 +26,7 @@ import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import org.apache.camel.component.google.pubsub.GooglePubsubConstants;
 import org.apache.camel.quarkus.test.support.google.GoogleCloudTestResource;
+import org.awaitility.Awaitility;
 import org.hamcrest.Matchers;
 import org.jboss.logging.Logger;
 import org.junit.jupiter.api.Assertions;
@@ -48,13 +50,15 @@ class GooglePubsubTest {
                 .then()
                 .statusCode(201);
 
-        RestAssured.get("/google-pubsub")
-                .then()
-                .statusCode(200)
-                .body("body", Matchers.is(message))
-                .body(GooglePubsubConstants.MESSAGE_ID.replaceFirst("\\.", 
"_"), Matchers.notNullValue())
-                .body(GooglePubsubConstants.PUBLISH_TIME.replaceFirst("\\.", 
"_"), Matchers.notNullValue())
-                .body(GooglePubsubConstants.ACK_ID.replaceFirst("\\.", "_"), 
Matchers.notNullValue());
+        
Awaitility.await().pollDelay(Duration.ofMillis(250)).atMost(Duration.ofSeconds(30)).untilAsserted(()
 -> {
+            RestAssured.get("/google-pubsub")
+                    .then()
+                    .statusCode(200)
+                    .body("body", Matchers.is(message))
+                    .body(GooglePubsubConstants.MESSAGE_ID.replaceFirst("\\.", 
"_"), Matchers.notNullValue())
+                    
.body(GooglePubsubConstants.PUBLISH_TIME.replaceFirst("\\.", "_"), 
Matchers.notNullValue())
+                    .body(GooglePubsubConstants.ACK_ID.replaceFirst("\\.", 
"_"), Matchers.notNullValue());
+        });
     }
 
     @Test

Reply via email to