use of com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace in project pinpoint by naver.
the class SpringAmqpRabbit_1_7_7_to_2_0_0_IT method testPush.
@Test
public void testPush() throws Exception {
final String remoteAddress = testRunner.getRemoteAddress();
Class<?> rabbitTemplateClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate");
Method rabbitTemplateConvertAndSend = rabbitTemplateClass.getDeclaredMethod("convertAndSend", String.class, String.class, Object.class);
ExpectedTrace rabbitTemplateConvertAndSendTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
rabbitTemplateConvertAndSend);
// automatic recovery deliberately disabled as Spring has it's own recovery mechanism
Class<?> channelNClass = Class.forName("com.rabbitmq.client.impl.ChannelN");
Method channelNBasicPublish = channelNClass.getDeclaredMethod("basicPublish", String.class, String.class, boolean.class, boolean.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace channelNBasicPublishTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT, // method
channelNBasicPublish, // rpc
null, // endPoint
remoteAddress, // destinationId
"exchange-" + RabbitMQTestConstants.EXCHANGE, Expectations.annotation("rabbitmq.exchange", RabbitMQTestConstants.EXCHANGE), Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PUSH));
ExpectedTrace rabbitMqConsumerInvocationTrace = Expectations.root(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT, // method
"RabbitMQ Consumer Invocation", // rpc
"rabbitmq://exchange=" + RabbitMQTestConstants.EXCHANGE, // endPoint (collected but API to retrieve local address is not available in all versions, so skip)
null, // remoteAddress
remoteAddress, Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PUSH));
Class<?> consumerDispatcherClass = Class.forName("com.rabbitmq.client.impl.ConsumerDispatcher");
Method consumerDispatcherHandleDelivery = consumerDispatcherClass.getDeclaredMethod("handleDelivery", Consumer.class, String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace consumerDispatcherHandleDeliveryTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
consumerDispatcherHandleDelivery);
ExpectedTrace asynchronousInvocationTrace = Expectations.event(ServiceType.ASYNC.getName(), "Asynchronous Invocation");
Class<?> blockingQueueConsumerConsumerDecoratorClass = Class.forName("org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$ConsumerDecorator");
Method blockingQueueConsumerConsumerDecoratorHandleDelivery = blockingQueueConsumerConsumerDecoratorClass.getDeclaredMethod("handleDelivery", String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace blockingQueueConsumerConsumerDecoratorHandleDeliveryTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, blockingQueueConsumerConsumerDecoratorHandleDelivery);
Class<?> deliveryClass = Class.forName("org.springframework.amqp.rabbit.support.Delivery");
Constructor<?> deliveryConstructor = deliveryClass.getDeclaredConstructor(String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace deliveryConstructorTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, deliveryConstructor);
Class<?> abstractMessageListenerContainerClass = Class.forName("org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer");
Method abstractMessageListenerContainerExecuteListener = abstractMessageListenerContainerClass.getDeclaredMethod("executeListener", Channel.class, Message.class);
ExpectedTrace abstractMessageListenerContainerExecuteListenerTrace = Expectations.event(ServiceType.INTERNAL_METHOD.getName(), abstractMessageListenerContainerExecuteListener);
Class<?> propagationMarkerClass = PropagationMarker.class;
Method propagationMarkerMark = propagationMarkerClass.getDeclaredMethod("mark");
ExpectedTrace markTrace = Expectations.event(ServiceType.INTERNAL_METHOD.getName(), propagationMarkerMark);
ExpectedTrace[] producerTraces = { rabbitTemplateConvertAndSendTrace, channelNBasicPublishTrace };
ExpectedTrace[] consumerTraces = { rabbitMqConsumerInvocationTrace, consumerDispatcherHandleDeliveryTrace, asynchronousInvocationTrace, blockingQueueConsumerConsumerDecoratorHandleDeliveryTrace, deliveryConstructorTrace, asynchronousInvocationTrace, abstractMessageListenerContainerExecuteListenerTrace, markTrace };
final int expectedTraceCount = producerTraces.length + consumerTraces.length;
final PluginTestVerifier verifier = testRunner.runPush(expectedTraceCount);
verifier.verifyDiscreteTrace(producerTraces);
verifier.verifyDiscreteTrace(consumerTraces);
verifier.verifyTraceCount(0);
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace in project pinpoint by naver.
the class SpringAmqpRabbit_2_0_3_to_2_1_0_IT method testPullWithTimeout.
@Test
public void testPullWithTimeout() throws Exception {
final String remoteAddress = testRunner.getRemoteAddress();
Class<?> rabbitTemplateClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate");
// verify queue-initiated traces
Method rabbitTemplateConvertAndSend = rabbitTemplateClass.getDeclaredMethod("convertAndSend", String.class, String.class, Object.class);
ExpectedTrace rabbitTemplateConvertAndSendTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
rabbitTemplateConvertAndSend);
// automatic recovery deliberately disabled as Spring has it's own recovery mechanism
Class<?> channelNClass = Class.forName("com.rabbitmq.client.impl.ChannelN");
Method channelNBasicPublish = channelNClass.getDeclaredMethod("basicPublish", String.class, String.class, boolean.class, boolean.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace channelNBasicPublishTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT, // method
channelNBasicPublish, // rpc
null, // endPoint
remoteAddress, // destinationId
"exchange-" + RabbitMQTestConstants.EXCHANGE, Expectations.annotation("rabbitmq.exchange", RabbitMQTestConstants.EXCHANGE), Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PULL));
ExpectedTrace rabbitMqConsumerInvocationTrace = Expectations.root(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT, // method
"RabbitMQ Consumer Invocation", // rpc
"rabbitmq://exchange=" + RabbitMQTestConstants.EXCHANGE, // endPoint (collected but API to retrieve local address is not available in all versions, so skip)
null, // remoteAddress
remoteAddress, Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PULL));
Class<?> consumerDispatcherClass = Class.forName("com.rabbitmq.client.impl.ConsumerDispatcher");
Method consumerDispatcherHandleDelivery = consumerDispatcherClass.getDeclaredMethod("handleDelivery", Consumer.class, String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace consumerDispatcherHandleDeliveryTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
consumerDispatcherHandleDelivery);
ExpectedTrace asynchronousInvocationTrace = Expectations.event(ServiceType.ASYNC.getName(), "Asynchronous Invocation");
// RabbitTemplate internal consumer implementation - may change in future versions which will cause tests to
// fail, in which case the integration test needs to be updated to match code changes
Class<?> rabbitTemplateInternalConsumerClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate$2");
Method rabbitTemplateInternalConsumerHandleDelivery = rabbitTemplateInternalConsumerClass.getDeclaredMethod("handleDelivery", String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace rabbitTemplateInternalConsumerHandleDeliveryTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
rabbitTemplateInternalConsumerHandleDelivery);
Class<?> deliveryClass = Class.forName("org.springframework.amqp.rabbit.support.Delivery");
Constructor<?> deliveryConstructor = deliveryClass.getDeclaredConstructor(String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace deliveryConstructorTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, deliveryConstructor);
ExpectedTrace[] producerTraces = { rabbitTemplateConvertAndSendTrace, channelNBasicPublishTrace };
ExpectedTrace[] consumerTraces = { rabbitMqConsumerInvocationTrace, consumerDispatcherHandleDeliveryTrace, asynchronousInvocationTrace, rabbitTemplateInternalConsumerHandleDeliveryTrace, deliveryConstructorTrace };
// verify client-initiated traces
Method rabbitTemplateReceive = rabbitTemplateClass.getDeclaredMethod("receive", String.class, long.class);
ExpectedTrace rabbitTemplateReceiveTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
rabbitTemplateReceive);
Class<?> propagationMarkerClass = PropagationMarker.class;
Method propagationMarkerMark = propagationMarkerClass.getDeclaredMethod("mark");
ExpectedTrace markTrace = Expectations.event(ServiceType.INTERNAL_METHOD.getName(), propagationMarkerMark);
ExpectedTrace[] clientInitiatedTraces = { rabbitTemplateReceiveTrace, markTrace };
final int expectedTraceCount = producerTraces.length + consumerTraces.length + clientInitiatedTraces.length;
final PluginTestVerifier verifier = testRunner.runPull(expectedTraceCount, 5000L);
verifier.verifyDiscreteTrace(producerTraces);
verifier.verifyDiscreteTrace(consumerTraces);
verifier.verifyDiscreteTrace(clientInitiatedTraces);
verifier.verifyTraceCount(0);
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace in project pinpoint by naver.
the class SpringAmqpRabbit_2_0_3_to_2_1_0_IT method testPush.
@Test
public void testPush() throws Exception {
final String remoteAddress = testRunner.getRemoteAddress();
Class<?> rabbitTemplateClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate");
Method rabbitTemplateConvertAndSend = rabbitTemplateClass.getDeclaredMethod("convertAndSend", String.class, String.class, Object.class);
ExpectedTrace rabbitTemplateConvertAndSendTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
rabbitTemplateConvertAndSend);
// automatic recovery deliberately disabled as Spring has it's own recovery mechanism
Class<?> channelNClass = Class.forName("com.rabbitmq.client.impl.ChannelN");
Method channelNBasicPublish = channelNClass.getDeclaredMethod("basicPublish", String.class, String.class, boolean.class, boolean.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace channelNBasicPublishTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT, // method
channelNBasicPublish, // rpc
null, // endPoint
remoteAddress, // destinationId
"exchange-" + RabbitMQTestConstants.EXCHANGE, Expectations.annotation("rabbitmq.exchange", RabbitMQTestConstants.EXCHANGE), Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PUSH));
ExpectedTrace rabbitMqConsumerInvocationTrace = Expectations.root(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT, // method
"RabbitMQ Consumer Invocation", // rpc
"rabbitmq://exchange=" + RabbitMQTestConstants.EXCHANGE, // endPoint (collected but API to retrieve local address is not available in all versions, so skip)
null, // remoteAddress
remoteAddress, Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PUSH));
Class<?> consumerDispatcherClass = Class.forName("com.rabbitmq.client.impl.ConsumerDispatcher");
Method consumerDispatcherHandleDelivery = consumerDispatcherClass.getDeclaredMethod("handleDelivery", Consumer.class, String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace consumerDispatcherHandleDeliveryTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
consumerDispatcherHandleDelivery);
ExpectedTrace asynchronousInvocationTrace = Expectations.event(ServiceType.ASYNC.getName(), "Asynchronous Invocation");
Class<?> blockingQueueConsumerConsumerDecoratorClass = Class.forName("org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$ConsumerDecorator");
Method blockingQueueConsumerConsumerDecoratorHandleDelivery = blockingQueueConsumerConsumerDecoratorClass.getDeclaredMethod("handleDelivery", String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace blockingQueueConsumerConsumerDecoratorHandleDeliveryTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, blockingQueueConsumerConsumerDecoratorHandleDelivery);
Class<?> deliveryClass = Class.forName("org.springframework.amqp.rabbit.support.Delivery");
Constructor<?> deliveryConstructor = deliveryClass.getDeclaredConstructor(String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace deliveryConstructorTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, deliveryConstructor);
Class<?> abstractMessageListenerContainerClass = Class.forName("org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer");
Method abstractMessageListenerContainerExecuteListener = abstractMessageListenerContainerClass.getDeclaredMethod("executeListener", Channel.class, Message.class);
ExpectedTrace abstractMessageListenerContainerExecuteListenerTrace = Expectations.event(ServiceType.INTERNAL_METHOD.getName(), abstractMessageListenerContainerExecuteListener);
Class<?> propagationMarkerClass = PropagationMarker.class;
Method propagationMarkerMark = propagationMarkerClass.getDeclaredMethod("mark");
ExpectedTrace markTrace = Expectations.event(ServiceType.INTERNAL_METHOD.getName(), propagationMarkerMark);
ExpectedTrace[] producerTraces = { rabbitTemplateConvertAndSendTrace, channelNBasicPublishTrace };
ExpectedTrace[] consumerTraces = { rabbitMqConsumerInvocationTrace, consumerDispatcherHandleDeliveryTrace, asynchronousInvocationTrace, blockingQueueConsumerConsumerDecoratorHandleDeliveryTrace, deliveryConstructorTrace, asynchronousInvocationTrace, abstractMessageListenerContainerExecuteListenerTrace, markTrace };
final int expectedTraceCount = producerTraces.length + consumerTraces.length;
final PluginTestVerifier verifier = testRunner.runPush(expectedTraceCount);
verifier.verifyDiscreteTrace(producerTraces);
verifier.verifyDiscreteTrace(consumerTraces);
verifier.verifyTraceCount(0);
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace in project pinpoint by naver.
the class SpringAmqpRabbit_2_1_x_to_2_x_IT method testPull.
@Test
public void testPull() throws Exception {
final String remoteAddress = testRunner.getRemoteAddress();
Class<?> rabbitTemplateClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate");
// verify queue-initiated traces
Method rabbitTemplateConvertAndSend = rabbitTemplateClass.getDeclaredMethod("convertAndSend", String.class, String.class, Object.class);
ExpectedTrace rabbitTemplateConvertAndSendTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
rabbitTemplateConvertAndSend);
// automatic recovery deliberately disabled as Spring has it's own recovery mechanism
Class<?> channelNClass = Class.forName("com.rabbitmq.client.impl.ChannelN");
Method channelNBasicPublish = channelNClass.getDeclaredMethod("basicPublish", String.class, String.class, boolean.class, boolean.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace channelNBasicPublishTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT, // method
channelNBasicPublish, // rpc
null, // endPoint
remoteAddress, // destinationId
"exchange-" + RabbitMQTestConstants.EXCHANGE, Expectations.annotation("rabbitmq.exchange", RabbitMQTestConstants.EXCHANGE), Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PULL));
ExpectedTrace rabbitMqConsumerInvocationTrace = Expectations.root(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT, // method
"RabbitMQ Consumer Invocation", // rpc
"rabbitmq://exchange=" + RabbitMQTestConstants.EXCHANGE, // endPoint (collected but API to retrieve local address is not available in all versions, so skip)
null, // remoteAddress
remoteAddress, Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PULL));
Class<?> amqChannelClass = Class.forName("com.rabbitmq.client.impl.AMQChannel");
Method amqChannelHandleCompleteInboundCommand = amqChannelClass.getDeclaredMethod("handleCompleteInboundCommand", AMQCommand.class);
ExpectedTrace amqChannelHandleCompleteInboundCommandTrace = Expectations.event(// method
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, amqChannelHandleCompleteInboundCommand);
ExpectedTrace[] producerTraces = { rabbitTemplateConvertAndSendTrace, channelNBasicPublishTrace };
ExpectedTrace[] consumerTraces = { rabbitMqConsumerInvocationTrace, amqChannelHandleCompleteInboundCommandTrace };
// verify client-initiated traces
Method rabbitTemplateReceive = rabbitTemplateClass.getDeclaredMethod("receive", String.class);
ExpectedTrace rabbitTemplateReceiveTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
rabbitTemplateReceive);
Method channelNBasicGet = channelNClass.getDeclaredMethod("basicGet", String.class, boolean.class);
ExpectedTrace channelNBasicGetTrace = Expectations.event(RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, channelNBasicGet);
Class<?> propagationMarkerClass = PropagationMarker.class;
Method propagationMarkerMark = propagationMarkerClass.getDeclaredMethod("mark");
ExpectedTrace markTrace = Expectations.event(ServiceType.INTERNAL_METHOD.getName(), propagationMarkerMark);
ExpectedTrace[] clientInitiatedTraces = { rabbitTemplateReceiveTrace, channelNBasicGetTrace, markTrace };
final int expectedTraceCount = producerTraces.length + consumerTraces.length + clientInitiatedTraces.length;
final PluginTestVerifier verifier = testRunner.runPull(expectedTraceCount);
verifier.verifyDiscreteTrace(producerTraces);
verifier.verifyDiscreteTrace(consumerTraces);
verifier.verifyDiscreteTrace(clientInitiatedTraces);
verifier.verifyTraceCount(0);
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace in project pinpoint by naver.
the class SpringAmqpRabbit_2_1_x_to_2_x_IT method testPullWithTimeout.
@Test
public void testPullWithTimeout() throws Exception {
final String remoteAddress = testRunner.getRemoteAddress();
Class<?> rabbitTemplateClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate");
// verify queue-initiated traces
Method rabbitTemplateConvertAndSend = rabbitTemplateClass.getDeclaredMethod("convertAndSend", String.class, String.class, Object.class);
ExpectedTrace rabbitTemplateConvertAndSendTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
rabbitTemplateConvertAndSend);
// automatic recovery deliberately disabled as Spring has it's own recovery mechanism
Class<?> channelNClass = Class.forName("com.rabbitmq.client.impl.ChannelN");
Method channelNBasicPublish = channelNClass.getDeclaredMethod("basicPublish", String.class, String.class, boolean.class, boolean.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace channelNBasicPublishTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT, // method
channelNBasicPublish, // rpc
null, // endPoint
remoteAddress, // destinationId
"exchange-" + RabbitMQTestConstants.EXCHANGE, Expectations.annotation("rabbitmq.exchange", RabbitMQTestConstants.EXCHANGE), Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PULL));
ExpectedTrace rabbitMqConsumerInvocationTrace = Expectations.root(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT, // method
"RabbitMQ Consumer Invocation", // rpc
"rabbitmq://exchange=" + RabbitMQTestConstants.EXCHANGE, // endPoint (collected but API to retrieve local address is not available in all versions, so skip)
null, // remoteAddress
remoteAddress, Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PULL));
Class<?> consumerDispatcherClass = Class.forName("com.rabbitmq.client.impl.ConsumerDispatcher");
Method consumerDispatcherHandleDelivery = consumerDispatcherClass.getDeclaredMethod("handleDelivery", Consumer.class, String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace consumerDispatcherHandleDeliveryTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
consumerDispatcherHandleDelivery);
ExpectedTrace asynchronousInvocationTrace = Expectations.event(ServiceType.ASYNC.getName(), "Asynchronous Invocation");
// RabbitTemplate internal consumer implementation - may change in future versions which will cause tests to
// fail, in which case the integration test needs to be updated to match code changes
Class<?> rabbitTemplateInternalConsumerClass = getRabbitTemplateClazz();
Method rabbitTemplateInternalConsumerHandleDelivery = rabbitTemplateInternalConsumerClass.getDeclaredMethod("handleDelivery", String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
ExpectedTrace rabbitTemplateInternalConsumerHandleDeliveryTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
rabbitTemplateInternalConsumerHandleDelivery);
Class<?> deliveryClass = Class.forName("org.springframework.amqp.rabbit.support.Delivery");
Constructor<?> deliveryConstructor = deliveryClass.getDeclaredConstructor(String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class, String.class);
ExpectedTrace deliveryConstructorTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, deliveryConstructor);
ExpectedTrace[] producerTraces = { rabbitTemplateConvertAndSendTrace, channelNBasicPublishTrace };
ExpectedTrace[] consumerTraces = { rabbitMqConsumerInvocationTrace, consumerDispatcherHandleDeliveryTrace, asynchronousInvocationTrace, rabbitTemplateInternalConsumerHandleDeliveryTrace, deliveryConstructorTrace };
// verify client-initiated traces
Method rabbitTemplateReceive = rabbitTemplateClass.getDeclaredMethod("receive", String.class, long.class);
ExpectedTrace rabbitTemplateReceiveTrace = Expectations.event(// serviceType
RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // method
rabbitTemplateReceive);
Class<?> propagationMarkerClass = PropagationMarker.class;
Method propagationMarkerMark = propagationMarkerClass.getDeclaredMethod("mark");
ExpectedTrace markTrace = Expectations.event(ServiceType.INTERNAL_METHOD.getName(), propagationMarkerMark);
ExpectedTrace[] clientInitiatedTraces = { rabbitTemplateReceiveTrace, markTrace };
final int expectedTraceCount = producerTraces.length + consumerTraces.length + clientInitiatedTraces.length;
final PluginTestVerifier verifier = testRunner.runPull(expectedTraceCount, 5000L);
verifier.verifyDiscreteTrace(producerTraces);
verifier.verifyDiscreteTrace(consumerTraces);
verifier.verifyDiscreteTrace(clientInitiatedTraces);
verifier.verifyTraceCount(0);
}
Aggregations