本文整理汇总了Java中org.springframework.test.context.TestContext.markApplicationContextDirty方法的典型用法代码示例。如果您正苦于以下问题:Java TestContext.markApplicationContextDirty方法的具体用法?Java TestContext.markApplicationContextDirty怎么用?Java TestContext.markApplicationContextDirty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.test.context.TestContext
的用法示例。
在下文中一共展示了TestContext.markApplicationContextDirty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTestContextManager
import org.springframework.test.context.TestContext; //导入方法依赖的package包/类
/**
* Creates a new {@link TestContextManager} for the supplied test class.
* <p>
* Can be overridden by subclasses.
*
* @param clazz
* the test class to be managed
*/
@Override
protected TestContextManager createTestContextManager(final Class<?> clazz) {
return new TestContextManager(clazz) {
@Override
public void beforeTestClass() throws Exception {
super.beforeTestClass();
}
@Override
public void afterTestClass() throws Exception {
// If we aren't caching the Spring context them mark it dirty so
// it is destroyed.
if (!cacheSpringContext) {
final TestContext testContext = getTestContext();
testContext.markApplicationContextDirty(HierarchyMode.EXHAUSTIVE);
testContext.setAttribute(DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE,
Boolean.TRUE);
}
super.afterTestClass();
}
};
}
示例2: dirtyContext
import org.springframework.test.context.TestContext; //导入方法依赖的package包/类
/**
* Mark the {@linkplain ApplicationContext application context} of the supplied
* {@linkplain TestContext test context} as
* {@linkplain TestContext#markApplicationContextDirty(DirtiesContext.HierarchyMode) dirty}
* and set {@link DependencyInjectionTestExecutionListener#REINJECT_DEPENDENCIES_ATTRIBUTE
* REINJECT_DEPENDENCIES_ATTRIBUTE} in the test context to {@code true}.
* @param testContext the test context whose application context should
* be marked as dirty
* @param hierarchyMode the context cache clearing mode to be applied if the
* context is part of a hierarchy; may be {@code null}
* @since 3.2.2
*/
protected void dirtyContext(TestContext testContext, HierarchyMode hierarchyMode) {
testContext.markApplicationContextDirty(hierarchyMode);
testContext.setAttribute(DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE, Boolean.TRUE);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:AbstractDirtiesContextTestExecutionListener.java