Search in sources :

Example 46 with PluginTestVerifier

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

the class HttpRequestIT method execute.

@Test
public void execute() throws Exception {
    HttpTransport NET_HTTP_TRANSPORT = new NetHttpTransport();
    HttpRequestFactory requestFactory = NET_HTTP_TRANSPORT.createRequestFactory(new HttpRequestInitializer() {

        @Override
        public void initialize(HttpRequest request) {
        }
    });
    GenericUrl url = new GenericUrl("http://google.com");
    HttpRequest request = null;
    HttpResponse response = null;
    try {
        request = requestFactory.buildGetRequest(url);
        response = request.execute();
        response.disconnect();
    } catch (IOException ignored) {
    } finally {
        if (response != null) {
            response.disconnect();
        }
    }
    Method executeMethod = HttpRequest.class.getDeclaredMethod("execute");
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(Expectations.event("GOOGLE_HTTP_CLIENT_INTERNAL", executeMethod));
}
Also used : HttpRequest(com.google.api.client.http.HttpRequest) NetHttpTransport(com.google.api.client.http.javanet.NetHttpTransport) HttpTransport(com.google.api.client.http.HttpTransport) HttpRequestFactory(com.google.api.client.http.HttpRequestFactory) NetHttpTransport(com.google.api.client.http.javanet.NetHttpTransport) HttpResponse(com.google.api.client.http.HttpResponse) GenericUrl(com.google.api.client.http.GenericUrl) IOException(java.io.IOException) Method(java.lang.reflect.Method) HttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 47 with PluginTestVerifier

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

the class GsonIT method testFromV1_2.

@Test
public void testFromV1_2() throws Exception {
    if (!v1_2) {
        return;
    }
    final Gson gson = new Gson();
    final JsonElement jsonElement = getParseElements();
    /**
         * @see Gson#fromJson(Reader, Class)
         * @see Gson#fromJson(Reader, InterceptPoint)
         * @see Gson#fromJson(JsonElement, Class)
         * @see Gson#fromJson(JsonElement, InterceptPoint)
         */
    gson.fromJson(new StringReader(json), (Class<?>) String.class);
    gson.fromJson(new StringReader(json), (Type) String.class);
    gson.fromJson(jsonElement, String.class);
    gson.fromJson(jsonElement, (Type) String.class);
    Method fromJson3 = Gson.class.getDeclaredMethod("fromJson", Reader.class, Class.class);
    Method fromJson4 = Gson.class.getDeclaredMethod("fromJson", Reader.class, Type.class);
    Method fromJson6 = Gson.class.getDeclaredMethod("fromJson", JsonElement.class, Class.class);
    Method fromJson7 = Gson.class.getDeclaredMethod("fromJson", JsonElement.class, Type.class);
    /**
         * @see Gson#toJson(Object, Appendable)
         * @see Gson#toJson(Object, InterceptPoint, Appendable)
         * @see Gson#toJson(JsonElement)
         * @see Gson#toJson(JsonElement, Appendable)
         */
    gson.toJson(java, new StringWriter());
    gson.toJson(java, String.class, new StringWriter());
    gson.toJson(jsonElement);
    gson.toJson(jsonElement, new StringWriter());
    Method toJson3 = Gson.class.getDeclaredMethod("toJson", Object.class, Appendable.class);
    Method toJson4 = Gson.class.getDeclaredMethod("toJson", Object.class, Type.class, Appendable.class);
    Method toJson6 = Gson.class.getDeclaredMethod("toJson", JsonElement.class);
    Method toJson7 = Gson.class.getDeclaredMethod("toJson", JsonElement.class, Appendable.class);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event(serviceType, fromJson3), event(serviceType, fromJson4), event(serviceType, fromJson6), event(serviceType, fromJson7));
    verifier.verifyTrace(event(serviceType, toJson3), event(serviceType, toJson4), event(serviceType, toJson6, expectedAnnotation), event(serviceType, toJson7));
    // 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) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 48 with PluginTestVerifier

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

the class GsonIT method test.

@Test
public void test() throws Exception {
    final Gson gson = new Gson();
    /**
         * @see Gson#fromJson(String, Class)
         * @see Gson#fromJson(String, InterceptPoint)
         */
    gson.fromJson(json, String.class);
    gson.fromJson(json, (Type) String.class);
    Method fromJson1 = Gson.class.getDeclaredMethod("fromJson", String.class, Class.class);
    Method fromJson2 = Gson.class.getDeclaredMethod("fromJson", String.class, Type.class);
    /**
         * @see Gson#toJson(Object)
         * @see Gson#toJson(Object, InterceptPoint)
         */
    gson.toJson(java);
    gson.toJson(java, String.class);
    Method toJson1 = Gson.class.getDeclaredMethod("toJson", Object.class);
    Method toJson2 = Gson.class.getDeclaredMethod("toJson", Object.class, Type.class);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event(serviceType, fromJson1, expectedAnnotation), event(serviceType, fromJson2, expectedAnnotation));
    verifier.verifyTrace(event(serviceType, toJson1, expectedAnnotation), event(serviceType, toJson2, expectedAnnotation));
    // No more traces
    verifier.verifyTraceCount(0);
}
Also used : Gson(com.google.gson.Gson) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 49 with PluginTestVerifier

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

the class HikariCpIT method testIdleTimeout4.

@Test
public void testIdleTimeout4() throws InterruptedException, SQLException, NoSuchMethodException {
    Connection connection = dataSource.getConnection();
    Assert.assertNotNull(connection);
    Thread.sleep(500);
    connection.close();
    Thread.sleep(500);
    Method getConnection = HikariDataSource.class.getDeclaredMethod("getConnection");
    Method proxyConnection = ConnectionProxy.class.getDeclaredMethod("close");
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event(serviceType, getConnection));
    verifier.verifyTrace(event(serviceType, proxyConnection));
}
Also used : Connection(java.sql.Connection) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 50 with PluginTestVerifier

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

the class HttpClientIT method hostConfig.

@Test
public void hostConfig() throws Exception {
    HttpClient client = new HttpClient();
    client.getParams().setConnectionManagerTimeout(CONNECTION_TIMEOUT);
    client.getParams().setSoTimeout(SO_TIMEOUT);
    HostConfiguration config = new HostConfiguration();
    config.setHost("weather.naver.com", 80, "http");
    GetMethod method = new GetMethod("/rgn/cityWetrMain.nhn");
    // 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(config, method);
    } catch (Exception ignored) {
    } finally {
        method.releaseConnection();
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) HostConfiguration(org.apache.commons.httpclient.HostConfiguration) 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)

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