Search in sources :

Example 66 with PluginTestVerifier

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

the class SqlMapClientTemplateIT method updateShouldBeTraced.

@Test
public void updateShouldBeTraced() throws Exception {
    // Given
    final String updateId = "updateId";
    SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
    // When
    clientTemplate.update(updateId);
    clientTemplate.update(updateId, new Object());
    clientTemplate.update(updateId, new Object(), 0);
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method update1 = SqlMapClientTemplate.class.getDeclaredMethod("update", String.class);
    Method update2 = SqlMapClientTemplate.class.getDeclaredMethod("update", String.class, Object.class);
    Method update3 = SqlMapClientTemplate.class.getDeclaredMethod("update", String.class, Object.class, int.class);
    verifier.verifyTrace(event("IBATIS_SPRING", update1, Expectations.cachedArgs(updateId)));
    verifier.verifyTrace(event("IBATIS_SPRING", update2, Expectations.cachedArgs(updateId)));
    verifier.verifyTrace(event("IBATIS_SPRING", update3, Expectations.cachedArgs(updateId)));
}
Also used : SqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 67 with PluginTestVerifier

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

the class SqlMapExecutorTestBase method testAndVerifyQueryForObject.

protected final void testAndVerifyQueryForObject(SqlMapExecutor executor) throws Exception {
    final String queryForObjectId = "queryForObjectId";
    executor.queryForObject(queryForObjectId);
    executor.queryForObject(queryForObjectId, new Object());
    executor.queryForObject(queryForObjectId, new Object(), new Object());
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method queryForObject1 = executor.getClass().getDeclaredMethod("queryForObject", String.class);
    Method queryForObject2 = executor.getClass().getDeclaredMethod("queryForObject", String.class, Object.class);
    Method queryForObject3 = executor.getClass().getDeclaredMethod("queryForObject", String.class, Object.class, Object.class);
    verifier.verifyTrace(event("IBATIS", queryForObject1, Expectations.cachedArgs(queryForObjectId)));
    verifier.verifyTrace(event("IBATIS", queryForObject2, Expectations.cachedArgs(queryForObjectId)));
    verifier.verifyTrace(event("IBATIS", queryForObject3, Expectations.cachedArgs(queryForObjectId)));
}
Also used : Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)

Example 68 with PluginTestVerifier

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

the class SqlMapExecutorTestBase method testAndVerifyInsertWithNullSqlId.

protected final void testAndVerifyInsertWithNullSqlId(SqlMapExecutor executor) throws Exception {
    executor.insert(null);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method insert = executor.getClass().getDeclaredMethod("insert", String.class);
    verifier.verifyTrace(event("IBATIS", insert));
}
Also used : Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)

Example 69 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 testExecutionException.

@Test
public void testExecutionException() throws Exception {
    Exception expectedException = new RuntimeException("expected");
    executeThrowExceptionCommand(expectedException);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method queue = HystrixCommand.class.getMethod("queue");
    Class<?> executionObservableClazz = Class.forName(EXECUTION_OBSERVABLE_INNER_CLASS);
    Method executionObservableCallCmd = executionObservableClazz.getDeclaredMethod("call", Subscriber.class);
    Class<?> fallbackObservableClazz = Class.forName(FALLBACK_OBSERVABLE_INNER_CLASS);
    Method fallbackObservableCallCmd = fallbackObservableClazz.getDeclaredMethod("call", Subscriber.class);
    verifier.verifyTrace(Expectations.async(Expectations.event("HYSTRIX_COMMAND", queue, annotation("hystrix.command", ThrowExceptionCommand.class.getSimpleName())), Expectations.event("ASYNC", "Asynchronous Invocation"), Expectations.event("HYSTRIX_COMMAND_INTERNAL", executionObservableCallCmd, annotation("hystrix.command.execution", "run")), Expectations.event("HYSTRIX_COMMAND_INTERNAL", fallbackObservableCallCmd, annotation("hystrix.command.execution", "fallback"))));
    // no more traces
    verifier.verifyTraceCount(0);
}
Also used : Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 70 with PluginTestVerifier

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

the class HystrixCommand_1_4_3_to_1_5_2_IT method testExecutionException.

@Test
public void testExecutionException() throws Exception {
    Exception expectedException = new RuntimeException("expected");
    executeThrowExceptionCommand(expectedException);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method queue = HystrixCommand.class.getMethod("queue");
    Class<?> executionObservableClazz = Class.forName(EXECUTION_OBSERVABLE_INNER_CLASS);
    Method executionObservableCallCmd = executionObservableClazz.getDeclaredMethod("call", Subscriber.class);
    Class<?> fallbackObservableClazz = Class.forName(FALLBACK_OBSERVABLE_INNER_CLASS);
    Method fallbackObservableCallCmd = fallbackObservableClazz.getDeclaredMethod("call", Subscriber.class);
    ExpectedTrace expectedFallbackTrace;
    try {
        // We record the cause of the fallback by invoking AbstractCommand.getExecutionException() added in 1.4.22
        HystrixCommand.class.getMethod("getExecutionException");
        expectedFallbackTrace = Expectations.event("HYSTRIX_COMMAND_INTERNAL", fallbackObservableCallCmd, annotation("hystrix.command.execution", "fallback"), annotation("hystrix.command.fallback.cause", expectedException.toString()));
    } catch (NoSuchMethodException e) {
        // pre 1.4.22
        expectedFallbackTrace = Expectations.event("HYSTRIX_COMMAND_INTERNAL", fallbackObservableCallCmd, annotation("hystrix.command.execution", "fallback"));
    }
    verifier.verifyTrace(Expectations.async(Expectations.event("HYSTRIX_COMMAND", queue, annotation("hystrix.command", ThrowExceptionCommand.class.getSimpleName())), Expectations.event("ASYNC", "Asynchronous Invocation"), Expectations.event("HYSTRIX_COMMAND_INTERNAL", executionObservableCallCmd, annotation("hystrix.command.execution", "run")), expectedFallbackTrace));
    // no more traces
    verifier.verifyTraceCount(0);
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) 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