Search in sources :

Example 61 with PluginTestVerifier

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

the class DubboConsumerIT method testConsumerMonitor.

@Test
public void testConsumerMonitor() {
    abstractClusterInvoker = new FailoverClusterInvoker(directory);
    when(abstractClusterInvoker.getInterface()).thenReturn(MonitorService.class);
    try {
        abstractClusterInvoker.invoke(rpcInvocation);
    } catch (RpcException ignore) {
    // ignore
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTraceCount(0);
}
Also used : FailoverClusterInvoker(com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker) RpcException(com.alibaba.dubbo.rpc.RpcException) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 62 with PluginTestVerifier

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

the class SqlMapClientTemplateIT method methodCallWithNullSqlIdShouldOnlyTraceMethodName.

@Test
public void methodCallWithNullSqlIdShouldOnlyTraceMethodName() throws Exception {
    // Given
    SqlMapClientTemplate template = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
    // When
    template.insert(null);
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method insert = SqlMapClientTemplate.class.getDeclaredMethod("insert", String.class);
    verifier.verifyTrace(event("IBATIS_SPRING", insert));
}
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 63 with PluginTestVerifier

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

the class SqlMapClientTemplateIT method queryForObjectShouldBeTraced.

@Test
public void queryForObjectShouldBeTraced() throws Exception {
    // Given
    final String queryForObjectId = "queryForObjectId";
    SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
    // When
    clientTemplate.queryForObject(queryForObjectId);
    clientTemplate.queryForObject(queryForObjectId, new Object());
    clientTemplate.queryForObject(queryForObjectId, new Object(), new Object());
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method queryForObject1 = SqlMapClientTemplate.class.getDeclaredMethod("queryForObject", String.class);
    Method queryForObject2 = SqlMapClientTemplate.class.getDeclaredMethod("queryForObject", String.class, Object.class);
    Method queryForObject3 = SqlMapClientTemplate.class.getDeclaredMethod("queryForObject", String.class, Object.class, Object.class);
    verifier.verifyTrace(event("IBATIS_SPRING", queryForObject1, Expectations.cachedArgs(queryForObjectId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForObject2, Expectations.cachedArgs(queryForObjectId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForObject3, Expectations.cachedArgs(queryForObjectId)));
}
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 64 with PluginTestVerifier

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

the class SqlMapClientTemplateIT method queryForPaginagedListShouldBeTraced.

@Test
@SuppressWarnings("deprecation")
public void queryForPaginagedListShouldBeTraced() throws Exception {
    // Given
    final String queryForPaginatedListId = "queryForPaginatedListId";
    // to emulate lazy-loading, otherwise exception is thrown
    TransactionManager mockTxManager = mock(TransactionManager.class);
    when(this.mockSqlMapExecutorDelegate.getTxManager()).thenReturn(mockTxManager);
    SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
    // When
    clientTemplate.queryForPaginatedList(queryForPaginatedListId, 1);
    clientTemplate.queryForPaginatedList(queryForPaginatedListId, new Object(), 1);
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method queryForPaginatedList1 = SqlMapClientTemplate.class.getDeclaredMethod("queryForPaginatedList", String.class, int.class);
    Method queryForPaginatedList2 = SqlMapClientTemplate.class.getDeclaredMethod("queryForPaginatedList", String.class, Object.class, int.class);
    verifier.verifyTrace(event("IBATIS_SPRING", queryForPaginatedList1, Expectations.cachedArgs(queryForPaginatedListId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForPaginatedList2, Expectations.cachedArgs(queryForPaginatedListId)));
}
Also used : TransactionManager(com.ibatis.sqlmap.engine.transaction.TransactionManager) SqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 65 with PluginTestVerifier

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

the class SqlMapClientTemplateIT method queryForListShouldBeTraced.

@Test
public void queryForListShouldBeTraced() throws Exception {
    // Given
    final String queryForListId = "queryForListId";
    SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
    // When
    clientTemplate.queryForList(queryForListId);
    clientTemplate.queryForList(queryForListId, new Object());
    clientTemplate.queryForList(queryForListId, 0, 1);
    clientTemplate.queryForList(queryForListId, new Object(), 0, 1);
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method queryForList1 = SqlMapClientTemplate.class.getDeclaredMethod("queryForList", String.class);
    Method queryForList2 = SqlMapClientTemplate.class.getDeclaredMethod("queryForList", String.class, Object.class);
    Method queryForList3 = SqlMapClientTemplate.class.getDeclaredMethod("queryForList", String.class, int.class, int.class);
    Method queryForList4 = SqlMapClientTemplate.class.getDeclaredMethod("queryForList", String.class, Object.class, int.class, int.class);
    verifier.verifyTrace(event("IBATIS_SPRING", queryForList1, Expectations.cachedArgs(queryForListId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForList2, Expectations.cachedArgs(queryForListId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForList3, Expectations.cachedArgs(queryForListId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForList4, Expectations.cachedArgs(queryForListId)));
}
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)

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