Search in sources :

Example 31 with SqlMapClientTemplate

use of org.springframework.orm.ibatis.SqlMapClientTemplate 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 32 with SqlMapClientTemplate

use of org.springframework.orm.ibatis.SqlMapClientTemplate 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 33 with SqlMapClientTemplate

use of org.springframework.orm.ibatis.SqlMapClientTemplate 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 34 with SqlMapClientTemplate

use of org.springframework.orm.ibatis.SqlMapClientTemplate 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)

Example 35 with SqlMapClientTemplate

use of org.springframework.orm.ibatis.SqlMapClientTemplate 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)

Aggregations

SqlMapClientTemplate (org.springframework.orm.ibatis.SqlMapClientTemplate)35 Test (org.junit.Test)34 PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)8 Method (java.lang.reflect.Method)8 StageHistoryEntry (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry)2 StageHistoryPage (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryPage)2 TransactionManager (com.ibatis.sqlmap.engine.transaction.TransactionManager)1 Cache (com.opensymphony.oscache.base.Cache)1 Cloner (com.rits.cloning.Cloner)1 FeedEntry (com.thoughtworks.go.domain.feed.FeedEntry)1 StageFeedEntry (com.thoughtworks.go.domain.feed.stage.StageFeedEntry)1 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)1 GoCache (com.thoughtworks.go.server.cache.GoCache)1 StubGoCache (com.thoughtworks.go.server.service.StubGoCache)1 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)1 Before (org.junit.Before)1 Matchers.anyObject (org.mockito.Matchers.anyObject)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1