本文整理匯總了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