use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.
the class HttpURLConnectionIT method test.
@Test
public void test() throws Exception {
URL url = new URL("http://www.naver.com");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.getHeaderFields();
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
Class<?> targetClass = Class.forName("sun.net.www.protocol.http.HttpURLConnection");
Method getInputStream = targetClass.getMethod("getInputStream");
verifier.verifyTraceCount(1);
verifier.verifyTrace(event("JDK_HTTPURLCONNECTOR", getInputStream, null, null, "www.naver.com", annotation("http.url", "http://www.naver.com")));
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.
the class HttpURLConnectionIT method testConnectTwice.
@Test
public void testConnectTwice() throws Exception {
URL url = new URL("http://www.naver.com");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
connection.getInputStream();
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
Class<?> targetClass = Class.forName("sun.net.www.protocol.http.HttpURLConnection");
Method connect = targetClass.getMethod("connect");
verifier.verifyTraceCount(1);
verifier.verifyTrace(event("JDK_HTTPURLCONNECTOR", connect, null, null, "www.naver.com", annotation("http.url", "http://www.naver.com")));
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.
the class HttpURLConnectionIT method testConnecting.
@Test
public void testConnecting() throws Exception {
URL url = new URL("http://no.such.url");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
try {
connection.connect();
} catch (UnknownHostException e) {
// ignore
}
try {
connection.connect();
} catch (UnknownHostException e) {
// ignore
}
Field field = null;
try {
field = connection.getClass().getDeclaredField("connecting");
} catch (NoSuchFieldException ignored) {
}
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
Class<?> targetClass = Class.forName("sun.net.www.protocol.http.HttpURLConnection");
Method getInputStream = targetClass.getMethod("connect");
verifier.verifyTrace(event("JDK_HTTPURLCONNECTOR", getInputStream, null, null, "no.such.url", annotation("http.url", "http://no.such.url")));
if (field == null) {
// JDK 6, 7
verifier.verifyTrace(event("JDK_HTTPURLCONNECTOR", getInputStream, null, null, "no.such.url", annotation("http.url", "http://no.such.url")));
}
verifier.verifyTraceCount(0);
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.
the class ActiveMQClientITBase method verifyConsumerPullEvent.
/**
* Verifies spans and span events for when {@link ActiveMQMessageConsumer} receives the message and enqueues it to
* the {@link org.apache.activemq.MessageDispatchChannel MessageDispatchChannel}. The client then invokes any of
* {@link ActiveMQMessageConsumer#receive() receive()}, {@link ActiveMQMessageConsumer#receive(long) receive(long)},
* or {@link ActiveMQMessageConsumer#receiveNoWait() receiveNotWait()} to retrieve the message. (trace count : 4)
*
* @param destination the destination from which the consumer is receiving the message
* @param expectedMessage the message the consumer is expected to receive
* @throws Exception
*/
private void verifyConsumerPullEvent(ActiveMQDestination destination, MessageConsumer consumer, Message expectedMessage) throws Exception {
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
Class<?> messageConsumerClass = Class.forName("org.apache.activemq.ActiveMQMessageConsumer");
Method receiveWithTimeout = messageConsumerClass.getDeclaredMethod("receive", long.class);
URI consumerBrokerUri = new URI(getConsumerBrokerUrl());
ExpectedTrace consumerDispatchTrace = root(// serviceType
ACTIVEMQ_CLIENT, // method
"ActiveMQ Consumer Invocation", // rpc
destination.getQualifiedName(), // endPoint (collected but there's no easy way to retrieve local address)
null, consumerBrokerUri.getHost() + ":" + consumerBrokerUri.getPort());
ExpectedTrace consumerReceiveTrace = event(// serviceType
ACTIVEMQ_CLIENT_INTERNAL, // method
receiveWithTimeout, annotation("activemq.message", getMessageAsString(expectedMessage)));
Class<?> messageDispatchChannel = getMessageDispatchChannelClass(consumer);
if (messageDispatchChannel != null) {
Method enqueue = messageDispatchChannel.getDeclaredMethod("enqueue", MessageDispatch.class);
Method dequeueWithTimeout = messageDispatchChannel.getDeclaredMethod("dequeue", long.class);
// Consumer dispatches and enqueues the message to dispatch channel automatically
verifier.verifyDiscreteTrace(consumerDispatchTrace, event(ACTIVEMQ_CLIENT_INTERNAL, enqueue));
// Client receives the message by dequeueing it from the dispatch channel
verifier.verifyDiscreteTrace(consumerReceiveTrace, event(ACTIVEMQ_CLIENT_INTERNAL, dequeueWithTimeout));
} else {
// Consumer dispatches and enqueues the message to dispatch channel automatically
verifier.verifyDiscreteTrace(consumerDispatchTrace);
// Client receives the message by dequeueing it from the dispatch channel
verifier.verifyDiscreteTrace(consumerReceiveTrace);
}
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.
the class ActiveMQClientITBase method verifyProducerSendEvent.
/**
* Verifies traced span event for when {@link org.apache.activemq.ActiveMQMessageProducer ActiveMQMessageProducer}
* sends the message. (trace count : 1)
*
* @param destination the destination to which the producer is sending the message
* @throws Exception
*/
private void verifyProducerSendEvent(ActiveMQDestination destination) throws Exception {
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
Class<?> messageProducerClass = Class.forName("org.apache.activemq.ActiveMQMessageProducer");
Method send = messageProducerClass.getDeclaredMethod("send", Destination.class, Message.class, int.class, int.class, long.class);
URI producerBrokerUri = new URI(getProducerBrokerUrl());
verifier.verifyDiscreteTrace(event(// serviceType
ACTIVEMQ_CLIENT, // method
send, // rpc
null, // endPoint
producerBrokerUri.getHost() + ":" + producerBrokerUri.getPort(), // destinationId
destination.getPhysicalName(), annotation("message.queue.url", destination.getQualifiedName()), annotation("activemq.broker.address", producerBrokerUri.getHost() + ":" + producerBrokerUri.getPort())));
}
Aggregations