Search in sources :

Example 51 with PluginTestVerifier

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

the class CloaeableHttpClientIT method test.

@Test
public void test() throws Exception {
    CloseableHttpClient httpclient = HttpClients.createDefault();
    try {
        HttpGet httpget = new HttpGet("http://www.naver.com");
        CloseableHttpResponse response = httpclient.execute(httpget);
        try {
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                InputStream instream = entity.getContent();
                try {
                    instream.read();
                } catch (IOException ex) {
                    throw ex;
                } finally {
                    instream.close();
                }
            }
        } finally {
            response.close();
        }
    } finally {
        httpclient.close();
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event("HTTP_CLIENT_4_INTERNAL", CloseableHttpClient.class.getMethod("execute", HttpUriRequest.class)));
    verifier.verifyTrace(event("HTTP_CLIENT_4_INTERNAL", PoolingHttpClientConnectionManager.class.getMethod("connect", HttpClientConnection.class, HttpRoute.class, int.class, HttpContext.class), annotation("http.internal.display", "www.naver.com:80")));
    verifier.verifyTrace(event("HTTP_CLIENT_4", HttpRequestExecutor.class.getMethod("execute", HttpRequest.class, HttpClientConnection.class, HttpContext.class), null, null, "www.naver.com", annotation("http.url", "/"), annotation("http.status.code", 200), annotation("http.io", anyAnnotationValue())));
    verifier.verifyTraceCount(0);
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpEntity(org.apache.http.HttpEntity) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) IOException(java.io.IOException) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 52 with PluginTestVerifier

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

the class ClosableAsyncHttpClientIT method test.

@Test
public void test() throws Exception {
    CloseableHttpAsyncClient httpClient = HttpAsyncClients.custom().useSystemProperties().build();
    httpClient.start();
    try {
        HttpPost httpRequest = new HttpPost("http://www.naver.com/");
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("param1", "value1"));
        httpRequest.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8.name()));
        Future<HttpResponse> responseFuture = httpClient.execute(httpRequest, null);
        HttpResponse response = (HttpResponse) responseFuture.get();
        if ((response != null) && (response.getEntity() != null)) {
            EntityUtils.consume(response.getEntity());
        }
    } finally {
        httpClient.close();
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event("HTTP_CLIENT_4_INTERNAL", CloseableHttpAsyncClient.class.getMethod("execute", HttpUriRequest.class, FutureCallback.class)));
    verifier.verifyTrace(async(event("HTTP_CLIENT_4", Class.forName("org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl").getMethod("start"), null, null, "www.naver.com", annotation("http.url", "http://www.naver.com/"), annotation("http.entity", "param1=value1")), event("ASYNC", "Asynchronous Invocation"), event("HTTP_CLIENT_4_INTERNAL", BasicFuture.class.getMethod("completed", Object.class))));
    verifier.verifyTrace(event("HTTP_CLIENT_4_INTERNAL", BasicFuture.class.getMethod("get")));
    verifier.verifyTraceCount(0);
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) BasicFuture(org.apache.http.concurrent.BasicFuture) ArrayList(java.util.ArrayList) CloseableHttpAsyncClient(org.apache.http.impl.nio.client.CloseableHttpAsyncClient) HttpResponse(org.apache.http.HttpResponse) UrlEncodedFormEntity(org.apache.http.client.entity.UrlEncodedFormEntity) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 53 with PluginTestVerifier

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

the class DefaultHttpRequestRetryHandlerModifierIT method test.

@Test
public void test() throws Exception {
    DefaultHttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler();
    IOException iOException = new IOException();
    HttpContext context = new BasicHttpContext();
    assertTrue(retryHandler.retryRequest(iOException, 1, context));
    assertTrue(retryHandler.retryRequest(iOException, 2, context));
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event("HTTP_CLIENT_4_INTERNAL", DefaultHttpRequestRetryHandler.class.getMethod("retryRequest", IOException.class, int.class, HttpContext.class), annotation("http.internal.display", IOException.class.getName() + ", 1"), annotation("RETURN_DATA", true)));
    verifier.verifyTrace(event("HTTP_CLIENT_4_INTERNAL", DefaultHttpRequestRetryHandler.class.getMethod("retryRequest", IOException.class, int.class, HttpContext.class), annotation("http.internal.display", IOException.class.getName() + ", 2"), annotation("RETURN_DATA", true)));
    verifier.verifyTraceCount(0);
}
Also used : BasicHttpContext(org.apache.http.protocol.BasicHttpContext) DefaultHttpRequestRetryHandler(org.apache.http.impl.client.DefaultHttpRequestRetryHandler) BasicHttpContext(org.apache.http.protocol.BasicHttpContext) HttpContext(org.apache.http.protocol.HttpContext) IOException(java.io.IOException) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 54 with PluginTestVerifier

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

the class HystrixCommand_1_3_20_IT method testExecutionException.

@Test
public void testExecutionException() throws Exception {
    Exception expectedException = new RuntimeException("expected");
    executeThrowExceptionCommand(expectedException);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method queue = HystrixCommand.class.getMethod("queue");
    Method executeCmd = HystrixCommand.class.getDeclaredMethod("executeCommand");
    Method getFallbackOrThrowException = HystrixCommand.class.getDeclaredMethod("getFallbackOrThrowException", HystrixEventType.class, HystrixRuntimeException.FailureType.class, String.class, Exception.class);
    verifier.verifyTrace(Expectations.async(Expectations.event("HYSTRIX_COMMAND", queue, annotation("hystrix.command", ThrowExceptionCommand.class.getSimpleName())), Expectations.event("ASYNC", "Asynchronous Invocation"), Expectations.event("HYSTRIX_COMMAND_INTERNAL", executeCmd), Expectations.event("HYSTRIX_COMMAND_INTERNAL", getFallbackOrThrowException, annotation("hystrix.command.fallback.cause", expectedException.toString()))));
    // no more traces
    verifier.verifyTraceCount(0);
}
Also used : HystrixRuntimeException(com.netflix.hystrix.exception.HystrixRuntimeException) Method(java.lang.reflect.Method) HystrixRuntimeException(com.netflix.hystrix.exception.HystrixRuntimeException) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) HystrixRuntimeException(com.netflix.hystrix.exception.HystrixRuntimeException) Test(org.junit.Test)

Example 55 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 testAsyncCall.

@Test
public void testAsyncCall() throws Exception {
    String name = "Pinpoint";
    queueAndGetSayHelloCommand(name);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method queue = HystrixCommand.class.getMethod("queue");
    Class<?> executionObservableClazz = Class.forName(EXECUTION_OBSERVABLE_INNER_CLASS);
    Method executionObservableCallCmd = 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", executionObservableCallCmd, 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