diff --git a/solace-spring-cloud-stream-binder/solace-spring-cloud-stream-binder/src/test/java/com/solace/spring/cloud/stream/binder/springBootTests/multibinder/MultiBinderIT.java b/solace-spring-cloud-stream-binder/solace-spring-cloud-stream-binder/src/test/java/com/solace/spring/cloud/stream/binder/springBootTests/multibinder/MultiBinderIT.java index 0ace5e65..4e04c141 100644 --- a/solace-spring-cloud-stream-binder/solace-spring-cloud-stream-binder/src/test/java/com/solace/spring/cloud/stream/binder/springBootTests/multibinder/MultiBinderIT.java +++ b/solace-spring-cloud-stream-binder/solace-spring-cloud-stream-binder/src/test/java/com/solace/spring/cloud/stream/binder/springBootTests/multibinder/MultiBinderIT.java @@ -1,5 +1,9 @@ package com.solace.spring.cloud.stream.binder.springBootTests.multibinder; +import static org.awaitility.Awaitility.await; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.solace.test.integration.testcontainer.PubSubPlusContainer; import com.solacesystems.jcsmp.JCSMPException; import com.solacesystems.jcsmp.JCSMPFactory; @@ -19,10 +23,6 @@ import org.springframework.test.context.DynamicPropertySource; import org.springframework.test.web.servlet.MockMvc; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - /** * Note: not using the PubSubPlusExtension as it appears to trigger after Spring Boot Application is started. @@ -91,11 +91,14 @@ public void checkSolaceMetricsAreExposed(@Autowired MockMvc mvc) throws Exceptio producer.send(JCSMPFactory.onlyInstance().createBytesXMLMessage(), JCSMPFactory.onlyInstance().createQueue(QUEUE_NAME_PREFIX + QUEUE_NAME_1)); - mvc.perform(get("/actuator/metrics")) - .andExpectAll( + await().until(() -> { + mvc.perform(get("/actuator/metrics")) + .andExpectAll( jsonPath("names", Matchers.hasItem("solace.message.size.payload")), - jsonPath("names", Matchers.hasItem("solace.message.size.total")) - ); + jsonPath("names", Matchers.hasItem("solace.message.size.total"))); + return true; + } + ); } }