This is an automated email from the ASF dual-hosted git repository. zbendhiba pushed a commit to branch 3.2.x in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 37712bdc954392f5fa7f6f5dfc44c487934eb59d Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Wed Sep 13 12:53:14 2023 +0200 Test Prometheus metrics with CXF SOAP client and service --- .../cxf-soap/cxf-soap-metrics/pom.xml | 139 +++++++++++++++++++++ .../cxf/soap/it/metrics/CxfSoapMetricsRoutes.java | 80 ++++++++++++ .../cxf/soap/it/metrics/MetricsClientResource.java | 41 ++++++ .../cxf/soap/it/metrics/service/HelloService.java | 32 +++++ .../src/main/resources/application.properties | 21 ++++ .../main/resources/wsdl/MetricsHelloService.wsdl | 75 +++++++++++ .../component/cxf/soap/it/metrics/MetricsIT.java | 24 ++++ .../component/cxf/soap/it/metrics/MetricsTest.java | 125 ++++++++++++++++++ integration-test-groups/cxf-soap/pom.xml | 1 + integration-tests/cxf-soap-grouped/pom.xml | 8 ++ 10 files changed, 546 insertions(+) diff --git a/integration-test-groups/cxf-soap/cxf-soap-metrics/pom.xml b/integration-test-groups/cxf-soap/cxf-soap-metrics/pom.xml new file mode 100644 index 0000000000..ce1258b3d9 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-metrics/pom.xml @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent-it</artifactId> + <version>3.2.1-SNAPSHOT</version> + <relativePath>../../../poms/build-parent-it/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-cxf-soap-metrics</artifactId> + + <name>Quarkus CXF - Integration Test - Metrics</name> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-cxf-soap</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> + <dependency> + <groupId>io.quarkiverse.cxf</groupId> + <artifactId>quarkus-cxf-rt-features-metrics</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-micrometer-registry-prometheus</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.package.type>native</quarkus.package.type> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>virtualDependencies</id> + <activation> + <property> + <name>!noVirtualDependencies</name> + </property> + </activation> + <dependencies> + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-cxf-soap-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + </profile> + </profiles> + +</project> diff --git a/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/CxfSoapMetricsRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/CxfSoapMetricsRoutes.java new file mode 100644 index 0000000000..3248172ac5 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/CxfSoapMetricsRoutes.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.cxf.soap.it.metrics; + +import io.quarkiverse.cxf.metrics.QuarkusCxfMetricsFeature; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.SessionScoped; +import jakarta.enterprise.inject.Produces; +import jakarta.inject.Named; +import org.apache.camel.Message; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.cxf.jaxws.CxfEndpoint; +import org.apache.camel.quarkus.component.cxf.soap.it.metrics.service.HelloService; +import org.eclipse.microprofile.config.inject.ConfigProperty; + +@ApplicationScoped +public class CxfSoapMetricsRoutes extends RouteBuilder { + + @ConfigProperty(name = "quarkus.http.test-port") + String port; + + @Override + public void configure() { + + from("direct:clientMetrics") + .to("cxf:bean:clientMetricsEndpoint?dataFormat=POJO"); + + from("cxf:bean:metricsServiceEndpoint") + .process(e -> { + try { + /* We have to slow down a bit so that the native test is able to see some elapsedTime */ + Thread.sleep(20); + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } + Message message = e.getMessage(); + message.setBody("Hello " + message.getBody(String.class) + "!", String.class); + }); + + } + + @Produces + @SessionScoped + @Named + CxfEndpoint clientMetricsEndpoint() { + final CxfEndpoint result = new CxfEndpoint(); + result.setServiceClass(HelloService.class); + result.setAddress("http://localhost:" + port + "/soapservice/hello-metrics"); + result.setWsdlURL("wsdl/MetricsHelloService.wsdl"); + result.getFeatures().add(new QuarkusCxfMetricsFeature()); + return result; + } + + @Produces + @ApplicationScoped + @Named + CxfEndpoint metricsServiceEndpoint() { + final CxfEndpoint result = new CxfEndpoint(); + result.setServiceClass(HelloService.class); + result.setAddress("/hello-metrics"); + result.setWsdlURL("wsdl/MetricsHelloService.wsdl"); + result.getFeatures().add(new QuarkusCxfMetricsFeature()); + return result; + } + +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/MetricsClientResource.java b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/MetricsClientResource.java new file mode 100644 index 0000000000..f7845c8269 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/MetricsClientResource.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.cxf.soap.it.metrics; + +import java.io.IOException; + +import jakarta.inject.Inject; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import org.apache.camel.ProducerTemplate; + +@Path("/cxf-soap/metrics/client") +public class MetricsClientResource { + + @Inject + ProducerTemplate producerTemplate; + + @POST + @Path("/hello") + @Produces(MediaType.TEXT_PLAIN) + public String hello(String body) throws IOException { + return producerTemplate.requestBody("direct:clientMetrics", body, String.class); + } + +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/service/HelloService.java b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/service/HelloService.java new file mode 100644 index 0000000000..a7826139c9 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/service/HelloService.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.cxf.soap.it.metrics.service; + +import jakarta.jws.WebMethod; +import jakarta.jws.WebParam; +import jakarta.jws.WebService; + +/** + * The simplest Hello service. + */ +@WebService(name = "HelloService", serviceName = "HelloService") +public interface HelloService { + + @WebMethod + String hello(@WebParam(name = "text") String text); + +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/resources/application.properties b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/resources/application.properties new file mode 100644 index 0000000000..29ce2938e3 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/resources/application.properties @@ -0,0 +1,21 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +quarkus.cxf.path = /soapservice + +quarkus.micrometer.export.json.enabled = true +quarkus.micrometer.export.json.path = metrics/json +quarkus.micrometer.export.prometheus.path = metrics/prometheus diff --git a/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/resources/wsdl/MetricsHelloService.wsdl b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/resources/wsdl/MetricsHelloService.wsdl new file mode 100644 index 0000000000..c8c557cb61 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/resources/wsdl/MetricsHelloService.wsdl @@ -0,0 +1,75 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://service.metrics.it.soap.cxf.component.quarkus.camel.apache.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="HelloService" targetNamespace="http://service.metrics.it.soap.cxf.component.quarkus.camel.apache.org/"> + <wsdl:types> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://service.metrics.it.soap.cxf.component.quarkus.camel.apache.org/" elementFormDefault="unqualified" targetNamespace="http://service.metrics.it.soap.cxf.component.quarkus.camel.apache.org/" version="1.0"> + + <xs:element name="hello" type="tns:hello"/> + + <xs:element name="helloResponse" type="tns:helloResponse"/> + + <xs:complexType name="hello"> + <xs:sequence> + <xs:element minOccurs="0" name="text" type="xs:string"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="helloResponse"> + <xs:sequence> + <xs:element minOccurs="0" name="return" type="xs:string"/> + </xs:sequence> + </xs:complexType> + +</xs:schema> + </wsdl:types> + <wsdl:message name="hello"> + <wsdl:part element="tns:hello" name="parameters"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="helloResponse"> + <wsdl:part element="tns:helloResponse" name="parameters"> + </wsdl:part> + </wsdl:message> + <wsdl:portType name="HelloService"> + <wsdl:operation name="hello"> + <wsdl:input message="tns:hello" name="hello"> + </wsdl:input> + <wsdl:output message="tns:helloResponse" name="helloResponse"> + </wsdl:output> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="HelloServiceSoapBinding" type="tns:HelloService"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="hello"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="hello"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="helloResponse"> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="HelloService"> + <wsdl:port binding="tns:HelloServiceSoapBinding" name="HelloServicePort"> + <soap:address location="http://localhost:8080/soap/hello"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> \ No newline at end of file diff --git a/integration-test-groups/cxf-soap/cxf-soap-metrics/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/MetricsIT.java b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/MetricsIT.java new file mode 100644 index 0000000000..51af96183c --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/MetricsIT.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.cxf.soap.it.metrics; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +public class MetricsIT extends MetricsTest { + +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-metrics/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/MetricsTest.java b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/MetricsTest.java new file mode 100644 index 0000000000..54a6a79588 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/MetricsTest.java @@ -0,0 +1,125 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.cxf.soap.it.metrics; + +import java.util.Map; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.path.json.JsonPath; +import org.assertj.core.api.Assertions; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.hamcrest.CoreMatchers; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; + +@QuarkusTest +public class MetricsTest { + + @Test + void serverAndClient() { + { + final Map<String, Object> metrics = getMetrics(); + /* There should be no cxf metrics available before we call anything */ + Assertions.assertThat(metrics.get("cxf.server.requests")).isNull(); + Assertions.assertThat(metrics.get("cxf.client.requests")).isNull(); + } + + /* First send a direct request to the service circumventing the in-app client */ + final String SOAP_REQUEST = "<x:Envelope xmlns:x=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cxf=\"http://service.metrics.it.soap.cxf.component.quarkus.camel.apache.org/\">\n" + + + " <x:Header/>\n" + + " <x:Body>\n" + + " <cxf:hello>\n" + + " <text>foo</text>\n" + + " </cxf:hello>\n" + + " </x:Body>\n" + + "</x:Envelope>"; + given() + .header("Content-Type", "text/xml") + .body(SOAP_REQUEST) + .when() + .post("/soapservice/hello-metrics") + .then() + .statusCode(200) + .body(CoreMatchers.containsString("Hello foo")); + + { + final Map<String, Object> metrics = getMetrics(); + @SuppressWarnings("unchecked") + Map<String, Object> serverRequests = (Map<String, Object>) metrics.get("cxf.server.requests"); + Assertions.assertThat(serverRequests).isNotNull(); + Assertions.assertThat(serverRequests.get( + "count;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=/soapservice/hello-metrics")) + .isEqualTo(1); + Assertions.assertThat((Float) serverRequests.get( + "elapsedTime;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=/soapservice/hello-metrics")) + .isGreaterThan(0.0F); + } + + final Config config = ConfigProvider.getConfig(); + final int port = config.getValue("quarkus.http.test-port", Integer.class); + + /* Now send a request using the in-app client */ + given() + .body("Joe") + .when() + .post("/cxf-soap/metrics/client/hello") + .then() + .statusCode(200) + .body(CoreMatchers.containsString("Hello Joe")); + { + final Map<String, Object> metrics = getMetrics(); + @SuppressWarnings("unchecked") + Map<String, Object> serverRequests = (Map<String, Object>) metrics.get("cxf.server.requests"); + Assertions.assertThat(serverRequests).isNotNull(); + Assertions.assertThat(serverRequests.get( + "count;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=/soapservice/hello-metrics")) + .isEqualTo(2); + Assertions.assertThat((Float) serverRequests.get( + "elapsedTime;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=/soapservice/hello-metrics")) + .isGreaterThan(0.0F); + + Map<String, Object> clientRequests = (Map<String, Object>) metrics.get("cxf.client.requests"); + Assertions.assertThat(clientRequests).isNotNull(); + Assertions.assertThat(clientRequests.get( + "count;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=http://localhost:" + + port + "/soapservice/hello-metrics")) + .isEqualTo(1); + Assertions.assertThat((Float) clientRequests.get( + "elapsedTime;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=http://localhost:" + + port + "/soapservice/hello-metrics")) + .isGreaterThan(0.0F); + + } + + } + + private Map<String, Object> getMetrics() { + final String body = RestAssured.given() + .header("Content-Type", "application/json") + .get("/q/metrics/json") + .then() + .statusCode(200) + .extract().body().asString(); + final JsonPath jp = new JsonPath(body); + return jp.getJsonObject("$"); + } + +} diff --git a/integration-test-groups/cxf-soap/pom.xml b/integration-test-groups/cxf-soap/pom.xml index accdcdc897..d0572d2fb7 100644 --- a/integration-test-groups/cxf-soap/pom.xml +++ b/integration-test-groups/cxf-soap/pom.xml @@ -39,6 +39,7 @@ <!-- extensions a..z; do not remove this comment, it is important when sorting via mvn process-resources -Pformat --> <module>cxf-soap-client</module> <module>cxf-soap-converter</module> + <module>cxf-soap-metrics</module> <module>cxf-soap-mtom</module> <module>cxf-soap-mtom-awt</module> <module>cxf-soap-rest</module> diff --git a/integration-tests/cxf-soap-grouped/pom.xml b/integration-tests/cxf-soap-grouped/pom.xml index 1c9f13107d..b39cd06fd4 100644 --- a/integration-tests/cxf-soap-grouped/pom.xml +++ b/integration-tests/cxf-soap-grouped/pom.xml @@ -60,6 +60,14 @@ <groupId>io.quarkiverse.cxf</groupId> <artifactId>quarkus-cxf-xjc-plugins</artifactId> </dependency> + <dependency> + <groupId>io.quarkiverse.cxf</groupId> + <artifactId>quarkus-cxf-rt-features-metrics</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-micrometer-registry-prometheus</artifactId> + </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId>