本文整理汇总了Java中org.springframework.test.context.transaction.BeforeTransaction类的典型用法代码示例。如果您正苦于以下问题:Java BeforeTransaction类的具体用法?Java BeforeTransaction怎么用?Java BeforeTransaction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BeforeTransaction类属于org.springframework.test.context.transaction包,在下文中一共展示了BeforeTransaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runBeforeTransactionMethods
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
/**
* Run all {@link BeforeTransaction @BeforeTransaction methods} for the
* specified {@link TestContext test context}. If one of the methods fails,
* however, the caught exception will be rethrown in a wrapped
* {@link RuntimeException}, and the remaining methods will <strong>not</strong>
* be given a chance to execute.
* @param testContext the current test context
*/
protected void runBeforeTransactionMethods(TestContext testContext) throws Exception {
try {
List<Method> methods = getAnnotatedMethods(testContext.getTestClass(), BeforeTransaction.class);
Collections.reverse(methods);
for (Method method : methods) {
if (logger.isDebugEnabled()) {
logger.debug("Executing @BeforeTransaction method [" + method + "] for test context ["
+ testContext + "]");
}
method.invoke(testContext.getTestInstance());
}
}
catch (InvocationTargetException ex) {
logger.error("Exception encountered while executing @BeforeTransaction methods for test context ["
+ testContext + "]", ex.getTargetException());
ReflectionUtils.rethrowException(ex.getTargetException());
}
}
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:27,代码来源:MergeTransactionalTestExecutionListener.java
示例2: runBeforeTransactionMethods
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
/**
* Run all {@link BeforeTransaction @BeforeTransaction methods} for the
* specified {@link TestContext test context}. If one of the methods fails,
* however, the caught exception will be rethrown in a wrapped
* {@link RuntimeException}, and the remaining methods will
* <strong>not</strong> be given a chance to execute.
*
* @param testContext
* the current test context
*/
protected void runBeforeTransactionMethods(TestContext testContext)
throws Exception {
try {
List<Method> methods = getAnnotatedMethods(
testContext.getTestClass(), BeforeTransaction.class);
Collections.reverse(methods);
for (Method method : methods) {
if (logger.isDebugEnabled()) {
logger.debug("Executing @BeforeTransaction method ["
+ method + "] for test context [" + testContext
+ "]");
}
method.invoke(testContext.getTestInstance());
}
} catch (InvocationTargetException ex) {
logger.error(
"Exception encountered while executing @BeforeTransaction methods for test context ["
+ testContext + "]", ex.getTargetException());
ReflectionUtils.rethrowException(ex.getTargetException());
}
}
示例3: beforeTransaction
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void beforeTransaction() {
if (testName.getMethodName().contains("tenant_2")) {
this.tenantResolver.setTenantId("rjb-blog-mutlitenancy-2");
} else if (testName.getMethodName().contains("tenant_3")) {
this.tenantResolver.setTenantId("rjb-blog-mutlitenancy-3");
} else if (testName.getMethodName().contains("tenant_4")) {
this.tenantResolver.setTenantId("rjb-blog-mutlitenancy-4");
} else {
// default to tenant 1
// so all tests in the ProductDaoTest base class will still pass
this.tenantResolver.setTenantId("rjb-blog-mutlitenancy-1");
}
}
示例4: beforeTransaction
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void beforeTransaction() {
if (testName.getMethodName().contains("tenant_2")) {
this.tenantResolver.setTenantId("rjb-blog-mutlitenancy-2");
} else {
// default to tenant 1
// so all tests in the ProductDaoTest base class will still pass
this.tenantResolver.setTenantId("rjb-blog-mutlitenancy-1");
}
}
示例5: verifyInitialDatabaseState
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void verifyInitialDatabaseState() {
for (App app : appRepository.findAll()) {
System.out.println(app.getAppId());
}
Assert.assertEquals(0, appRepository.count());
Assert.assertEquals(7, appNamespaceRepository.count());
Assert.assertEquals(0, namespaceRepository.count());
Assert.assertEquals(0, clusterRepository.count());
}
示例6: beforeTransaction
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void beforeTransaction() {
assertInTransaction(false);
this.inTransaction = true;
BeforeAndAfterTransactionAnnotationTests.numBeforeTransactionCalls++;
clearPersonTable(jdbcTemplate);
assertEquals("Adding yoda", 1, addPerson(jdbcTemplate, YODA));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:BeforeAndAfterTransactionAnnotationTests.java
示例7: prepareDatabase
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
/** Load information into the database. */
@BeforeTransaction
public void prepareDatabase() {
synchronized (this) {
if (!run) {
prepareTestData(getModuleName());
}
run = true;
}
((ConfigurableApplicationContext) this.applicationContext).registerShutdownHook();
}
示例8: assertBeforeTransaction
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void assertBeforeTransaction() {
if (nonNull(beforeTransactionAssertion)) {
final RedisConnection connection = connectionFactory.getConnection();
beforeTransactionAssertion.assertBeforeTransaction(connection);
connection.close();
}
}
示例9: beforeTransaction
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void beforeTransaction() {
localeEn = new Locale("en");
localeFr = new Locale("fr");
baseName = "basename";
moduleName = "modulename";
Assert.notNull(messageBundleService);
resourceBundleEN = ResourceBundle.getBundle("org/sakaiproject/messagebundle/impl/test/bundle", localeEn);
resourceBundleFr = ResourceBundle.getBundle("org/sakaiproject/messagebundle/impl/test/bundle", localeFr);
messageBundleService.saveOrUpdate(baseName, moduleName, resourceBundleEN, localeEn);
messageBundleService.saveOrUpdate(baseName, moduleName, resourceBundleFr, localeFr);
}
示例10: onSetUpBeforeTransaction
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
/**
* SetsUp before transaction.
* @throws Exception - if something is wrong this exception is thrown.
*/
@BeforeTransaction
public void onSetUpBeforeTransaction() throws Exception {
// Unbind session from TransactionManager
session = sessionFactory.openSession();
TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
}
示例11: beforeTransaction
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void beforeTransaction() {
assertInTransaction(false);
this.inTransaction = true;
BeforeAndAfterTransactionAnnotationTests.numBeforeTransactionCalls++;
clearPersonTable(simpleJdbcTemplate);
assertEquals("Adding yoda", 1, addPerson(simpleJdbcTemplate, YODA));
}
示例12: beforeTransaction
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void beforeTransaction() {
this.inTransaction = true;
assertEquals("Verifying the number of rows in the person table before a transactional test method.", 1,
countRowsInPersonTable(super.simpleJdbcTemplate));
assertEquals("Adding yoda", 1, addPerson(super.simpleJdbcTemplate, YODA));
}
示例13: setUp
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void setUp() {
try {
if (!m_populated) {
m_databasePopulator.populateDatabase();
}
} catch (Throwable e) {
e.printStackTrace(System.err);
} finally {
m_populated = true;
}
}
示例14: setUp
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void setUp() {
try {
if (!m_populated) {
m_populator.populateDatabase();
m_lastPopulator = m_populator;
}
} catch (Throwable e) {
e.printStackTrace(System.err);
} finally {
m_populated = true;
}
}
示例15: setUp
import org.springframework.test.context.transaction.BeforeTransaction; //导入依赖的package包/类
@BeforeTransaction
public void setUp() {
try {
if (!m_populated) {
m_populator.populateDatabase();
}
} catch (Throwable e) {
e.printStackTrace(System.err);
} finally {
m_populated = true;
}
}