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