Search in sources :

Example 1 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class ActiveMQClientITBase method verifyConsumerPushEvent.

/**
     * Verifies spans and span events for when {@link ActiveMQMessageConsumer} receives the message and invokes it's
     * {@link javax.jms.MessageListener MessageListener}. (trace count : 1)
     *
     * @param destination the destination from which the consumer is receiving the message
     * @throws Exception
     */
private void verifyConsumerPushEvent(ActiveMQDestination destination) throws Exception {
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    URI consumerBrokerUri = new URI(getConsumerBrokerUrl());
    verifier.verifyDiscreteTrace(root(// serviceType
    ACTIVEMQ_CLIENT, // method
    "ActiveMQ Consumer Invocation", // rpc
    destination.getQualifiedName(), // endPoint (collected but there's no easy way to retrieve local address so skip check)
    null, // remoteAddress
    consumerBrokerUri.getHost() + ":" + consumerBrokerUri.getPort()));
}
Also used : PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) URI(java.net.URI)

Example 2 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class ActiveMQClientITBase method awaitAndVerifyTraceCount.

protected final void awaitAndVerifyTraceCount(int expectedTraceCount, long maxWaitMs) throws InterruptedException {
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    final long waitIntervalMs = 100L;
    long maxWaitTime = maxWaitMs;
    if (maxWaitMs < waitIntervalMs) {
        maxWaitTime = waitIntervalMs;
    }
    long startTime = System.currentTimeMillis();
    while (System.currentTimeMillis() - startTime < maxWaitTime) {
        try {
            verifier.verifyTraceCount(expectedTraceCount);
            return;
        } catch (AssertionError e) {
            // ignore and retry
            Thread.sleep(waitIntervalMs);
        }
    }
    verifier.printCache();
    verifier.verifyTraceCount(expectedTraceCount);
}
Also used : PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)

Example 3 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class SpringWebMvcIT method testRequest.

@Test
public void testRequest() throws Exception {
    MockServletConfig config = new MockServletConfig();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse res = new MockHttpServletResponse();
    config.addInitParameter("contextConfigLocation", "classpath:spring-web-test.xml");
    req.setMethod("GET");
    req.setRequestURI("/");
    req.setRemoteAddr("1.2.3.4");
    DispatcherServlet servlet = new DispatcherServlet();
    servlet.init(config);
    servlet.service(req, res);
    Method method = FrameworkServlet.class.getDeclaredMethod("doGet", HttpServletRequest.class, HttpServletResponse.class);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(Expectations.event(SPRING_MVC, method));
    verifier.verifyTraceCount(0);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) MockServletConfig(org.springframework.mock.web.MockServletConfig) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 4 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class JsonLibJSONObjectIT method mapToJsonTest.

@Test
public void mapToJsonTest() throws Exception {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "pinpoint");
    map.put("lib", "json-lib");
    JSONObject jsonObject = JSONObject.fromObject(map);
    String json = jsonObject.toString();
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method fromObject = JSONObject.class.getMethod("fromObject", Object.class);
    Method toString = JSONObject.class.getMethod("toString");
    verifier.verifyTrace(event(SERVICE_TYPE, fromObject));
    verifier.verifyTrace(event(SERVICE_TYPE, toString, annotation(ANNOTATION_KEY, json.length())));
    verifier.verifyTraceCount(0);
}
Also used : JSONObject(net.sf.json.JSONObject) HashMap(java.util.HashMap) JSONObject(net.sf.json.JSONObject) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 5 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class JsonLibJSONObjectIT method jsonToBeanTest.

@Test
public void jsonToBeanTest() throws Exception {
    String json = "{'string':'JSON'}";
    JSONObject jsonObject = JSONObject.fromObject(json);
    JSONObject.toBean(jsonObject);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method fromObject = JSONObject.class.getMethod("fromObject", Object.class);
    Method toBean = JSONObject.class.getMethod("toBean", JSONObject.class);
    verifier.verifyTrace(event(SERVICE_TYPE, fromObject, annotation(ANNOTATION_KEY, json.length())));
    verifier.verifyTrace(event(SERVICE_TYPE, toBean));
    verifier.verifyTraceCount(0);
}
Also used : JSONObject(net.sf.json.JSONObject) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Aggregations

PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)101 Method (java.lang.reflect.Method)80 Test (org.junit.Test)80 SqlSession (org.apache.ibatis.session.SqlSession)8 SqlMapClientTemplate (org.springframework.orm.ibatis.SqlMapClientTemplate)8 IOException (java.io.IOException)5 RpcException (com.alibaba.dubbo.rpc.RpcException)4 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)3 Gson (com.google.gson.Gson)3 ExpectedTrace (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace)3 HttpURLConnection (java.net.HttpURLConnection)3 URI (java.net.URI)3 URL (java.net.URL)3 FailoverClusterInvoker (com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker)2 AbstractProxyInvoker (com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)2 GenericUrl (com.google.api.client.http.GenericUrl)2 HttpRequest (com.google.api.client.http.HttpRequest)2 HttpRequestFactory (com.google.api.client.http.HttpRequestFactory)2