This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.3.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit cadd22211744d49c221cbd6f8e86624d59b52f89 Author: Andriy Redko <[email protected]> AuthorDate: Tue Aug 3 11:45:45 2021 -0400 CXF-8573: Fix org.apache.cxf.systest.jaxrs.spring.boot.SpringJaxrsTest.testJaxrsSuccessMetric (cherry picked from commit 6e645cb9a671c43bf61c2dd26b1363a96e94885d) # Conflicts: # systests/spring-boot/pom.xml (cherry picked from commit 0e154cc43e72809153d0d63d6ba9fa426c36d606) # Conflicts: # systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java --- systests/spring-boot/pom.xml | 5 ++++ .../spring/boot/SpringJaxrsApplicationTest.java | 35 +++++++++++++++++++++- .../systest/jaxrs/spring/boot/SpringJaxrsTest.java | 29 ++++++++++++++++++ .../systest/jaxws/spring/boot/SpringJaxwsTest.java | 20 +++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) diff --git a/systests/spring-boot/pom.xml b/systests/spring-boot/pom.xml index 6e90112..45a7e76 100644 --- a/systests/spring-boot/pom.xml +++ b/systests/spring-boot/pom.xml @@ -156,5 +156,10 @@ <artifactId>spring-boot-starter-actuator</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java index 55d4ebc..f66c86a 100644 --- a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java +++ b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java @@ -19,6 +19,7 @@ package org.apache.cxf.systest.jaxrs.spring.boot; +import java.time.Duration; import java.util.Arrays; import java.util.Map; @@ -54,6 +55,7 @@ import org.springframework.util.SocketUtils; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Tag; +import io.micrometer.core.instrument.search.MeterNotFoundException; import io.micrometer.core.instrument.search.RequiredSearch; import org.junit.Before; @@ -65,6 +67,9 @@ import static java.util.stream.Collectors.toMap; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.entry; +import static org.awaitility.Awaitility.await; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.empty; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsApplicationTest.TestConfig.class) @@ -116,7 +121,11 @@ public class SpringJaxrsApplicationTest { try (Response r = target.request().get()) { assertThat(r.getStatus()).isEqualTo(200); } - + + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -154,6 +163,10 @@ public class SpringJaxrsApplicationTest { assertThat(r.getStatus()).isEqualTo(200); } + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -191,6 +204,10 @@ public class SpringJaxrsApplicationTest { .isInstanceOf(NotFoundException.class) .hasMessageContaining("Not Found"); + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -228,6 +245,10 @@ public class SpringJaxrsApplicationTest { .isInstanceOf(InternalServerErrorException.class) .hasMessageContaining("Internal Server Error"); + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -297,6 +318,10 @@ public class SpringJaxrsApplicationTest { assertThat(r.getStatus()).isEqualTo(200); } + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -334,6 +359,10 @@ public class SpringJaxrsApplicationTest { .isInstanceOf(InternalServerErrorException.class) .hasMessageContaining("Internal Server Error"); + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -371,6 +400,10 @@ public class SpringJaxrsApplicationTest { assertThat(r.getStatus()).isEqualTo(404); } + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() diff --git a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java index c810c91..5607a99 100644 --- a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java +++ b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java @@ -19,6 +19,7 @@ package org.apache.cxf.systest.jaxrs.spring.boot; +import java.time.Duration; import java.util.Arrays; import java.util.Map; @@ -54,6 +55,7 @@ import org.springframework.util.SocketUtils; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Tag; +import io.micrometer.core.instrument.search.MeterNotFoundException; import io.micrometer.core.instrument.search.RequiredSearch; import org.junit.Before; @@ -65,6 +67,9 @@ import static java.util.stream.Collectors.toMap; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.entry; +import static org.awaitility.Awaitility.await; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.empty; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsTest.TestConfig.class) @@ -118,6 +123,10 @@ public class SpringJaxrsTest { assertThat(r.getStatus()).isEqualTo(200); } + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -155,6 +164,10 @@ public class SpringJaxrsTest { .isInstanceOf(NotFoundException.class) .hasMessageContaining("Not Found"); + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -192,6 +205,10 @@ public class SpringJaxrsTest { .isInstanceOf(InternalServerErrorException.class) .hasMessageContaining("Internal Server Error"); + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -261,6 +278,10 @@ public class SpringJaxrsTest { assertThat(r.getStatus()).isEqualTo(200); } + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -298,6 +319,10 @@ public class SpringJaxrsTest { .isInstanceOf(InternalServerErrorException.class) .hasMessageContaining("Internal Server Error"); + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -335,6 +360,10 @@ public class SpringJaxrsTest { assertThat(r.getStatus()).isEqualTo(404); } + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() diff --git a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java index 21e030d..c39af1e 100644 --- a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java +++ b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java @@ -22,6 +22,7 @@ package org.apache.cxf.systest.jaxws.spring.boot; import java.io.StringReader; import java.net.MalformedURLException; import java.net.URL; +import java.time.Duration; import java.util.Arrays; import java.util.Map; @@ -58,6 +59,7 @@ import org.springframework.util.SocketUtils; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Tag; +import io.micrometer.core.instrument.search.MeterNotFoundException; import io.micrometer.core.instrument.search.RequiredSearch; import org.junit.Before; @@ -70,8 +72,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.catchThrowable; import static org.assertj.core.api.Assertions.entry; +import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.empty; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, @@ -154,6 +158,10 @@ public class SpringJaxwsTest { + "<return>Hello, Elan</return>" + "</ns2:sayHelloResponse>"); + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -199,6 +207,10 @@ public class SpringJaxwsTest { .hasMessageContaining("Fault occurred while processing"); + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -261,6 +273,10 @@ public class SpringJaxwsTest { final HelloService api = createApi(port, HELLO_SERVICE_NAME_V1); assertThat(api.sayHello("Elan")).isEqualTo("Hello, Elan"); + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream() @@ -301,6 +317,10 @@ public class SpringJaxwsTest { .isInstanceOf(SOAPFaultException.class) .hasMessageContaining("Fault occurred while processing"); + await() + .atMost(Duration.ofSeconds(1)) + .ignoreException(MeterNotFoundException.class) + .until(() -> registry.get("cxf.server.requests").timers(), not(empty())); RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests"); Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream()
