use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.
the class NingAsyncHttpClientIT method test.
@Test
public void test() throws Exception {
AsyncHttpClient client = new AsyncHttpClient();
try {
Future<Response> f = client.preparePost("http://www.naver.com/").addParameter("param1", "value1").execute();
Response response = f.get();
} finally {
client.close();
}
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
verifier.verifyTrace(event("ASYNC_HTTP_CLIENT", AsyncHttpClient.class.getMethod("executeRequest", Request.class, AsyncHandler.class), null, null, "www.naver.com", annotation("http.url", "http://www.naver.com"), annotation("http.param", "param1=value1")));
verifier.verifyTraceCount(0);
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.
the class AbstractAutowireCapableBeanFactoryModifierIT method test.
@Test
public void test() throws Exception {
ApplicationContext context = new ClassPathXmlApplicationContext("spring-beans-test.xml");
Maru maru = context.getBean(Maru.class);
maru.publicMethod();
maru.protectedMethod();
Morae morae = (Morae) context.getBean("morae");
morae.doSomething();
Morae duplicatedMorae = (Morae) context.getBean("duplicatedMorae");
duplicatedMorae.doSomething();
Mozzi mozzi = (Mozzi) context.getBean("mozzi");
mozzi.doSomething();
Excluded excluded = (Excluded) context.getBean("excluded");
excluded.doSomething();
Outer outer = (Outer) context.getBean("outer");
outer.doSomething();
Inner inner = outer.getInner();
inner.doSomething();
ProxyTarget proxyTarget = context.getBean(ProxyTarget.class);
proxyTarget.doSomething();
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
verifier.verifyTrace(Expectations.event("SPRING_BEAN", Outer.class.getMethod("setInner", Inner.class)));
verifier.verifyTrace(Expectations.event("SPRING_BEAN", Maru.class.getMethod("publicMethod")));
verifier.verifyTrace(Expectations.event("SPRING_BEAN", Morae.class.getMethod("doSomething")));
verifier.verifyTrace(Expectations.event("SPRING_BEAN", Morae.class.getMethod("doSomething")));
verifier.verifyTrace(Expectations.event("SPRING_BEAN", Mozzi.class.getMethod("doSomething")));
verifier.verifyTrace(Expectations.event("SPRING_BEAN", Outer.class.getMethod("doSomething")));
verifier.verifyTrace(Expectations.event("SPRING_BEAN", Outer.class.getMethod("getInner")));
verifier.verifyTrace(Expectations.event("SPRING_BEAN", Inner.class.getMethod("doSomething")));
verifier.verifyTrace(Expectations.event("SPRING_BEAN", ProxyTarget.class.getMethod("doSomething")));
verifier.verifyTraceCount(0);
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.
the class CassandraDatastaxITBase method test.
@Test
public void test() throws Exception {
final int testId = 99;
final String testValue = "testValue";
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
Session myKeyspaceSession = null;
try {
myKeyspaceSession = cluster.connect(TEST_KEYSPACE);
// ===============================================
// Insert Data (PreparedStatement, BoundStatement)
PreparedStatement preparedStatement = myKeyspaceSession.prepare(CQL_INSERT);
BoundStatement boundStatement = new BoundStatement(preparedStatement);
boundStatement.bind(testId, testValue);
myKeyspaceSession.execute(boundStatement);
verifier.printCache();
// Cluster#connect(String)
Class<?> clusterClass = Class.forName("com.datastax.driver.core.Cluster");
Method connect = clusterClass.getDeclaredMethod("connect", String.class);
verifier.verifyTrace(event(CASSANDRA, connect, null, CASSANDRA_ADDRESS, TEST_KEYSPACE));
// SessionManager#prepare(String) OR AbstractSession#prepare(String)
Class<?> sessionClass;
try {
sessionClass = Class.forName("com.datastax.driver.core.AbstractSession");
} catch (ClassNotFoundException e) {
sessionClass = Class.forName("com.datastax.driver.core.SessionManager");
}
Method prepare = sessionClass.getDeclaredMethod("prepare", String.class);
verifier.verifyTrace(event(CASSANDRA, prepare, null, CASSANDRA_ADDRESS, TEST_KEYSPACE, sql(CQL_INSERT, null)));
// SessionManager#execute(Statement) OR AbstractSession#execute(Statement)
Method execute = sessionClass.getDeclaredMethod("execute", Statement.class);
verifier.verifyTrace(event(CASSANDRA_EXECUTE_QUERY, execute, null, CASSANDRA_ADDRESS, TEST_KEYSPACE, sql(CQL_INSERT, null)));
// ====================
// Select Data (String)
final String cqlSelect = String.format("SELECT %s, %s FROM %s WHERE %s = %d", TEST_COL_ID, TEST_COL_VALUE, TEST_TABLE, TEST_COL_ID, testId);
verifySelect(myKeyspaceSession.execute(cqlSelect), testId, testValue);
verifier.printCache();
// SessionManager#execute(String) OR AbstractSession#execute(String)
execute = sessionClass.getDeclaredMethod("execute", String.class);
String normalizedSelectSql = SQL_PARSER.normalizedSql(cqlSelect).getNormalizedSql();
verifier.verifyTrace(event(CASSANDRA_EXECUTE_QUERY, execute, null, CASSANDRA_ADDRESS, TEST_KEYSPACE, sql(normalizedSelectSql, String.valueOf(testId))));
// ====================
// Delete Data (String)
final String cqlDelete = String.format("DELETE FROM %s.%s WHERE %s = ?", TEST_KEYSPACE, TEST_TABLE, TEST_COL_ID);
myKeyspaceSession.execute(cqlDelete, testId);
verifier.printCache();
// SessionManager#execute(String, Object[]) OR AbstractSession#execute(String, Object[])
execute = sessionClass.getDeclaredMethod("execute", String.class, Object[].class);
String normalizedDeleteSql = SQL_PARSER.normalizedSql(cqlDelete).getNormalizedSql();
verifier.verifyTrace(event(CASSANDRA_EXECUTE_QUERY, execute, null, CASSANDRA_ADDRESS, TEST_KEYSPACE, sql(normalizedDeleteSql, null)));
} finally {
closeSession(myKeyspaceSession);
}
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.
the class OkHttpClientIT method enqueue.
@Test
public void enqueue() throws Exception {
Request request = new Request.Builder().url("http://google.com").build();
OkHttpClient client = new OkHttpClient();
final CountDownLatch latch = new CountDownLatch(1);
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Request request, IOException e) {
latch.countDown();
}
@Override
public void onResponse(Response response) throws IOException {
latch.countDown();
}
});
latch.await(3, TimeUnit.SECONDS);
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
Method enqueueMethod = Call.class.getDeclaredMethod("enqueue", com.squareup.okhttp.Callback.class);
verifier.verifyTrace(Expectations.event("OK_HTTP_CLIENT_INTERNAL", enqueueMethod));
}
use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.
the class JsonLibJSONArrayIT method arrayToJsonTest.
@Test
public void arrayToJsonTest() throws Exception {
Method fromObject = JSONArray.class.getMethod("fromObject", Object.class);
Method toString = JSONArray.class.getMethod("toString");
JSONArray jsonArray = JSONArray.fromObject(new Object[] { "pinpoint", "json-lib" });
String json = jsonArray.toString();
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
verifier.verifyTrace(event(SERVICE_TYPE, fromObject));
verifier.verifyTrace(event(SERVICE_TYPE, toString, Expectations.annotation(ANNOTATION_KEY, json.length())));
verifier.verifyTraceCount(0);
}
Aggregations