Search in sources :

Example 56 with PluginTestVerifier

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 testTraceContinuation.

@Test
public void testTraceContinuation() throws Exception {
    String name = "Pinpoint";
    executeInvokeSayHelloCommand(name);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    // If the trace is propagated properly to a HystrixCommand's run() method, there should be 6 total traces.
    // 3 for InvokeSayHelloCommand, 3 for SayHelloCommand.
    verifier.verifyTraceCount(6);
}
Also used : PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 57 with PluginTestVerifier

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

the class ObjectMapperIT method testReadValue.

@Test
public void testReadValue() throws Exception {
    String json_str = "{\"name\" : \"Jackson\"}";
    byte[] json_b = json_str.getBytes("UTF-8");
    mapper.readValue(json_str, __POJO.class);
    mapper.readValue(json_b, __POJO.class);
    ObjectReader reader = mapper.reader(__POJO.class);
    reader.readValue(json_str);
    reader.readValue(json_b);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method mapperReadValueString = ObjectMapper.class.getMethod("readValue", String.class, Class.class);
    Method mapperReadValueBytes = ObjectMapper.class.getMethod("readValue", byte[].class, Class.class);
    Method readerReadValueString = ObjectReader.class.getMethod("readValue", String.class);
    Method readerReadValueBytes = ObjectReader.class.getMethod("readValue", byte[].class);
    verifier.verifyTrace(event(SERVICE_TYPE, mapperReadValueString, annotation(ANNOTATION_KEY, json_str.length())));
    verifier.verifyTrace(event(SERVICE_TYPE, mapperReadValueBytes, annotation(ANNOTATION_KEY, json_b.length)));
    verifier.verifyTrace(event(SERVICE_TYPE, readerReadValueString, annotation(ANNOTATION_KEY, json_str.length())));
    verifier.verifyTrace(event(SERVICE_TYPE, readerReadValueBytes, annotation(ANNOTATION_KEY, 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)

Example 58 with PluginTestVerifier

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

the class ObjectMapper_1_x_IT method testWriteValue.

@Test()
public void testWriteValue() throws Exception {
    __POJO pojo = new __POJO();
    pojo.setName("Jackson");
    Method mapperWriteValueAsString = getMethod(ObjectMapper.class, "writeValueAsString", Object.class);
    Method mapperWriteValueAsBytes = getMethod(ObjectMapper.class, "writeValueAsBytes", Object.class);
    Method mapperWriteValue = getMethod(ObjectMapper.class, "writeValue", Writer.class, Object.class);
    mapper.writeValue(new OutputStreamWriter(new ByteArrayOutputStream()), pojo);
    String jsonString = mapperWriteValueAsString == null ? null : (String) mapperWriteValueAsString.invoke(mapper, pojo);
    byte[] jsonBytes = mapperWriteValueAsBytes == null ? null : (byte[]) mapperWriteValueAsBytes.invoke(mapper, pojo);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event(SERVICE_TYPE, mapperWriteValue));
    if (mapperWriteValueAsString != null) {
        verifier.verifyTrace(event(SERVICE_TYPE, mapperWriteValueAsString, annotation(ANNOTATION_KEY, jsonString.length())));
    }
    if (mapperWriteValueAsBytes != null) {
        verifier.verifyTrace(event(SERVICE_TYPE, mapperWriteValueAsBytes, annotation(ANNOTATION_KEY, jsonBytes.length)));
    }
    verifier.verifyTraceCount(0);
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) Method(java.lang.reflect.Method) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 59 with PluginTestVerifier

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

the class ObjectMapper_1_x_IT method testConstructor.

@Test
public void testConstructor() throws Exception {
    ObjectMapper mapper1 = new ObjectMapper();
    ObjectMapper mapper2 = new ObjectMapper(new JsonFactory());
    Constructor<?> omConstructor1 = ObjectMapper.class.getConstructor();
    Constructor<?> omConstructor2 = ObjectMapper.class.getConstructor(JsonFactory.class);
    Constructor<?> omConstructor3 = ObjectMapper.class.getConstructor(JsonFactory.class, SerializerProvider.class, DeserializerProvider.class);
    Class<?> serializationConfig = null;
    Class<?> deserializationConfig = null;
    try {
        serializationConfig = Class.forName("org.codehaus.jackson.map.SerializationConfig");
        deserializationConfig = Class.forName("org.codehaus.jackson.map.DeserializationConfig");
    } catch (ClassNotFoundException ignored) {
    }
    Constructor<?> omConstructor4 = null;
    if (serializationConfig != null && deserializationConfig != null) {
        omConstructor4 = ObjectMapper.class.getConstructor(JsonFactory.class, SerializerProvider.class, DeserializerProvider.class, serializationConfig, deserializationConfig);
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    if (omConstructor4 != null) {
        verifier.verifyTrace(event(SERVICE_TYPE, omConstructor4));
    }
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor3), event(SERVICE_TYPE, omConstructor1));
    if (omConstructor4 != null) {
        verifier.verifyTrace(event(SERVICE_TYPE, omConstructor4));
    }
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor3), event(SERVICE_TYPE, omConstructor2));
    verifier.verifyTraceCount(0);
}
Also used : DeserializerProvider(org.codehaus.jackson.map.DeserializerProvider) JsonFactory(org.codehaus.jackson.JsonFactory) SerializerProvider(org.codehaus.jackson.map.SerializerProvider) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Example 60 with PluginTestVerifier

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

the class PluginDisableIT method test.

@Test
public void test() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "jackson");
    mapper.writeValueAsString(map);
    mapper.writeValueAsBytes(map);
    ObjectWriter writer = mapper.writer();
    writer.writeValueAsString(map);
    writer.writeValueAsBytes(map);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTraceCount(0);
}
Also used : HashMap(java.util.HashMap) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) 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