use of org.apache.camel.Endpoint in project camel by apache.
the class AbstractHttpSpanDecoratorTest method testGetMethodBodyNotNull.
@Test
public void testGetMethodBodyNotNull() {
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);
Mockito.when(message.getBody()).thenReturn("Message Body");
assertEquals(AbstractHttpSpanDecorator.POST_METHOD, AbstractHttpSpanDecorator.getHttpMethod(exchange, endpoint));
}
use of org.apache.camel.Endpoint in project camel by apache.
the class AbstractHttpSpanDecoratorTest method testGetHttpURLFromHeaderUri.
@Test
public void testGetHttpURLFromHeaderUri() {
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);
AbstractHttpSpanDecorator decorator = new AbstractHttpSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
assertEquals(TEST_URI, decorator.getHttpURL(exchange, endpoint));
}
use of org.apache.camel.Endpoint in project camel by apache.
the class AbstractHttpSpanDecoratorTest method testGetMethodDefault.
@Test
public void testGetMethodDefault() {
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);
assertEquals(AbstractHttpSpanDecorator.GET_METHOD, AbstractHttpSpanDecorator.getHttpMethod(exchange, endpoint));
}
use of org.apache.camel.Endpoint 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 org.apache.camel.Endpoint in project camel by apache.
the class AbstractHttpSpanDecoratorTest method testGetHttpURLFromEndpointUri.
@Test
public void testGetHttpURLFromEndpointUri() {
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);
AbstractHttpSpanDecorator decorator = new AbstractHttpSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
assertEquals(TEST_URI, decorator.getHttpURL(exchange, endpoint));
}
Aggregations