本文整理汇总了Java中com.ibatis.sqlmap.client.SqlMapSession类的典型用法代码示例。如果您正苦于以下问题:Java SqlMapSession类的具体用法?Java SqlMapSession怎么用?Java SqlMapSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlMapSession类属于com.ibatis.sqlmap.client包,在下文中一共展示了SqlMapSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: exceptionsThrownShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void exceptionsThrownShouldBeTraced() throws Exception {
// Given
final String exceptionInsertId = "insertShouldThrowNPE";
when(this.mockSqlMapExecutorDelegate.insert(mockSessionScope, exceptionInsertId, null)).thenThrow(new NullPointerException());
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
// When
try {
sqlMapSession.insert(exceptionInsertId);
fail("sqlMapSession.insert() should throw NullPointerException");
} catch (NullPointerException e) {
// Then
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
assertThat(spanEvents.size(), is(1));
final SpanEventBo exceptionSpanEventBo = spanEvents.get(0);
assertThat(exceptionSpanEventBo.hasException(), is(true));
assertThat(exceptionSpanEventBo.getExceptionId(), not(0));
}
}
开发者ID:masonmei,项目名称:apm-agent,代码行数:20,代码来源:SqlMapSessionImplModifierTest.java
示例2: nullParametersShouldNotBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void nullParametersShouldNotBeTraced() throws Exception {
// Given
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
// When
sqlMapSession.insert(null);
sqlMapSession.queryForList(null);
// Then
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
assertThat(spanEvents.size(), is(2));
// Check Method
final SpanEventBo insertSpanEventBo = spanEvents.get(0);
final SpanEventBo queryForListSpanEventBo = spanEvents.get(1);
assertThat(insertSpanEventBo.getApiId(), not(0));
assertThat(queryForListSpanEventBo.getApiId(), not(0));
assertThat(insertSpanEventBo.getApiId(), not(queryForListSpanEventBo.getApiId()));
// Check Parameter
assertNull(insertSpanEventBo.getAnnotationBoList());
assertNull(queryForListSpanEventBo.getAnnotationBoList());
}
开发者ID:masonmei,项目名称:apm-agent,代码行数:23,代码来源:SqlMapSessionImplModifierTest.java
示例3: sameApiCallsShouldHaveTheSameApiId
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void sameApiCallsShouldHaveTheSameApiId() throws Exception {
// Given
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
// When
sqlMapSession.insert("insertA");
sqlMapSession.insert("insertB");
// Then
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
assertThat(spanEvents.size(), is(2));
// Check Method
final SpanEventBo insertASpanEventBo = spanEvents.get(0);
final SpanEventBo insertBSpanEventBo = spanEvents.get(1);
assertThat(insertASpanEventBo.getApiId(), not(0));
assertThat(insertBSpanEventBo.getApiId(), not(0));
assertThat(insertASpanEventBo.getApiId(), is(insertBSpanEventBo.getApiId()));
}
开发者ID:masonmei,项目名称:apm-agent,代码行数:20,代码来源:SqlMapSessionImplModifierTest.java
示例4: queryForListShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void queryForListShouldBeTraced() throws Exception {
// Given
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
// When
sqlMapSession.queryForList("abc");
// Then
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
assertThat(spanEvents.size(), is(1));
// Check Method
final SpanEventBo apiCallSpanEventBo = spanEvents.get(0);
assertThat(apiCallSpanEventBo.getApiId(), not(0));
// Check Parameter
final List<AnnotationBo> annotationBoList = apiCallSpanEventBo.getAnnotationBoList();
assertThat(annotationBoList.size(), is(1));
final AnnotationBo parameterAnnotationBo = annotationBoList.get(0);
assertThat(parameterAnnotationBo.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));
}
开发者ID:masonmei,项目名称:apm-agent,代码行数:22,代码来源:SqlMapSessionImplModifierTest.java
示例5: queryForObjectShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void queryForObjectShouldBeTraced() throws Exception {
// Given
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
// When
sqlMapSession.queryForObject("abrgrgfdaghertah", new Object());
// Then
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
assertThat(spanEvents.size(), is(1));
// Check Method
final SpanEventBo apiCallSpanEventBo = spanEvents.get(0);
assertThat(apiCallSpanEventBo.getApiId(), not(0));
// Check Parameter
final List<AnnotationBo> annotationBoList = apiCallSpanEventBo.getAnnotationBoList();
assertThat(annotationBoList.size(), is(1));
final AnnotationBo parameterAnnotationBo = annotationBoList.get(0);
assertThat(parameterAnnotationBo.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));
}
开发者ID:masonmei,项目名称:apm-agent,代码行数:22,代码来源:SqlMapSessionImplModifierTest.java
示例6: closeShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Ignore // Changed to trace only query operations
@Test
public void closeShouldBeTraced() throws Exception {
// Given
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
// When
sqlMapSession.close();
// Then
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
assertThat(spanEvents.size(), is(1));
// Check Method
final SpanEventBo closeSpanEventBo = spanEvents.get(0);
assertThat(closeSpanEventBo.getApiId(), not(0));
// Check Parameter
assertNull(closeSpanEventBo.getAnnotationBoList());
}
开发者ID:masonmei,项目名称:apm-agent,代码行数:19,代码来源:SqlMapSessionImplModifierTest.java
示例7: testSqlMapClientTemplateWithNestedSqlMapSession
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void testSqlMapClientTemplateWithNestedSqlMapSession() throws SQLException {
DataSource ds = mock(DataSource.class);
final Connection con = mock(Connection.class);
final SqlMapSession session = mock(SqlMapSession.class);
SqlMapClient client = mock(SqlMapClient.class);
given(client.openSession()).willReturn(session);
given(session.getCurrentConnection()).willReturn(con);
SqlMapClientTemplate template = new SqlMapClientTemplate();
template.setDataSource(ds);
template.setSqlMapClient(client);
template.afterPropertiesSet();
Object result = template.execute(new SqlMapClientCallback() {
@Override
public Object doInSqlMapClient(SqlMapExecutor executor) {
assertTrue(executor == session);
return "done";
}
});
assertEquals("done", result);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:SqlMapClientTests.java
示例8: testQueryForObjectOnSqlMapSession
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void testQueryForObjectOnSqlMapSession() throws SQLException {
DataSource ds = mock(DataSource.class);
Connection con = mock(Connection.class);
SqlMapClient client = mock(SqlMapClient.class);
SqlMapSession session = mock(SqlMapSession.class);
given(ds.getConnection()).willReturn(con);
given(client.getDataSource()).willReturn(ds);
given(client.openSession()).willReturn(session);
given(session.queryForObject("myStatement", "myParameter")).willReturn("myResult");
SqlMapClientTemplate template = new SqlMapClientTemplate();
template.setSqlMapClient(client);
template.afterPropertiesSet();
assertEquals("myResult", template.queryForObject("myStatement", "myParameter"));
verify(con).close();
verify(session).setUserConnection(con);
verify(session).close();
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:22,代码来源:SqlMapClientTests.java
示例9: executeWith
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
protected Object executeWith(Connection connection, SqlMapClientCallback action) {
SqlMapSession session = getSqlMapClient().openSession();
try {
try {
session.setUserConnection(connection);
} catch (SQLException e) {
throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", e);
}
try {
return action.doInSqlMapClient(session);
} catch (SQLException ex) {
throw new SQLErrorCodeSQLExceptionTranslator().translate("SqlMapClient operation",
null, ex);
}
} finally {
session.close();
}
}
开发者ID:alibaba,项目名称:cobarclient,代码行数:19,代码来源:DefaultConcurrentRequestProcessor.java
示例10: run
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Override
public void run() {
try {
SqlMapSession session = sqlMap.openSession();
List list = session.queryForList(statementName, null);
int firstId = System.identityHashCode(list);
list = session.queryForList(statementName, null);
int secondId = System.identityHashCode(list);
// assertEquals(firstId, secondId);
results.put("id", new Integer(System.identityHashCode(list)));
results.put("list", list);
session.close();
} catch (SQLException e) {
throw new RuntimeException("Error. Cause: " + e);
}
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:17,代码来源:CacheStatementTest.java
示例11: insertShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void insertShouldBeTraced() throws Exception {
// Given
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
// When
sqlMapSession.insert("insertId");
sqlMapSession.insert("insertId", new Object());
// Then
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
assertThat(spanEvents.size(), is(2));
// Check Method
final SpanEventBo insertWith1ArgSpanEventBo = spanEvents.get(0);
final SpanEventBo insertWith2ArgSpanEventBo = spanEvents.get(1);
assertThat(insertWith1ArgSpanEventBo.getApiId(), not(0));
assertThat(insertWith2ArgSpanEventBo.getApiId(), not(0));
assertThat(insertWith1ArgSpanEventBo.getApiId(), not(insertWith2ArgSpanEventBo.getApiId()));
// Check Parameter
final List<AnnotationBo> insertWith1ArgAnnotations = insertWith1ArgSpanEventBo.getAnnotationBoList();
assertThat(insertWith1ArgAnnotations.size(), is(1));
final AnnotationBo insertWith1ArgParameterAnnotation = insertWith1ArgAnnotations.get(0);
assertThat(insertWith1ArgParameterAnnotation.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));
final List<AnnotationBo> insertWith2ArgAnnotations = insertWith2ArgSpanEventBo.getAnnotationBoList();
assertThat(insertWith2ArgAnnotations.size(), is(1));
final AnnotationBo insertWith2ArgAnnotation = insertWith2ArgAnnotations.get(0);
assertThat(insertWith2ArgAnnotation.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));
}
开发者ID:masonmei,项目名称:apm-agent,代码行数:31,代码来源:SqlMapSessionImplModifierTest.java
示例12: deleteShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void deleteShouldBeTraced() throws Exception {
// Given
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
// When
sqlMapSession.delete("deleteId");
sqlMapSession.delete("deleteId", new Object());
// Then
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
assertThat(spanEvents.size(), is(2));
// Check Method
final SpanEventBo deleteWith1ArgSpanEvent = spanEvents.get(0);
final SpanEventBo deleteWith2ArgSpanEvent = spanEvents.get(1);
assertThat(deleteWith1ArgSpanEvent.getApiId(), not(0));
assertThat(deleteWith2ArgSpanEvent.getApiId(), not(0));
assertThat(deleteWith1ArgSpanEvent.getApiId(), not(deleteWith2ArgSpanEvent.getApiId()));
// Check Parameter
final List<AnnotationBo> deleteWith1ArgAnnotations = deleteWith1ArgSpanEvent.getAnnotationBoList();
assertThat(deleteWith1ArgAnnotations.size(), is(1));
final AnnotationBo deleteWith1ArgParameterAnnotation = deleteWith1ArgAnnotations.get(0);
assertThat(deleteWith1ArgParameterAnnotation.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));
final List<AnnotationBo> deleteWith2ArgAnnotations = deleteWith2ArgSpanEvent.getAnnotationBoList();
assertThat(deleteWith2ArgAnnotations.size(), is(1));
final AnnotationBo deleteWith2ArgAnnotation = deleteWith2ArgAnnotations.get(0);
assertThat(deleteWith2ArgAnnotation.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));
}
开发者ID:masonmei,项目名称:apm-agent,代码行数:30,代码来源:SqlMapSessionImplModifierTest.java
示例13: updateShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void updateShouldBeTraced() throws Exception {
// Given
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
// When
sqlMapSession.update("updateId");
sqlMapSession.update("updateId", new Object());
// Then
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
assertThat(spanEvents.size(), is(2));
// Check Method
final SpanEventBo updateWith1ArgSpanEvent = spanEvents.get(0);
final SpanEventBo updateWith2ArgSpanEvent = spanEvents.get(1);
assertThat(updateWith1ArgSpanEvent.getApiId(), not(0));
assertThat(updateWith2ArgSpanEvent.getApiId(), not(0));
assertThat(updateWith1ArgSpanEvent.getApiId(), not(updateWith2ArgSpanEvent.getApiId()));
// Check Parameter
final List<AnnotationBo> updateWith1ArgAnnotations = updateWith1ArgSpanEvent.getAnnotationBoList();
assertThat(updateWith1ArgAnnotations.size(), is(1));
final AnnotationBo updateWith1ArgParameterAnnotation = updateWith1ArgAnnotations.get(0);
assertThat(updateWith1ArgParameterAnnotation.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));
final List<AnnotationBo> updateWith2ArgAnnotations = updateWith2ArgSpanEvent.getAnnotationBoList();
assertThat(updateWith2ArgAnnotations.size(), is(1));
final AnnotationBo updateWith2ArgAnnotation = updateWith2ArgAnnotations.get(0);
assertThat(updateWith2ArgAnnotation.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));
}
开发者ID:masonmei,项目名称:apm-agent,代码行数:31,代码来源:SqlMapSessionImplModifierTest.java
示例14: transactionsShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Ignore // Changed to trace only query operations
@Test
public void transactionsShouldBeTraced() throws Exception {
// Given
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
// When
sqlMapSession.startTransaction();
sqlMapSession.commitTransaction();
sqlMapSession.endTransaction();
// Then
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
assertThat(spanEvents.size(), is(3));
// Check Method
final SpanEventBo startTransactionSpanEventBo = spanEvents.get(0);
final SpanEventBo commitTransactionSpanEventBo = spanEvents.get(1);
final SpanEventBo endTransactionSpanEventBo = spanEvents.get(2);
assertThat(startTransactionSpanEventBo.getApiId(), not(0));
assertThat(commitTransactionSpanEventBo.getApiId(), not(0));
assertThat(endTransactionSpanEventBo.getApiId(), not(0));
assertThat(startTransactionSpanEventBo.getApiId(), not(commitTransactionSpanEventBo.getApiId()));
assertThat(commitTransactionSpanEventBo.getApiId(), not(endTransactionSpanEventBo.getApiId()));
assertThat(endTransactionSpanEventBo.getApiId(), not(startTransactionSpanEventBo.getApiId()));
// Check Parameter
assertNull(startTransactionSpanEventBo.getAnnotationBoList());
assertNull(commitTransactionSpanEventBo.getAnnotationBoList());
assertNull(endTransactionSpanEventBo.getAnnotationBoList());
}
开发者ID:masonmei,项目名称:apm-agent,代码行数:32,代码来源:SqlMapSessionImplModifierTest.java
示例15: testSqlMapClientTemplate
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void testSqlMapClientTemplate() throws SQLException {
DataSource ds = mock(DataSource.class);
Connection con = mock(Connection.class);
final SqlMapSession session = mock(SqlMapSession.class);
SqlMapClient client = mock(SqlMapClient.class);
given(ds.getConnection()).willReturn(con);
given(client.openSession()).willReturn(session);
SqlMapClientTemplate template = new SqlMapClientTemplate();
template.setDataSource(ds);
template.setSqlMapClient(client);
template.afterPropertiesSet();
Object result = template.execute(new SqlMapClientCallback() {
@Override
public Object doInSqlMapClient(SqlMapExecutor executor) {
assertTrue(executor == session);
return "done";
}
});
assertEquals("done", result);
verify(con).close();
verify(session).setUserConnection(con);
verify(session).close();
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:28,代码来源:SqlMapClientTests.java
示例16: testSessionUserConnection
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
public void testSessionUserConnection() throws SQLException {
DataSource ds = sqlMap.getDataSource();
Connection conn = ds.getConnection();
((SqlMapClientImpl) sqlMap).getDelegate().getTxManager().getConfig().setDataSource(null);
SqlMapSession session = sqlMap.openSession(conn);
Account account = (Account) session.queryForObject("getAccountViaColumnName", new Integer(1));
session.close();
conn.close();
assertAccount1(account);
((SqlMapClientImpl) sqlMap).getDelegate().getTxManager().getConfig().setDataSource(ds);
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:12,代码来源:StatementTest.java
示例17: methodCallWithNullSqlIdShouldOnlyTraceMethodName
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void methodCallWithNullSqlIdShouldOnlyTraceMethodName() throws Exception {
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
super.testAndVerifyInsertWithNullSqlId(sqlMapSession);
}
开发者ID:naver,项目名称:pinpoint,代码行数:6,代码来源:SqlMapSessionIT.java
示例18: insertShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void insertShouldBeTraced() throws Exception {
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
super.testAndVerifyInsert(sqlMapSession);
}
开发者ID:naver,项目名称:pinpoint,代码行数:6,代码来源:SqlMapSessionIT.java
示例19: deleteShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void deleteShouldBeTraced() throws Exception {
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
super.testAndVerifyDelete(sqlMapSession);
}
开发者ID:naver,项目名称:pinpoint,代码行数:6,代码来源:SqlMapSessionIT.java
示例20: updateShouldBeTraced
import com.ibatis.sqlmap.client.SqlMapSession; //导入依赖的package包/类
@Test
public void updateShouldBeTraced() throws Exception {
SqlMapSession sqlMapSession = new SqlMapSessionImpl(this.sqlMapClient);
super.testAndVerifyUpdate(sqlMapSession);
}
开发者ID:naver,项目名称:pinpoint,代码行数:6,代码来源:SqlMapSessionIT.java
注:本文中的com.ibatis.sqlmap.client.SqlMapSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论