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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations