Search in sources :

Example 51 with MockSpan

use of io.opentracing.mock.MockSpan in project motan by weibocom.

the class OpenTracingFilterTest method testException.

@Test
public void testException() {
    response.setException(new RuntimeException("in test"));
    Response res = OTFilter.filter(refer, request);
    assertEquals(response, res);
    if (tracer instanceof MockTracer) {
        MockSpan span = ((MockTracer) tracer).finishedSpans().get(0);
        assertEquals(span.logEntries().size(), 1);
        assertTrue("request fail.in test".equals(span.logEntries().get(0).fields().get("event")));
    }
}
Also used : DefaultResponse(com.weibo.api.motan.rpc.DefaultResponse) Response(com.weibo.api.motan.rpc.Response) MockTracer(io.opentracing.mock.MockTracer) MockSpan(io.opentracing.mock.MockSpan) Test(org.junit.Test)

Aggregations

MockSpan (io.opentracing.mock.MockSpan)51 Test (org.junit.Test)50 MockTracer (io.opentracing.mock.MockTracer)17 Matchers.anyString (org.mockito.Matchers.anyString)14 SpanDecorator (org.apache.camel.opentracing.SpanDecorator)13 Endpoint (org.apache.camel.Endpoint)11 Scope (io.opentracing.Scope)10 Exchange (org.apache.camel.Exchange)10 Message (org.apache.camel.Message)8 Span (io.opentracing.Span)2 DefaultResponse (com.weibo.api.motan.rpc.DefaultResponse)1 Response (com.weibo.api.motan.rpc.Response)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Client (javax.ws.rs.client.Client)1 WebTarget (javax.ws.rs.client.WebTarget)1