This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.6.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 8c0bf137f4f99a565c5034709a90ddf5515eec10 Author: Andriy Redko <[email protected]> AuthorDate: Wed Oct 11 19:45:41 2023 -0400 Add JAX-WS tests for @Oneway methods to tracing suites (cherry picked from commit 638c8896a1d4e8afbc611416e8b816c43033a016) # Conflicts: # systests/tracing/src/test/java/org/apache/cxf/systest/brave/jaxws/AbstractBraveTracingTest.java # systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/brave/BookStore.java # systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/BookStore.java # systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/BookStore.java --- .../cxf/systest/jaxws/tracing/BookStoreService.java | 1 + .../cxf/systest/jaxws/tracing/brave/BookStore.java | 6 ++++++ .../systest/jaxws/tracing/brave/BraveTracingTest.java | 17 +++++++++++++++++ .../systest/jaxws/tracing/opentelemetry/BookStore.java | 5 +++++ .../tracing/opentelemetry/OpenTelemetryTracingTest.java | 14 ++++++++++++++ .../systest/jaxws/tracing/opentracing/BookStore.java | 5 +++++ .../tracing/opentracing/OpenTracingTracingTest.java | 13 +++++++++++++ 7 files changed, 61 insertions(+) diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/BookStoreService.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/BookStoreService.java index c6a58cf373..0df92a8202 100644 --- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/BookStoreService.java +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/BookStoreService.java @@ -29,4 +29,5 @@ public interface BookStoreService { Collection< Book > getBooks(); int removeBooks(); void addBooks(); + void orderBooks(); } diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/brave/BookStore.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/brave/BookStore.java index 2a1d254574..deb2f52888 100644 --- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/brave/BookStore.java +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/brave/BookStore.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.UUID; import javax.annotation.Resource; +import javax.jws.Oneway; import javax.jws.WebMethod; import javax.jws.WebService; import javax.xml.ws.WebServiceContext; @@ -72,4 +73,9 @@ public class BookStore implements BookStoreService { final MessageContext ctx = context.getMessageContext(); ctx.put(MessageContext.HTTP_RESPONSE_CODE, 305); } + + @WebMethod @Oneway + public void orderBooks() { + } + } diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/brave/BraveTracingTest.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/brave/BraveTracingTest.java index d7c3d0b8d1..fc4a3a36dc 100644 --- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/brave/BraveTracingTest.java +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/brave/BraveTracingTest.java @@ -18,6 +18,7 @@ */ package org.apache.cxf.systest.jaxws.tracing.brave; +import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -55,6 +56,7 @@ import static org.apache.cxf.systest.brave.BraveTestSupport.PARENT_SPAN_ID_NAME; import static org.apache.cxf.systest.brave.BraveTestSupport.SAMPLED_NAME; import static org.apache.cxf.systest.brave.BraveTestSupport.SPAN_ID_NAME; import static org.apache.cxf.systest.brave.BraveTestSupport.TRACE_ID_NAME; +import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.nullValue; @@ -241,6 +243,21 @@ public class BraveTracingTest extends AbstractClientServerTestBase { } } + @Test + public void testThatNewInnerSpanIsCreatedOneway() throws Exception { + try (Tracing brave = createTracer()) { + final BookStoreService service = createJaxWsService(new BraveClientFeature(brave)); + service.orderBooks(); + + // Await till flush happens, usually every second + await().atMost(Duration.ofSeconds(1L)).until(() -> TestSpanReporter.getAllSpans().size() == 2); + + assertThat(TestSpanReporter.getAllSpans().get(0).name(), equalTo("post /bookstore")); + assertThat(TestSpanReporter.getAllSpans().get(1).name(), + equalTo("post http://localhost:" + PORT + "/bookstore")); + } + } + private BookStoreService createJaxWsService() { return createJaxWsService(Collections.emptyMap()); } diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/BookStore.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/BookStore.java index 829aa0f8f7..c7a1b05426 100644 --- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/BookStore.java +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/BookStore.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.UUID; import javax.annotation.Resource; +import javax.jws.Oneway; import javax.jws.WebMethod; import javax.jws.WebService; import javax.xml.ws.WebServiceContext; @@ -68,4 +69,8 @@ public class BookStore implements BookStoreService { final MessageContext ctx = context.getMessageContext(); ctx.put(MessageContext.HTTP_RESPONSE_CODE, 202); } + + @WebMethod @Oneway + public void orderBooks() { + } } diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/OpenTelemetryTracingTest.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/OpenTelemetryTracingTest.java index 5b5e43e071..653804a46e 100644 --- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/OpenTelemetryTracingTest.java +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/OpenTelemetryTracingTest.java @@ -256,6 +256,20 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase { hasAttribute(SemanticAttributes.HTTP_STATUS_CODE, 202L)); } + @Test + public void testThatNewInnerSpanIsCreatedOneway() throws Exception { + final BookStoreService service = createJaxWsService(new OpenTelemetryClientFeature(otelRule + .getOpenTelemetry(), "jaxws-client-test")); + service.orderBooks(); + + // Await till flush happens, usually every second + await().atMost(Duration.ofSeconds(1L)).until(() -> otelRule.getSpans().size() == 2); + + assertThat(otelRule.getSpans().get(0).getName(), equalTo("POST /BookStore")); + assertThat(otelRule.getSpans().get(1).getName(), + equalTo("POST http://localhost:" + PORT + "/BookStore")); + } + private BookStoreService createJaxWsService(final Feature feature) { return createJaxWsService(Collections.emptyMap(), feature); } diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/BookStore.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/BookStore.java index 5ffa70ed6e..874ed76685 100644 --- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/BookStore.java +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/BookStore.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.UUID; import javax.annotation.Resource; +import javax.jws.Oneway; import javax.jws.WebMethod; import javax.jws.WebService; import javax.xml.ws.WebServiceContext; @@ -65,6 +66,10 @@ public class BookStore implements BookStoreService { throw new RuntimeException("Unable to remove books"); } + @WebMethod @Oneway + public void orderBooks() { + } + @WebMethod public void addBooks() { final MessageContext ctx = context.getMessageContext(); diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/OpenTracingTracingTest.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/OpenTracingTracingTest.java index af8268924d..481c961628 100644 --- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/OpenTracingTracingTest.java +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/OpenTracingTracingTest.java @@ -229,6 +229,19 @@ public class OpenTracingTracingTest extends AbstractClientServerTestBase { assertThat(REPORTER.getSpans().get(0).getTags(), hasItem(Tags.HTTP_STATUS.getKey(), 202)); } + @Test + public void testThatNewInnerSpanIsCreatedOneway() throws Exception { + final BookStoreService service = createJaxWsService(new OpenTracingClientFeature(tracer)); + service.orderBooks(); + + // Await till flush happens, usually every second + await().atMost(Duration.ofSeconds(1L)).until(() -> REPORTER.getSpans().size() == 2); + + assertThat(REPORTER.getSpans().get(0).getOperationName(), equalTo("POST /BookStore")); + assertThat(REPORTER.getSpans().get(1).getOperationName(), + equalTo("POST http://localhost:" + PORT + "/BookStore")); + } + private static BookStoreService createJaxWsService() { return createJaxWsService(Collections.emptyMap()); }
