Search in sources :

Example 21 with MockTracer

use of io.opentracing.mock.MockTracer in project camel by apache.

the class JdbcSpanDecoratorTest method testPre.

@Test
public void testPre() {
    Endpoint endpoint = Mockito.mock(Endpoint.class);
    Exchange exchange = Mockito.mock(Exchange.class);
    Message message = Mockito.mock(Message.class);
    Mockito.when(endpoint.getEndpointUri()).thenReturn("test");
    Mockito.when(exchange.getIn()).thenReturn(message);
    Mockito.when(message.getBody()).thenReturn(SQL_STATEMENT);
    SpanDecorator decorator = new JdbcSpanDecorator();
    MockTracer tracer = new MockTracer();
    MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
    decorator.pre(span, exchange, endpoint);
    assertEquals("sql", span.tags().get(Tags.DB_TYPE.getKey()));
    assertEquals(SQL_STATEMENT, span.tags().get(Tags.DB_STATEMENT.getKey()));
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) Message(org.apache.camel.Message) SpanDecorator(org.apache.camel.opentracing.SpanDecorator) MockTracer(io.opentracing.mock.MockTracer) MockSpan(io.opentracing.mock.MockSpan) Test(org.junit.Test)

Example 22 with MockTracer

use of io.opentracing.mock.MockTracer in project camel by apache.

the class SqlSpanDecoratorTest method testPre.

@Test
public void testPre() {
    Endpoint endpoint = Mockito.mock(Endpoint.class);
    Exchange exchange = Mockito.mock(Exchange.class);
    Message message = Mockito.mock(Message.class);
    Mockito.when(endpoint.getEndpointUri()).thenReturn("test");
    Mockito.when(exchange.getIn()).thenReturn(message);
    Mockito.when(message.getHeader(SqlSpanDecorator.CAMEL_SQL_QUERY)).thenReturn(SQL_STATEMENT);
    SpanDecorator decorator = new SqlSpanDecorator();
    MockTracer tracer = new MockTracer();
    MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
    decorator.pre(span, exchange, endpoint);
    assertEquals("sql", span.tags().get(Tags.DB_TYPE.getKey()));
    assertEquals(SQL_STATEMENT, span.tags().get(Tags.DB_STATEMENT.getKey()));
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) Message(org.apache.camel.Message) SpanDecorator(org.apache.camel.opentracing.SpanDecorator) MockTracer(io.opentracing.mock.MockTracer) MockSpan(io.opentracing.mock.MockSpan) Test(org.junit.Test)

Example 23 with MockTracer

use of io.opentracing.mock.MockTracer in project tomee by apache.

the class MicroProfileOpenTracingTCKDeploymentPackager method generateDeployment.

@Override
public Archive<?> generateDeployment(final TestDeployment testDeployment, final Collection<ProtocolArchiveProcessor> processors) {
    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "microprofile-opentracing.war").merge(testDeployment.getApplicationArchive());
    // opentracing-api jar added by Geronimo Impl. Also added by TCK causes issues with same classes in different Classloaders
    final Map<ArchivePath, Node> content = webArchive.getContent(object -> object.get().matches(".*opentracing-api.*jar.*"));
    content.forEach((archivePath, node) -> webArchive.delete(archivePath));
    // TCK expects a MockTracer. Check org/eclipse/microprofile/opentracing/tck/application/TracerWebService.java:133
    webArchive.addAsLibrary(jarLocation(MockTracer.class));
    webArchive.addAsLibrary(jarLocation(ThreadLocalScopeManager.class));
    webArchive.addAsWebInfResource("META-INF/beans.xml");
    webArchive.addClass(MicroProfileOpenTracingTCKTracer.class);
    System.out.println(webArchive.toString(true));
    return super.generateDeployment(new TestDeployment(null, webArchive, testDeployment.getAuxiliaryArchives()), processors);
}
Also used : ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) ThreadLocalScopeManager(io.opentracing.util.ThreadLocalScopeManager) TestDeployment(org.jboss.arquillian.container.test.spi.TestDeployment) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) Node(org.jboss.shrinkwrap.api.Node) MockTracer(io.opentracing.mock.MockTracer)

Example 24 with MockTracer

use of io.opentracing.mock.MockTracer in project cxf by apache.

the class OpenTracingContextTest method setUp.

@Before
public void setUp() {
    tracer = new MockTracer();
    context = new OpenTracingContext(tracer);
}
Also used : MockTracer(io.opentracing.mock.MockTracer) Before(org.junit.Before)

Example 25 with MockTracer

use of io.opentracing.mock.MockTracer in project ballerina by ballerina-lang.

the class GetFinishedSpansCount method execute.

@Override
public void execute(Context context) {
    List<MockTracer> mockTracer = BMockTracer.getTracerMap();
    final int[] count = { 0 };
    mockTracer.forEach((tracer) -> count[0] += tracer.finishedSpans().size());
    context.setReturnValues(new BInteger(count[0]));
}
Also used : BInteger(org.ballerinalang.model.values.BInteger) MockTracer(io.opentracing.mock.MockTracer) BMockTracer(org.ballerina.testing.extension.BMockTracer)

Aggregations

MockTracer (io.opentracing.mock.MockTracer)31 Test (org.junit.Test)23 MockSpan (io.opentracing.mock.MockSpan)17 SpanDecorator (org.apache.camel.opentracing.SpanDecorator)13 Endpoint (org.apache.camel.Endpoint)11 Exchange (org.apache.camel.Exchange)10 Message (org.apache.camel.Message)8 DefaultResponse (com.weibo.api.motan.rpc.DefaultResponse)2 Response (com.weibo.api.motan.rpc.Response)2 Before (org.junit.Before)2 DefaultRequest (com.weibo.api.motan.rpc.DefaultRequest)1 Request (com.weibo.api.motan.rpc.Request)1 URL (com.weibo.api.motan.rpc.URL)1 Scope (io.opentracing.Scope)1 Tracer (io.opentracing.Tracer)1 ThreadLocalActiveSpanSource (io.opentracing.util.ThreadLocalActiveSpanSource)1 ThreadLocalScopeManager (io.opentracing.util.ThreadLocalScopeManager)1 Client (javax.ws.rs.client.Client)1 WebTarget (javax.ws.rs.client.WebTarget)1 Response (javax.ws.rs.core.Response)1