Skip to content

Commit

Permalink
added test for handler chain order
Browse files Browse the repository at this point in the history
  • Loading branch information
pellmont committed Apr 1, 2023
1 parent 9e7c788 commit 29b94bc
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
*/

import hello.HelloServiceImpl
import io.opentelemetry.api.trace.Span
import io.opentelemetry.context.Context
import io.opentelemetry.instrumentation.api.instrumenter.LocalRootSpan
import org.apache.cxf.jaxws.EndpointImpl
import org.apache.cxf.message.Message
import org.apache.cxf.phase.AbstractPhaseInterceptor
import org.apache.cxf.phase.Phase
import org.apache.cxf.transport.servlet.CXFNonSpringServlet

import javax.servlet.ServletConfig
Expand All @@ -18,5 +24,14 @@ class TestWsServlet extends CXFNonSpringServlet {
Object implementor = new HelloServiceImpl()
EndpointImpl endpoint = new EndpointImpl(bus, implementor)
endpoint.publish("/HelloService")
endpoint.getOutInterceptors().add(new AbstractPhaseInterceptor<Message>(Phase.SETUP) {
@Override
void handleMessage(Message message) {
Context context = Context.current()
if (LocalRootSpan.fromContext(context) != Span.fromContext(context)) {
throw new IllegalStateException("handler span should not be ended before outgoing interceptors")
}
}
});
}
}

0 comments on commit 29b94bc

Please sign in to comment.