use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.
the class BraveTracingTest method createJaxWsService.
private BookStoreService createJaxWsService(final Map<String, List<String>> headers, final Configurator configurator) throws MalformedURLException {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.setServiceClass(BookStoreService.class);
factory.setAddress("http://localhost:" + PORT + "/BookStore");
if (configurator != null) {
configurator.configure(factory);
}
final BookStoreService service = (BookStoreService) factory.create();
final Client proxy = ClientProxy.getClient(service);
proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);
return service;
}
use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.
the class BraveTracingTest method testThatProvidedSpanIsNotClosedWhenActive.
@Test
public void testThatProvidedSpanIsNotClosedWhenActive() throws MalformedURLException {
final Tracing brave = Tracing.newBuilder().localServiceName("book-store").reporter(new TestSpanReporter()).build();
final BookStoreService service = createJaxWsService(new Configurator() {
@Override
public void configure(final JaxWsProxyFactoryBean factory) {
factory.getFeatures().add(new BraveClientFeature(brave));
}
});
final Span span = brave.tracer().nextSpan().name("test span").start();
try {
try (SpanInScope scope = brave.tracer().withSpanInScope(span)) {
assertThat(service.getBooks().size(), equalTo(2));
assertThat(brave.tracer().currentSpan(), not(nullValue()));
assertThat(TestSpanReporter.getAllSpans().size(), equalTo(3));
assertThat(TestSpanReporter.getAllSpans().get(0).name, equalTo("get books"));
assertThat(TestSpanReporter.getAllSpans().get(0).parentId, not(nullValue()));
assertThat(TestSpanReporter.getAllSpans().get(1).name, equalTo("post /bookstore"));
assertThat(TestSpanReporter.getAllSpans().get(2).name, equalTo("post http://localhost:" + PORT + "/bookstore"));
final Map<String, List<String>> response = getResponseHeaders(service);
assertThatTraceHeadersArePresent(response, true);
}
} finally {
if (span != null) {
span.finish();
}
}
assertThat(TestSpanReporter.getAllSpans().size(), equalTo(4));
assertThat(TestSpanReporter.getAllSpans().get(3).name, equalTo("test span"));
}
use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.
the class BraveTracingTest method testThatNewSpanIsCreatedInCaseOfFault.
@Test
public void testThatNewSpanIsCreatedInCaseOfFault() throws MalformedURLException {
final BookStoreService service = createJaxWsService();
try {
service.removeBooks();
fail("Expected SOAPFaultException to be raised");
} catch (final SOAPFaultException ex) {
/* expected exception */
}
assertThat(TestSpanReporter.getAllSpans().size(), equalTo(1));
assertThat(TestSpanReporter.getAllSpans().get(0).name, equalTo("post /bookstore"));
final Map<String, List<String>> headers = getResponseHeaders(service);
assertFalse(headers.containsKey(TRACE_ID_NAME));
assertFalse(headers.containsKey(SAMPLED_NAME));
assertFalse(headers.containsKey(PARENT_SPAN_ID_NAME));
assertFalse(headers.containsKey(SPAN_ID_NAME));
}
use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.
the class HTraceTracingTest method testThatNewSpanIsCreatedWhenNotProvided.
@Test
public void testThatNewSpanIsCreatedWhenNotProvided() throws MalformedURLException {
final BookStoreService service = createJaxWsService();
assertThat(service.getBooks().size(), equalTo(2));
assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Get Books"));
assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("POST /BookStore"));
final Map<String, List<String>> response = getResponseHeaders(service);
assertThat(response.get(TracerHeaders.DEFAULT_HEADER_SPAN_ID), nullValue());
}
use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.
the class HTraceTracingTest method testThatProvidedSpanIsNotClosedWhenActive.
@Test
public void testThatProvidedSpanIsNotClosedWhenActive() throws MalformedURLException {
final Tracer tracer = createTracer();
final BookStoreService service = createJaxWsService(new Configurator() {
@Override
public void configure(final JaxWsProxyFactoryBean factory) {
factory.getOutInterceptors().add(new HTraceClientStartInterceptor(tracer));
factory.getInInterceptors().add(new HTraceClientStopInterceptor());
}
});
try (TraceScope scope = tracer.newScope("test span")) {
assertThat(service.getBooks().size(), equalTo(2));
assertThat(Tracer.getCurrentSpan(), not(nullValue()));
assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Get Books"));
assertThat(TestSpanReceiver.getAllSpans().get(0).getParents().length, equalTo(1));
assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("POST /BookStore"));
}
assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(3));
assertThat(TestSpanReceiver.getAllSpans().get(2).getDescription(), equalTo("test span"));
final Map<String, List<String>> response = getResponseHeaders(service);
assertThat(response.get(TracerHeaders.DEFAULT_HEADER_SPAN_ID), not(nullValue()));
}
Aggregations