本文整理汇总了Java中org.springframework.orm.ibatis.SqlMapClientTemplate类的典型用法代码示例。如果您正苦于以下问题:Java SqlMapClientTemplate类的具体用法?Java SqlMapClientTemplate怎么用?Java SqlMapClientTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlMapClientTemplate类属于org.springframework.orm.ibatis包,在下文中一共展示了SqlMapClientTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteShouldBeTraced
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void deleteShouldBeTraced() throws Exception {
// Given
final String deleteId = "deleteId";
SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
// When
clientTemplate.delete(deleteId);
clientTemplate.delete(deleteId, new Object());
clientTemplate.delete(deleteId, new Object(), 0);
// Then
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
Method delete1 = SqlMapClientTemplate.class.getDeclaredMethod("delete", String.class);
Method delete2 = SqlMapClientTemplate.class.getDeclaredMethod("delete", String.class, Object.class);
Method delete3 = SqlMapClientTemplate.class.getDeclaredMethod("delete", String.class, Object.class, int.class);
verifier.verifyTrace(event("IBATIS_SPRING", delete1, Expectations.cachedArgs(deleteId)));
verifier.verifyTrace(event("IBATIS_SPRING", delete2, Expectations.cachedArgs(deleteId)));
verifier.verifyTrace(event("IBATIS_SPRING", delete3, Expectations.cachedArgs(deleteId)));
}
示例2: updateShouldBeTraced
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@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)));
}
示例3: queryForListShouldBeTraced
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@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)));
}
示例4: queryForMapShouldBeTraced
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void queryForMapShouldBeTraced() throws Exception {
// Given
final String queryForMapId = "queryForMapId";
SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
// When
clientTemplate.queryForMap(queryForMapId, new Object(), "key");
clientTemplate.queryForMap(queryForMapId, new Object(), "key", "value");
// Then
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
Method queryForMap1 = SqlMapClientTemplate.class.getDeclaredMethod("queryForMap", String.class, Object.class,
String.class);
Method queryForMap2 = SqlMapClientTemplate.class.getDeclaredMethod("queryForMap", String.class, Object.class,
String.class, String.class);
verifier.verifyTrace(event("IBATIS_SPRING", queryForMap1, Expectations.cachedArgs(queryForMapId)));
verifier.verifyTrace(event("IBATIS_SPRING", queryForMap2, Expectations.cachedArgs(queryForMapId)));
}
示例5: queryForObjectShouldBeTraced
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@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)));
}
示例6: queryForPaginagedListShouldBeTraced
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@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)));
}
示例7: setup
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Before
public void setup() throws Exception {
transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
goCache = new StubGoCache(new TestTransactionSynchronizationManager());
goCache.clear();
mockTemplate = mock(SqlMapClientTemplate.class);
repository = mock(MaterialRepository.class);
environmentVariableDao = mock(EnvironmentVariableDao.class);
mockSessionFactory = mock(SessionFactory.class);
repository = mock(MaterialRepository.class);
transactionTemplate = mock(TransactionTemplate.class);
configFileDao = mock(GoConfigDao.class);
pipelineDao = new PipelineSqlMapDao(null, repository, goCache, environmentVariableDao, transactionTemplate, null,
transactionSynchronizationManager, null, configFileDao, mock(Database.class), mockSessionFactory);
pipelineDao.setSqlMapClientTemplate(mockTemplate);
session = mock(Session.class);
when(mockSessionFactory.getCurrentSession()).thenReturn(session);
when(configFileDao.load()).thenReturn(GoConfigMother.defaultCruiseConfig());
}
示例8: setup
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Before
public void setup() throws Exception {
transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
goCache = new StubGoCache(new TestTransactionSynchronizationManager());
goCache.clear();
mockTemplate = mock(SqlMapClientTemplate.class);
repository = mock(MaterialRepository.class);
environmentVariableDao = mock(EnvironmentVariableDao.class);
mockSessionFactory = mock(SessionFactory.class);
repository = mock(MaterialRepository.class);
transactionTemplate = mock(TransactionTemplate.class);
configFileDao = mock(GoConfigDao.class);
pipelineStateDao = new PipelineStateDao(null, repository, goCache, environmentVariableDao, transactionTemplate, null,
transactionSynchronizationManager, null, configFileDao, mock(Database.class), mockSessionFactory);
pipelineStateDao.setSqlMapClientTemplate(mockTemplate);
session = mock(Session.class);
when(mockSessionFactory.getCurrentSession()).thenReturn(session);
when(configFileDao.load()).thenReturn(GoConfigMother.defaultCruiseConfig());
}
示例9: setUp
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Before
public void setUp() {
goCache = new StubGoCache(new TestTransactionSynchronizationManager());
sqlMapClientTemplate = mock(SqlMapClientTemplate.class);
stageSqlMapDao = new StageSqlMapDao(mock(JobInstanceSqlMapDao.class), new Cache(true, false, false), mock(TransactionTemplate.class), mock(SqlMapClient.class), goCache,
mock(TransactionSynchronizationManager.class), mock(SystemEnvironment.class), null);
stageSqlMapDao.setSqlMapClientTemplate(sqlMapClientTemplate);
cloner = mock(Cloner.class);
ReflectionUtil.setField(stageSqlMapDao, "cloner", cloner);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
return invocationOnMock.getArguments()[0];
}
}).when(cloner).deepClone(anyObject());
}
示例10: getTotalStageCountForChart_shouldInvalidateTheCountCacheOnStageSchedule
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getTotalStageCountForChart_shouldInvalidateTheCountCacheOnStageSchedule() throws SQLException {
SqlMapClientTemplate mockClient = mock(SqlMapClientTemplate.class);
stageDao.setSqlMapClientTemplate(mockClient);
Map<String, Object> toGet = arguments("pipelineName", "maar").and("stageName", "khoon").asMap();
when(mockClient.queryForObject("getTotalStageCountForChart", toGet)).thenReturn(3).thenReturn(4);
assertThat(stageDao.getTotalStageCountForChart("maar", "khoon"), is(3));//Should prime the cache
Stage stage = new Stage("khoon", new JobInstances(), "foo", "manual", new TimeProvider());
Pipeline pipeline = new Pipeline("maar", "${COUNT}", BuildCause.createWithEmptyModifications(), stage);
pipeline.setId(1);
stageDao.save(pipeline, stage);//Should Invalidate the cache
assertThat(stageDao.getTotalStageCountForChart("maar", "khoon"), is(4));//should refetch
verify(mockClient, times(2)).queryForObject("getTotalStageCountForChart", toGet);
}
示例11: getTotalStageCountForChart_shouldInvalidateTheCountCacheOnStageUpdate
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getTotalStageCountForChart_shouldInvalidateTheCountCacheOnStageUpdate() throws SQLException {
SqlMapClientTemplate mockClient = mock(SqlMapClientTemplate.class);
stageDao.setSqlMapClientTemplate(mockClient);
Map<String, Object> toGet = arguments("pipelineName", "maar").and("stageName", "khoon").asMap();
when(mockClient.queryForObject("getTotalStageCountForChart", toGet)).thenReturn(3).thenReturn(4);
assertThat(stageDao.getTotalStageCountForChart("maar", "khoon"), is(3));//Should prime the cache
Stage stage = new Stage("khoon", new JobInstances(), "foo", "manual", new TimeProvider());
stage.setIdentifier(new StageIdentifier("maar/2/khoon/1"));
updateResultInTransaction(stage, StageResult.Cancelled);//Should Invalidate the cache
assertThat(stageDao.getTotalStageCountForChart("maar", "khoon"), is(4));//should refetch
verify(mockClient, times(2)).queryForObject("getTotalStageCountForChart", toGet);
}
示例12: getAllRunsOfStageForPipelineInstance_shouldCacheAllTheStages
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getAllRunsOfStageForPipelineInstance_shouldCacheAllTheStages() {
SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);
Stage first = StageMother.passedStageInstance("pipeline", "stage", 1, "job", new Date());
Stage second = StageMother.passedStageInstance("pipeline", "stage", 2, "job", new Date());
Stage third = StageMother.passedStageInstance("pipeline", "stage", 3, "job", new Date());
List<Stage> expected = asList(third, second, first);
stageDao.setSqlMapClientTemplate(mockTemplate);
when(mockTemplate.queryForList(eq("getAllRunsOfStageForPipelineInstance"), any())).thenReturn(expected);
Stages actual = stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage");
assertEquals(expected, actual);
assertThat(expected == actual, is(false));
assertThat(expected.get(0) == actual.get(0), is(false));
stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage");
verify(mockTemplate, times(1)).queryForList(eq("getAllRunsOfStageForPipelineInstance"), any());
}
示例13: getAllRunsOfStageForPipelineInstance_shouldClearCacheOnJobStateChange
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getAllRunsOfStageForPipelineInstance_shouldClearCacheOnJobStateChange() {
SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);
Stage first = StageMother.passedStageInstance("pipeline", "stage", 1, "job", new Date());
Stage second = StageMother.passedStageInstance("pipeline", "stage", 2, "job", new Date());
Stage third = StageMother.passedStageInstance("pipeline", "stage", 3, "job", new Date());
List<Stage> expected = asList(third, second, first);
stageDao.setSqlMapClientTemplate(mockTemplate);
when(mockTemplate.queryForList(eq("getAllRunsOfStageForPipelineInstance"), any())).thenReturn(expected);
assertThat(stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage"), is(expected));
stageDao.jobStatusChanged(first.getFirstJob());
assertThat(stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage"), is(expected));
stageDao.jobStatusChanged(second.getFirstJob());
assertThat(stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage"), is(expected));
verify(mockTemplate, times(3)).queryForList(eq("getAllRunsOfStageForPipelineInstance"), any());
}
示例14: getAllRunsOfStageForPipelineInstance_shouldRemoveFromCacheOnStageSave
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getAllRunsOfStageForPipelineInstance_shouldRemoveFromCacheOnStageSave() {
SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);
Stage newStage = StageMother.passedStageInstance("pipeline", "stage", 2, "job", new Date());
Stage first = StageMother.passedStageInstance("pipeline", "stage", 1, "job", new Date());
List<Stage> expected = asList(first);
List<Stage> expectedSecondTime = asList(first, newStage);
stageDao.setSqlMapClientTemplate(mockTemplate);
when(mockTemplate.queryForList(eq("getAllRunsOfStageForPipelineInstance"), any())).thenReturn(expected, expectedSecondTime);
stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage");
Pipeline pipeline = PipelineMother.pipeline("pipeline");
pipeline.setCounter(1);
stageDao.save(pipeline, newStage);//should remove first from cache
Stages actual = stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage");
assertThat(actual.size(), is(2));
assertThat(actual, hasItem(newStage));
assertThat(actual, hasItem(first));
verify(mockTemplate, times(2)).queryForList(eq("getAllRunsOfStageForPipelineInstance"), any());
}
示例15: getAllRunsOfStageForPipelineInstance_shouldRemoveFromCacheOnStageStatusChange
import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getAllRunsOfStageForPipelineInstance_shouldRemoveFromCacheOnStageStatusChange() {
SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);
Stage newStage = StageMother.passedStageInstance("pipeline", "stage", 2, "job", new Date());
Stage first = StageMother.passedStageInstance("pipeline", "stage", 1, "job", new Date());
List<Stage> expected = asList(first);
List<Stage> expectedSecondTime = asList(first, newStage);
stageDao.setSqlMapClientTemplate(mockTemplate);
when(mockTemplate.queryForList(eq("getAllRunsOfStageForPipelineInstance"), any())).thenReturn(expected, expectedSecondTime);
stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage");
Pipeline pipeline = PipelineMother.pipeline("pipeline");
pipeline.setCounter(1);
updateResultInTransaction(newStage, StageResult.Passed);
Stages actual = stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage");
assertThat(actual.size(), is(2));
assertThat(actual, hasItem(newStage));
assertThat(actual, hasItem(first));
verify(mockTemplate, times(2)).queryForList(eq("getAllRunsOfStageForPipelineInstance"), any());
}