Search in sources :

Example 6 with PluginTestVerifier

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

the class JsonLibJSONSerializerIT method test.

@Test
public void test() throws Exception {
    Method toJSON = JSONSerializer.class.getMethod("toJSON", Object.class);
    Method toJava = JSONSerializer.class.getMethod("toJava", JSON.class);
    String test = "{'string':'JSON'}";
    JSON json = JSONSerializer.toJSON(test);
    if (Modifier.isStatic(toJava.getModifiers())) {
        toJava.invoke(null, json);
    } else {
        // JSONSerializer.toJava(JSON) of json-lib 2.0 and below is instance method.
        toJava.invoke(new JSONSerializer(), json);
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event(SERVICE_TYPE, toJSON, annotation(ANNOTATION_KEY, test.length())));
    verifier.verifyTrace(event("JSON-LIB", toJava));
    verifier.verifyTraceCount(0);
}
Also used : JSON(net.sf.json.JSON) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) JSONSerializer(net.sf.json.JSONSerializer) Test(org.junit.Test)

Example 7 with PluginTestVerifier

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

the class SqlSessionTestBase method testAndVerifySelectMap.

protected final void testAndVerifySelectMap() throws Exception {
    // Given
    final String selectMapId = "selectListId";
    SqlSession sqlSession = getSqlSession();
    // When
    sqlSession.selectMap(selectMapId, "key");
    sqlSession.selectMap(selectMapId, new Object(), "key");
    sqlSession.selectMap(selectMapId, new Object(), "key", RowBounds.DEFAULT);
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method selectMap1 = sqlSession.getClass().getDeclaredMethod("selectMap", String.class, String.class);
    Method selectMap2 = sqlSession.getClass().getDeclaredMethod("selectMap", String.class, Object.class, String.class);
    Method selectMap3 = sqlSession.getClass().getDeclaredMethod("selectMap", String.class, Object.class, String.class, RowBounds.class);
    verifier.verifyTrace(event("MYBATIS", selectMap1, Expectations.cachedArgs(selectMapId)));
    verifier.verifyTrace(event("MYBATIS", selectMap2, Expectations.cachedArgs(selectMapId)));
    verifier.verifyTrace(event("MYBATIS", selectMap3, Expectations.cachedArgs(selectMapId)));
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)

Example 8 with PluginTestVerifier

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

the class SqlSessionTestBase method testAndVerifySelectList.

protected final void testAndVerifySelectList() throws Exception {
    // Given
    final String selectListId = "selectListId";
    SqlSession sqlSession = getSqlSession();
    // When
    sqlSession.selectList(selectListId);
    sqlSession.selectList(selectListId, new Object());
    sqlSession.selectList(selectListId, new Object(), RowBounds.DEFAULT);
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method selectList1 = sqlSession.getClass().getDeclaredMethod("selectList", String.class);
    Method selectList2 = sqlSession.getClass().getDeclaredMethod("selectList", String.class, Object.class);
    Method selectList3 = sqlSession.getClass().getDeclaredMethod("selectList", String.class, Object.class, RowBounds.class);
    verifier.verifyTrace(event("MYBATIS", selectList1, Expectations.cachedArgs(selectListId)));
    verifier.verifyTrace(event("MYBATIS", selectList2, Expectations.cachedArgs(selectListId)));
    verifier.verifyTrace(event("MYBATIS", selectList3, Expectations.cachedArgs(selectListId)));
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)

Example 9 with PluginTestVerifier

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

the class SqlSessionTestBase method testAndVerifySelectOne.

protected final void testAndVerifySelectOne() throws Exception {
    // Given
    final String selectOneId = "selectOneId";
    SqlSession sqlSession = getSqlSession();
    // When
    sqlSession.selectOne(selectOneId);
    sqlSession.selectOne(selectOneId, new Object());
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method selectOne1 = sqlSession.getClass().getDeclaredMethod("selectOne", String.class);
    Method selectOne2 = sqlSession.getClass().getDeclaredMethod("selectOne", String.class, Object.class);
    verifier.verifyTrace(event("MYBATIS", selectOne1, Expectations.cachedArgs(selectOneId)));
    verifier.verifyTrace(event("MYBATIS", selectOne2, Expectations.cachedArgs(selectOneId)));
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)

Example 10 with PluginTestVerifier

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

the class ObjectReaderIT method testReadValue.

@Test
public void testReadValue() throws Exception {
    String json_str = "{\"name\" : \"Jackson\"}";
    byte[] json_b = json_str.getBytes("UTF-8");
    ObjectReader reader = mapper.reader(__POJO.class);
    __POJO pojo = reader.readValue(json_str);
    pojo = reader.readValue(json_b);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method readval1 = ObjectReader.class.getMethod("readValue", String.class);
    Method readval2 = ObjectReader.class.getMethod("readValue", byte[].class);
    verifier.verifyTrace(event("JACKSON", readval1, Expectations.annotation("jackson.json.length", json_str.length())));
    verifier.verifyTrace(event("JACKSON", readval2, Expectations.annotation("jackson.json.length", json_b.length)));
    verifier.verifyTraceCount(0);
}
Also used : ObjectReader(com.fasterxml.jackson.databind.ObjectReader) 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