当前位置: 首页>>代码示例>>Java>>正文


Java SimpleTransactionStatus类代码示例

本文整理汇总了Java中org.springframework.transaction.support.SimpleTransactionStatus的典型用法代码示例。如果您正苦于以下问题:Java SimpleTransactionStatus类的具体用法?Java SimpleTransactionStatus怎么用?Java SimpleTransactionStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleTransactionStatus类属于org.springframework.transaction.support包,在下文中一共展示了SimpleTransactionStatus类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertAfterTestMethodWithTransactionalTestMethod

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
private void assertAfterTestMethodWithTransactionalTestMethod(Class<? extends Invocable> clazz) throws Exception {
	BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz);
	Invocable instance = clazz.newInstance();
	given(testContext.getTestInstance()).willReturn(instance);
	given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("transactionalTest"));

	given(tm.getTransaction(BDDMockito.any(TransactionDefinition.class))).willReturn(new SimpleTransactionStatus());

	assertFalse(instance.invoked);
	TransactionContextHolder.removeCurrentTransactionContext();
	listener.beforeTestMethod(testContext);
	listener.afterTestMethod(testContext);
	assertTrue(instance.invoked);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:TransactionalTestExecutionListenerTests.java

示例2: getExecuteTransactionOperations

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
@Override
public TransactionOperations getExecuteTransactionOperations() {
	return new TransactionOperations() {
		@Override
		public <T2> T2 execute(TransactionCallback<T2> action) throws TransactionException {
			return action.doInTransaction(new SimpleTransactionStatus());
		}
	};
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:10,代码来源:SimpleHibernateBatchExecutor.java

示例3: execute

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
@Override
public <T> T execute(TransactionCallback<T> action) throws TransactionException {
	try {
		entityManagerUtils.openEntityManager();
		// We do not  call super() here, no transaction will be opened.
		// Note : it doesn't exist any transaction manager which doesn't open transaction while
		// keeping entity manager open.
		return action.doInTransaction(new SimpleTransactionStatus());
	} finally {
		entityManagerUtils.closeEntityManager();
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:13,代码来源:OpenEntityManagerWithNoTransactionTransactionTemplate.java

示例4: setupTransactionManager

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
private void setupTransactionManager() {
    m_transactionManager = m_easyMockUtils.createMock(PlatformTransactionManager.class);
    TransactionTemplate transactionTemplate = new TransactionTemplate(m_transactionManager);
    m_collectd.setTransactionTemplate(transactionTemplate);
    
    expect(m_transactionManager.getTransaction(isA(TransactionDefinition.class))).andReturn(new SimpleTransactionStatus()).anyTimes();
    m_transactionManager.rollback(isA(TransactionStatus.class));
    expectLastCall().anyTimes();
    m_transactionManager.commit(isA(TransactionStatus.class)); //anyTimes();
    expectLastCall().anyTimes();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:12,代码来源:CollectdTest.java

示例5: shouldNotCorruptCacheIfSaveFailsWhileLocking

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
@Test
public void shouldNotCorruptCacheIfSaveFailsWhileLocking() {
    String pipelineName = UUID.randomUUID().toString();
    Pipeline pipeline = PipelineMother.pipeline(pipelineName, new Stage());
    PipelineState pipelineState = new PipelineState(pipelineName);
    goCache.put(pipelineStateDao.pipelineLockStateCacheKey(pipelineName), pipelineState);

    when(transactionTemplate.execute(any(org.springframework.transaction.support.TransactionCallbackWithoutResult.class))).thenAnswer(new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            org.springframework.transaction.support.TransactionCallbackWithoutResult callback = (org.springframework.transaction.support.TransactionCallbackWithoutResult) invocation.getArguments()[0];
            callback.doInTransaction(new SimpleTransactionStatus());
            return null;
        }
    });
    doThrow(new RuntimeException("could not save!")).when(session).saveOrUpdate(any(PipelineState.class));

    try {
        pipelineStateDao.lockPipeline(pipeline);
        fail("save should have thrown an exception!");
    } catch (Exception e) {
        PipelineState stateFromCache = (PipelineState) goCache.get(pipelineStateDao.pipelineLockStateCacheKey(pipelineName));
        assertThat(stateFromCache.isLocked(), is(false));
        assertThat(stateFromCache.getLockedByPipelineId(), is(0L));
        assertThat(stateFromCache.getLockedBy(), is(nullValue()));
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:28,代码来源:PipelineStateDaoTest.java

示例6: shouldNotCorruptCacheIfSaveFailsWhileUnLocking

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
@Test
public void shouldNotCorruptCacheIfSaveFailsWhileUnLocking() {
    String pipelineName = UUID.randomUUID().toString();
    PipelineState pipelineState = new PipelineState(pipelineName);
    long lockedByPipelineId = 1;
    pipelineState.lock(lockedByPipelineId);
    goCache.put(pipelineStateDao.pipelineLockStateCacheKey(pipelineName), pipelineState);

    when(transactionTemplate.execute(any(org.springframework.transaction.support.TransactionCallbackWithoutResult.class))).thenAnswer(new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            org.springframework.transaction.support.TransactionCallbackWithoutResult callback = (org.springframework.transaction.support.TransactionCallbackWithoutResult) invocation.getArguments()[0];
            callback.doInTransaction(new SimpleTransactionStatus());
            return null;
        }
    });
    doThrow(new RuntimeException("could not save!")).when(session).saveOrUpdate(any(PipelineState.class));

    try {
        pipelineStateDao.unlockPipeline(pipelineName);
        fail("save should have thrown an exception!");
    } catch (Exception e) {
        PipelineState stateFromCache = (PipelineState) goCache.get(pipelineStateDao.pipelineLockStateCacheKey(pipelineName));
        assertThat(stateFromCache.isLocked(), is(true));
        assertThat(stateFromCache.getLockedByPipelineId(), is(lockedByPipelineId));
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:28,代码来源:PipelineStateDaoTest.java

示例7: getTransaction

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
@Override
public TransactionStatus getTransaction(TransactionDefinition definition)
                    throws TransactionException {
      return new SimpleTransactionStatus();
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:6,代码来源:TransactionManager.java

示例8: execute

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
@Override
public <T> T execute(TransactionCallback<T> action) throws TransactionException {
    return action.doInTransaction(new SimpleTransactionStatus());
}
 
开发者ID:yandex-money,项目名称:db-queue,代码行数:5,代码来源:FakeTransactionTemplate.java

示例9: execute

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
@Override
public <T> T execute(TransactionDefinition definition, TransactionCallback<T> callback) throws TransactionException {
	this.definition = definition;
	this.status = new SimpleTransactionStatus();
	return callback.doInTransaction(this.status);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:MockCallbackPreferringTransactionManager.java

示例10: execute

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
@Override
public Object execute(TransactionDefinition definition, TransactionCallback callback) throws TransactionException {
	this.definition = definition;
	this.status = new SimpleTransactionStatus();
	return callback.doInTransaction(this.status);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:7,代码来源:MockCallbackPreferringTransactionManager.java

示例11: getTransaction

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
public TransactionStatus getTransaction(TransactionDefinition definition)
		throws TransactionException {
	return new SimpleTransactionStatus();
}
 
开发者ID:joshlong,项目名称:javaconfig-ftw,代码行数:5,代码来源:StupidPlatformTransactionManager.java

示例12: execute

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
@Override
public <T> T execute(TransactionCallback<T> action) throws TransactionException {
  return action.doInTransaction(new SimpleTransactionStatus(true));
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:5,代码来源:FakeTransactionOperations.java

示例13: getTransaction

import org.springframework.transaction.support.SimpleTransactionStatus; //导入依赖的package包/类
public TransactionStatus getTransaction(TransactionDefinition transactionDefinition) throws TransactionException {
    committed = false;
    return new SimpleTransactionStatus(true);
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:5,代码来源:DummyTransactionManager.java


注:本文中的org.springframework.transaction.support.SimpleTransactionStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。