當前位置: 首頁>>代碼示例>>Java>>正文


Java TestContext.markApplicationContextDirty方法代碼示例

本文整理匯總了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();
        }
    };
}
 
開發者ID:gchq,項目名稱:stroom-proxy,代碼行數:32,代碼來源:StroomSpringJUnit4ClassRunner.java

示例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


注:本文中的org.springframework.test.context.TestContext.markApplicationContextDirty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。