use of io.opentracing.mock.MockTracer in project camel by apache.
the class CqlSpanDecoratorTest method testPreCqlFromHeader.
@Test
public void testPreCqlFromHeader() {
String cql = "select * from users";
Endpoint endpoint = Mockito.mock(Endpoint.class);
Exchange exchange = Mockito.mock(Exchange.class);
Message message = Mockito.mock(Message.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("cql://host1,host2?consistencyLevel=quorum");
Mockito.when(exchange.getIn()).thenReturn(message);
Mockito.when(message.getHeader(CqlSpanDecorator.CAMEL_CQL_QUERY)).thenReturn(cql);
SpanDecorator decorator = new CqlSpanDecorator();
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.pre(span, exchange, endpoint);
assertEquals(CqlSpanDecorator.CASSANDRA_DB_TYPE, span.tags().get(Tags.DB_TYPE.getKey()));
assertEquals(cql, span.tags().get(Tags.DB_STATEMENT.getKey()));
assertNull(span.tags().get(Tags.DB_INSTANCE.getKey()));
}
use of io.opentracing.mock.MockTracer in project camel by apache.
the class KafkaSpanDecoratorTest method testPre.
@Test
public void testPre() {
String testKey = "TestKey";
String testOffset = "TestOffset";
String testPartition = "TestPartition";
String testPartitionKey = "TestPartitionKey";
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(KafkaSpanDecorator.KEY)).thenReturn(testKey);
Mockito.when(message.getHeader(KafkaSpanDecorator.OFFSET)).thenReturn(testOffset);
Mockito.when(message.getHeader(KafkaSpanDecorator.PARTITION)).thenReturn(testPartition);
Mockito.when(message.getHeader(KafkaSpanDecorator.PARTITION_KEY)).thenReturn(testPartitionKey);
SpanDecorator decorator = new KafkaSpanDecorator();
MockTracer tracer = new MockTracer();
MockSpan span = tracer.buildSpan("TestSpan").start();
decorator.pre(span, exchange, endpoint);
assertEquals(testKey, span.tags().get(KafkaSpanDecorator.KAFKA_KEY_TAG));
assertEquals(testOffset, span.tags().get(KafkaSpanDecorator.KAFKA_OFFSET_TAG));
assertEquals(testPartition, span.tags().get(KafkaSpanDecorator.KAFKA_PARTITION_TAG));
assertEquals(testPartitionKey, span.tags().get(KafkaSpanDecorator.KAFKA_PARTITION_KEY_TAG));
}
use of io.opentracing.mock.MockTracer in project camel by apache.
the class MongoDBSpanDecoratorTest method testPre.
@Test
public void testPre() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn(MONGODB_STATEMENT);
SpanDecorator decorator = new MongoDBSpanDecorator();
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.pre(span, null, endpoint);
assertEquals("mongodb", span.tags().get(Tags.DB_TYPE.getKey()));
assertEquals("flights", span.tags().get(Tags.DB_INSTANCE.getKey()));
assertTrue(span.tags().containsKey(Tags.DB_STATEMENT.getKey()));
}
use of io.opentracing.mock.MockTracer in project camel by apache.
the class AbstractHttpSpanDecoratorTest method testPreUri.
@Test
public void testPreUri() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Exchange exchange = Mockito.mock(Exchange.class);
Message message = Mockito.mock(Message.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
Mockito.when(exchange.getIn()).thenReturn(message);
Mockito.when(message.getHeader(Exchange.HTTP_URI)).thenReturn(TEST_URI);
SpanDecorator decorator = new AbstractHttpSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.pre(span, exchange, endpoint);
assertEquals(TEST_URI, span.tags().get(Tags.HTTP_URL.getKey()));
assertTrue(span.tags().containsKey(Tags.HTTP_METHOD.getKey()));
}
use of io.opentracing.mock.MockTracer in project camel by apache.
the class AbstractMessagingSpanDecoratorTest method testPreMessageBusDestination.
@Test
public void testPreMessageBusDestination() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("jms://MyQueue?hello=world");
SpanDecorator decorator = new AbstractMessagingSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.pre(span, null, endpoint);
assertEquals("MyQueue", span.tags().get(Tags.MESSAGE_BUS_DESTINATION.getKey()));
}
Aggregations