use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.
the class HTraceTracingTest method testThatNewChildSpanIsCreatedWhenParentIsProvided.
@Test
public void testThatNewChildSpanIsCreatedWhenParentIsProvided() 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());
}
});
assertThat(service.getBooks().size(), equalTo(2));
assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(3));
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().get(2).getDescription(), equalTo("POST http://localhost:" + PORT + "/BookStore"));
final Map<String, List<String>> response = getResponseHeaders(service);
assertThat(response.get(TracerHeaders.DEFAULT_HEADER_SPAN_ID), not(nullValue()));
}
use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.
the class HTraceTracingTest 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 OpenTracingTracingTest method testThatNewSpanIsCreatedWhenNotProvided.
@Test
public void testThatNewSpanIsCreatedWhenNotProvided() throws MalformedURLException {
final BookStoreService service = createJaxWsService();
assertThat(service.getBooks().size(), equalTo(2));
assertThat(TestSender.getAllSpans().size(), equalTo(2));
assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("Get Books"));
assertThat(TestSender.getAllSpans().get(1).getOperationName(), equalTo("POST /BookStore"));
}
use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.
the class OpenTracingTracingTest 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(TestSender.getAllSpans().size(), equalTo(1));
assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("POST /BookStore"));
}
use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.
the class OpenTracingTracingTest method testThatProvidedSpanIsNotClosedWhenActive.
@Test
public void testThatProvidedSpanIsNotClosedWhenActive() throws MalformedURLException {
final BookStoreService service = createJaxWsService(new Configurator() {
@Override
public void configure(final JaxWsProxyFactoryBean factory) {
factory.getFeatures().add(new OpenTracingClientFeature(tracer));
}
});
try (ActiveSpan scope = tracer.buildSpan("test span").startActive()) {
assertThat(service.getBooks().size(), equalTo(2));
assertThat(tracer.activeSpan(), not(nullValue()));
assertThat(TestSender.getAllSpans().size(), equalTo(3));
assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("Get Books"));
assertThat(TestSender.getAllSpans().get(0).getReferences(), not(empty()));
assertThat(TestSender.getAllSpans().get(1).getOperationName(), equalTo("POST /BookStore"));
assertThat(TestSender.getAllSpans().get(1).getReferences(), not(empty()));
assertThat(TestSender.getAllSpans().get(2).getOperationName(), equalTo("POST http://localhost:" + PORT + "/BookStore"));
assertThat(TestSender.getAllSpans().get(2).getReferences(), not(empty()));
}
// Await till flush happens, usually every second
await().atMost(Duration.ONE_SECOND).until(() -> TestSender.getAllSpans().size() == 4);
assertThat(TestSender.getAllSpans().size(), equalTo(4));
assertThat(TestSender.getAllSpans().get(3).getOperationName(), equalTo("test span"));
assertThat(TestSender.getAllSpans().get(3).getReferences(), empty());
}
Aggregations