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


Java BeforeTransaction类代码示例

本文整理汇总了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 &#064;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:fpuna-cia,项目名称:karaku,代码行数:33,代码来源:TransactionalTestCucumberExecutionListener.java

示例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");
	}
}
 
开发者ID:RJBTechnology,项目名称:rjb-blog-multitenancy,代码行数:15,代码来源:AbstractTest.java

示例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");
	}
}
 
开发者ID:RJBTechnology,项目名称:rjb-blog-multitenancy,代码行数:11,代码来源:AbstractTest.java

示例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());
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:11,代码来源:AdminServiceTransactionTest.java

示例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();
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:12,代码来源:DcmaTestCase.java

示例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();
    }
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:9,代码来源:BaseRedisTest.java

示例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);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:16,代码来源:MessageBundleTest.java

示例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));
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:11,代码来源:AbstractHibernateDaoTestCase.java

示例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));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:BeforeAndAfterTransactionAnnotationTests.java

示例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));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:8,代码来源:ConcreteTransactionalJUnit38SpringContextTests.java

示例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;
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:13,代码来源:CriteriaTest.java

示例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;
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:14,代码来源:NodeDaoTest.java

示例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;
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:13,代码来源:AuthorizationTest.java


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