Search in sources :

Example 1 with JSONSerializer

use of net.sf.json.JSONSerializer 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)

Aggregations

PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)1 Method (java.lang.reflect.Method)1 JSON (net.sf.json.JSON)1 JSONSerializer (net.sf.json.JSONSerializer)1 Test (org.junit.Test)1