You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2021/08/03 15:46:05 UTC

[cxf] branch master updated: CXF-8573: Fix org.apache.cxf.systest.jaxrs.spring.boot.SpringJaxrsTest.testJaxrsSuccessMetric

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

reta pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 6e645cb  CXF-8573: Fix org.apache.cxf.systest.jaxrs.spring.boot.SpringJaxrsTest.testJaxrsSuccessMetric
6e645cb is described below

commit 6e645cb9a671c43bf61c2dd26b1363a96e94885d
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Tue Aug 3 11:45:45 2021 -0400

    CXF-8573: Fix org.apache.cxf.systest.jaxrs.spring.boot.SpringJaxrsTest.testJaxrsSuccessMetric
---
 systests/spring-boot/pom.xml                       |  6 +++-
 .../spring/boot/SpringJaxrsApplicationTest.java    | 35 +++++++++++++++++++++-
 .../systest/jaxrs/spring/boot/SpringJaxrsTest.java | 29 ++++++++++++++++++
 .../systest/jaxws/spring/boot/SpringJaxwsTest.java | 21 +++++++++++++
 4 files changed, 89 insertions(+), 2 deletions(-)

diff --git a/systests/spring-boot/pom.xml b/systests/spring-boot/pom.xml
index 1df0b4e..2e47eba 100644
--- a/systests/spring-boot/pom.xml
+++ b/systests/spring-boot/pom.xml
@@ -91,7 +91,6 @@
             <artifactId>cxf-testutils</artifactId>
             <scope>test</scope>
         </dependency>
-
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
@@ -109,5 +108,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 f5efe25..12a614d 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;
 
@@ -52,6 +53,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.jupiter.api.AfterEach;
@@ -62,6 +64,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;
 
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsApplicationTest.TestConfig.class)
@@ -108,7 +113,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()
@@ -146,6 +155,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()
@@ -183,6 +196,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()
@@ -220,6 +237,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()
@@ -289,6 +310,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()
@@ -326,6 +351,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()
@@ -363,6 +392,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 fd72e47..28ea815 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;
 
@@ -52,6 +53,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.jupiter.api.AfterEach;
@@ -62,6 +64,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;
 
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsTest.TestConfig.class)
@@ -110,6 +115,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()
@@ -147,6 +156,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()
@@ -184,6 +197,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()
@@ -253,6 +270,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()
@@ -290,6 +311,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()
@@ -327,6 +352,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 25baf74..623bb5e 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;
 
@@ -57,6 +58,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.jupiter.api.AfterEach;
@@ -69,6 +71,9 @@ 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.not;
+import static org.hamcrest.Matchers.empty;
 
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(
@@ -150,6 +155,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()
@@ -195,6 +204,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()
@@ -259,6 +272,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()
@@ -299,6 +316,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()