Search in sources :

Example 1 with HelloService

use of org.apache.cxf.systest.jaxws.resources.HelloService in project cxf by apache.

the class SpringJaxwsTest method testJaxwsProxyFailedMetric.

@Test
public void testJaxwsProxyFailedMetric() {
    final HelloService api = createApi(port, HELLO_SERVICE_NAME_V1);
    // then
    assertThatThrownBy(() -> api.sayHello(null)).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().collect(toMap(Tag::getKey, Tag::getValue));
    assertThat(serverTags).containsOnly(entry("exception", "NullPointerException"), entry("faultCode", "UNCHECKED_APPLICATION_FAULT"), entry("method", "POST"), entry("operation", "sayHello"), entry("uri", "/Service/" + HELLO_SERVICE_NAME_V1), entry("outcome", "SERVER_ERROR"), entry("status", "500"));
    RequiredSearch clientRequestMetrics = registry.get("cxf.client.requests");
    Map<Object, Object> clientTags = clientRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
    assertThat(clientTags).containsOnly(entry("exception", "None"), entry("faultCode", "UNCHECKED_APPLICATION_FAULT"), entry("method", "POST"), entry("operation", "sayHello"), entry("uri", "http://localhost:" + port + "/Service/" + HELLO_SERVICE_NAME_V1), entry("outcome", "SERVER_ERROR"), entry("status", "500"));
}
Also used : MeterNotFoundException(io.micrometer.core.instrument.search.MeterNotFoundException) HelloService(org.apache.cxf.systest.jaxws.resources.HelloService) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) RequiredSearch(io.micrometer.core.instrument.search.RequiredSearch) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with HelloService

use of org.apache.cxf.systest.jaxws.resources.HelloService in project cxf by apache.

the class SpringJaxwsTest method testJaxwsProxySuccessMetric.

@Test
public void testJaxwsProxySuccessMetric() throws MalformedURLException {
    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().collect(toMap(Tag::getKey, Tag::getValue));
    assertThat(serverTags).containsOnly(entry("exception", "None"), entry("faultCode", "None"), entry("method", "POST"), entry("operation", "sayHello"), entry("uri", "/Service/" + HELLO_SERVICE_NAME_V1), entry("outcome", "SUCCESS"), entry("status", "200"));
    RequiredSearch clientRequestMetrics = registry.get("cxf.client.requests");
    Map<Object, Object> clientTags = clientRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
    assertThat(clientTags).containsOnly(entry("exception", "None"), entry("faultCode", "None"), entry("method", "POST"), entry("operation", "sayHello"), entry("uri", "http://localhost:" + port + "/Service/" + HELLO_SERVICE_NAME_V1), entry("outcome", "SUCCESS"), entry("status", "200"));
}
Also used : MeterNotFoundException(io.micrometer.core.instrument.search.MeterNotFoundException) HelloService(org.apache.cxf.systest.jaxws.resources.HelloService) RequiredSearch(io.micrometer.core.instrument.search.RequiredSearch) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with HelloService

use of org.apache.cxf.systest.jaxws.resources.HelloService in project cxf by apache.

the class SpringJaxwsTest method sendSoapRequest.

private String sendSoapRequest(String requestBody, final String serviceName) throws MalformedURLException {
    String address = "http://localhost:" + port + "/Service/" + serviceName;
    StreamSource source = new StreamSource(new StringReader(requestBody));
    Service service = Service.create(new URL(address + "?wsdl"), new QName("http://service.ws.sample/", "HelloService"), new MetricsFeature(metricsProvider));
    Dispatch<Source> dispatch = service.createDispatch(new QName("http://service.ws.sample/", "HelloPort"), Source.class, Mode.PAYLOAD);
    Source result = dispatch.invoke(source);
    return StaxUtils.toString(result);
}
Also used : MetricsFeature(org.apache.cxf.metrics.MetricsFeature) QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader) Service(javax.xml.ws.Service) HelloService(org.apache.cxf.systest.jaxws.resources.HelloService) URL(java.net.URL) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source)

Example 4 with HelloService

use of org.apache.cxf.systest.jaxws.resources.HelloService in project cxf by apache.

the class SpringJaxwsTest method testJaxwsProxyClientExceptionMetric.

@Test
public void testJaxwsProxyClientExceptionMetric() throws MalformedURLException {
    final int fakePort = SocketUtils.findAvailableTcpPort();
    final HelloService api = createApi(fakePort, HELLO_SERVICE_NAME_V1);
    assertThatThrownBy(() -> api.sayHello("Elan")).isInstanceOf(WebServiceException.class).hasMessageContaining("Could not send Message");
    // no server meters
    assertThat(registry.getMeters()).noneMatch(m -> "cxf.server.requests".equals(m.getId().getName()));
    RequiredSearch clientRequestMetrics = registry.get("cxf.client.requests");
    Map<Object, Object> clientTags = clientRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
    assertThat(clientTags).containsOnly(entry("exception", "None"), entry("faultCode", "RUNTIME_FAULT"), entry("method", "POST"), entry("operation", "sayHello"), entry("uri", "http://localhost:" + fakePort + "/Service/" + HELLO_SERVICE_NAME_V1), entry("outcome", "UNKNOWN"), entry("status", "UNKNOWN"));
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) HelloService(org.apache.cxf.systest.jaxws.resources.HelloService) Endpoint(javax.xml.ws.Endpoint) RequiredSearch(io.micrometer.core.instrument.search.RequiredSearch) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

HelloService (org.apache.cxf.systest.jaxws.resources.HelloService)4 RequiredSearch (io.micrometer.core.instrument.search.RequiredSearch)3 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 MeterNotFoundException (io.micrometer.core.instrument.search.MeterNotFoundException)2 StringReader (java.io.StringReader)1 URL (java.net.URL)1 QName (javax.xml.namespace.QName)1 Source (javax.xml.transform.Source)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Endpoint (javax.xml.ws.Endpoint)1 Service (javax.xml.ws.Service)1 WebServiceException (javax.xml.ws.WebServiceException)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 MetricsFeature (org.apache.cxf.metrics.MetricsFeature)1