Search in sources :

Example 26 with PluginTestVerifier

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

the class DubboProviderIT method testDoNotTrace.

@Test
public void testDoNotTrace() throws Exception {
    when(rpcInvocation.getAttachment(DubboConstants.META_DO_NOT_TRACE)).thenReturn("1");
    AbstractProxyInvoker abstractProxyInvoker = new AbstractProxyInvoker(new String(), String.class, url) {

        @Override
        protected Object doInvoke(Object proxy, String methodName, Class[] parameterTypes, Object[] arguments) throws Throwable {
            Method method = proxy.getClass().getMethod(methodName, parameterTypes);
            return method.invoke(proxy, arguments);
        }
    };
    try {
        abstractProxyInvoker.invoke(rpcInvocation);
    } catch (RpcException ignore) {
        ignore.printStackTrace();
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTraceCount(0);
}
Also used : RpcException(com.alibaba.dubbo.rpc.RpcException) Method(java.lang.reflect.Method) AbstractProxyInvoker(com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 27 with PluginTestVerifier

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

the class DubboProviderIT method testProvider.

@Test
public void testProvider() throws NoSuchMethodException {
    AbstractProxyInvoker abstractProxyInvoker = new AbstractProxyInvoker(new String(), String.class, url) {

        @Override
        protected Object doInvoke(Object proxy, String methodName, Class[] parameterTypes, Object[] arguments) throws Throwable {
            Method method = proxy.getClass().getMethod(methodName, parameterTypes);
            return method.invoke(proxy, arguments);
        }
    };
    try {
        abstractProxyInvoker.invoke(rpcInvocation);
    } catch (RpcException ignore) {
        ignore.printStackTrace();
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTraceCount(1);
}
Also used : RpcException(com.alibaba.dubbo.rpc.RpcException) Method(java.lang.reflect.Method) AbstractProxyInvoker(com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 28 with PluginTestVerifier

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

the class GsonIT method testFromV1_6.

@Test
public void testFromV1_6() throws Exception {
    if (!v1_6) {
        return;
    }
    final Gson gson = new Gson();
    final JsonElement jsonElement = getParseElements();
    /**
         * @see Gson#fromJson(JsonReader, InterceptPoint)
         */
    gson.fromJson(new JsonReader(new StringReader(json)), String.class);
    Method fromJson5 = Gson.class.getDeclaredMethod("fromJson", JsonReader.class, Type.class);
    /**
         * @see Gson#toJson(Object, InterceptPoint, JsonWriter)
         * @see Gson#toJson(JsonElement, JsonWriter)
         */
    gson.toJson(java, String.class, new JsonWriter(new StringWriter()));
    gson.toJson(jsonElement, new JsonWriter(new StringWriter()));
    Method toJson5 = Gson.class.getDeclaredMethod("toJson", Object.class, Type.class, JsonWriter.class);
    Method toJson8 = Gson.class.getDeclaredMethod("toJson", JsonElement.class, JsonWriter.class);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event(serviceType, fromJson5));
    verifier.verifyTrace(event(serviceType, toJson5), event(serviceType, toJson8));
    // No more traces
    verifier.verifyTraceCount(0);
}
Also used : StringWriter(java.io.StringWriter) JsonElement(com.google.gson.JsonElement) StringReader(java.io.StringReader) Gson(com.google.gson.Gson) JsonReader(com.google.gson.stream.JsonReader) Method(java.lang.reflect.Method) JsonWriter(com.google.gson.stream.JsonWriter) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 29 with PluginTestVerifier

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

the class HttpClientIT method test.

@Test
public void test() throws Exception {
    HttpClient client = new HttpClient();
    client.getParams().setConnectionManagerTimeout(CONNECTION_TIMEOUT);
    client.getParams().setSoTimeout(SO_TIMEOUT);
    GetMethod method = new GetMethod("http://google.com");
    // Provide custom retry handler is necessary
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
    method.setQueryString(new NameValuePair[] { new NameValuePair("key2", "value2") });
    try {
        // Execute the method.
        client.executeMethod(method);
    } catch (Exception ignored) {
    } finally {
        method.releaseConnection();
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) HttpClient(org.apache.commons.httpclient.HttpClient) GetMethod(org.apache.commons.httpclient.methods.GetMethod) DefaultHttpMethodRetryHandler(org.apache.commons.httpclient.DefaultHttpMethodRetryHandler) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 30 with PluginTestVerifier

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

the class HystrixCommand_1_4_1_to_1_4_2_IT method testSyncCall.

@Test
public void testSyncCall() throws Exception {
    String name = "Pinpoint";
    executeSayHelloCommand(name);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method queue = HystrixCommand.class.getMethod("queue");
    Class<?> executionObservableClazz = Class.forName(EXECUTION_OBSERVABLE_INNER_CLASS);
    Method executioObservableCallCmd = executionObservableClazz.getDeclaredMethod("call", Subscriber.class);
    verifier.verifyTrace(Expectations.async(Expectations.event("HYSTRIX_COMMAND", queue, annotation("hystrix.command", SayHelloCommand.class.getSimpleName())), Expectations.event("ASYNC", "Asynchronous Invocation"), Expectations.event("HYSTRIX_COMMAND_INTERNAL", executioObservableCallCmd, annotation("hystrix.command.execution", "run"))));
    // no more traces
    verifier.verifyTraceCount(0);
}
Also used : 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