org.springframework.test.annotation.DirtiesContext.HierarchyMode Java Examples
The following examples show how to use
org.springframework.test.annotation.DirtiesContext.HierarchyMode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContextCacheTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void removeContextHierarchyCacheLevel1() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 1 // Should also remove Levels 2, 3-A, and 3-B, leaving nothing. contextCache.remove(getMergedContextConfiguration(testContext3a).getParent().getParent(), HierarchyMode.CURRENT_LEVEL); assertContextCacheStatistics(contextCache, "removed level 1", 0, 1, 4); assertParentContextCount(0); }
Example #2
Source File: ContextCacheTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void removeContextHierarchyCacheLevel2WithExhaustiveMode() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 2 // Should wipe the cache contextCache.remove(getMergedContextConfiguration(testContext3a).getParent(), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 2", 0, 1, 4); assertParentContextCount(0); }
Example #3
Source File: ContextCacheTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void removeContextHierarchyCacheLevel1WithExhaustiveMode() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 1 // Should also remove Levels 2, 3-A, and 3-B, leaving nothing. contextCache.remove(getMergedContextConfiguration(testContext3a).getParent().getParent(), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 1", 0, 1, 4); assertParentContextCount(0); }
Example #4
Source File: ContextCacheTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void removeContextHierarchyCacheLevel1() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 1 // Should also remove Levels 2, 3-A, and 3-B, leaving nothing. contextCache.remove(getMergedContextConfiguration(testContext3a).getParent().getParent(), HierarchyMode.CURRENT_LEVEL); assertContextCacheStatistics(contextCache, "removed level 1", 0, 1, 4); assertParentContextCount(0); }
Example #5
Source File: ContextCacheTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void removeContextHierarchyCacheLevel1WithExhaustiveMode() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 1 // Should also remove Levels 2, 3-A, and 3-B, leaving nothing. contextCache.remove(getMergedContextConfiguration(testContext3a).getParent().getParent(), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 1", 0, 1, 4); assertParentContextCount(0); }
Example #6
Source File: ContextCacheTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void removeContextHierarchyCacheLevel2WithExhaustiveMode() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 2 // Should wipe the cache contextCache.remove(getMergedContextConfiguration(testContext3a).getParent(), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 2", 0, 1, 4); assertParentContextCount(0); }
Example #7
Source File: ContextCacheTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void removeContextHierarchyCacheLevel2WithExhaustiveMode() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 2 // Should wipe the cache contextCache.remove(getMergedContextConfiguration(testContext3a).getParent(), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 2", 0, 1, 4); assertParentContextCount(0); }
Example #8
Source File: ContextCacheTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void removeContextHierarchyCacheLevel2() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 2 // Should also remove Levels 3-A and 3-B, leaving only Level 1 as a context in the // cache but also removing the Level 1 hierarchy since all children have been // removed. contextCache.remove(getMergedContextConfiguration(testContext3a).getParent(), HierarchyMode.CURRENT_LEVEL); assertContextCacheStatistics(contextCache, "removed level 2", 1, 1, 4); assertParentContextCount(0); }
Example #9
Source File: ContextCacheTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void removeContextHierarchyCacheLevel1WithExhaustiveMode() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 1 // Should also remove Levels 2, 3-A, and 3-B, leaving nothing. contextCache.remove(getMergedContextConfiguration(testContext3a).getParent().getParent(), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 1", 0, 1, 4); assertParentContextCount(0); }
Example #10
Source File: ContextCacheTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void removeContextHierarchyCacheLevel1() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 1 // Should also remove Levels 2, 3-A, and 3-B, leaving nothing. contextCache.remove(getMergedContextConfiguration(testContext3a).getParent().getParent(), HierarchyMode.CURRENT_LEVEL); assertContextCacheStatistics(contextCache, "removed level 1", 0, 1, 4); assertParentContextCount(0); }
Example #11
Source File: DirtiesContextTestExecutionListenerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void beforeAndAfterTestClassForDirtiesContextDeclaredViaMetaAnnotationOnClassAfterClass() throws Exception { Class<?> clazz = DirtiesContextDeclaredViaMetaAnnotationAfterClass.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); beforeListener.beforeTestClass(testContext); afterListener.beforeTestClass(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); afterListener.afterTestClass(testContext); beforeListener.afterTestClass(testContext); verify(testContext, times(1)).markApplicationContextDirty(EXHAUSTIVE); }
Example #12
Source File: DirtiesContextTestExecutionListenerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextDeclaredLocallyOnClassAfterClass() throws Exception { Class<?> clazz = DirtiesContextDeclaredLocallyAfterClass.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("clean")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); }
Example #13
Source File: DirtiesContextTestExecutionListenerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextDeclaredLocallyOnClassBeforeClass() throws Exception { Class<?> clazz = DirtiesContextDeclaredLocallyBeforeClass.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("clean")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); }
Example #14
Source File: DirtiesContextTestExecutionListenerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextDeclaredLocallyOnMethodWithAfterMethodMode() throws Exception { Class<?> clazz = getClass(); BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn( clazz.getDeclaredMethod("dirtiesContextDeclaredLocallyWithAfterMethodMode")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(1)).markApplicationContextDirty(EXHAUSTIVE); }
Example #15
Source File: DirtiesContextTestExecutionListenerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextDeclaredOnMethodViaMetaAnnotationWithAfterMethodMode() throws Exception { Class<?> clazz = getClass(); BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn( clazz.getDeclaredMethod("dirtiesContextDeclaredViaMetaAnnotationWithAfterMethodMode")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(1)).markApplicationContextDirty(EXHAUSTIVE); }
Example #16
Source File: DirtiesContextTestExecutionListenerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextDeclaredLocallyOnClassAfterEachTestMethod() throws Exception { Class<?> clazz = DirtiesContextDeclaredLocallyAfterEachTestMethod.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("clean")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(1)).markApplicationContextDirty(EXHAUSTIVE); }
Example #17
Source File: DirtiesContextTestExecutionListenerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextDeclaredViaMetaAnnotationOnClassAfterClass() throws Exception { Class<?> clazz = DirtiesContextDeclaredViaMetaAnnotationAfterClass.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("clean")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); }
Example #18
Source File: DirtiesContextTestExecutionListenerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void beforeAndAfterTestClassForDirtiesContextDeclaredLocallyOnMethod() throws Exception { Class<?> clazz = getClass(); BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); beforeListener.beforeTestClass(testContext); afterListener.beforeTestClass(testContext); afterListener.afterTestClass(testContext); beforeListener.afterTestClass(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); }
Example #19
Source File: ContextCacheTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void removeContextHierarchyCacheLevel3Then2() { // Load Level 3-A TestContext testContext3a = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache); testContext3a.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3); assertParentContextCount(2); // Load Level 3-B TestContext testContext3b = TestContextTestUtils.buildTestContext( ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache); testContext3b.getApplicationContext(); assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4); assertParentContextCount(2); // Remove Level 3-A contextCache.remove(getMergedContextConfiguration(testContext3a), HierarchyMode.CURRENT_LEVEL); assertContextCacheStatistics(contextCache, "removed level 3-A", 3, 1, 4); assertParentContextCount(2); // Remove Level 2 // Should also remove Level 3-B, leaving only Level 1. contextCache.remove(getMergedContextConfiguration(testContext3b).getParent(), HierarchyMode.CURRENT_LEVEL); assertContextCacheStatistics(contextCache, "removed level 2", 1, 1, 4); assertParentContextCount(0); }
Example #20
Source File: DirtiesContextTestExecutionListenerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void beforeAndAfterTestClassForDirtiesContextDeclaredViaMetaAnnotationWithOverridenAttributes() throws Exception { Class<?> clazz = DirtiesContextViaMetaAnnotationWithOverridenAttributes.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); beforeListener.beforeTestClass(testContext); afterListener.beforeTestClass(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); afterListener.afterTestClass(testContext); beforeListener.afterTestClass(testContext); verify(testContext, times(1)).markApplicationContextDirty(EXHAUSTIVE); }
Example #21
Source File: DirtiesContextTestExecutionListenerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void beforeAndAfterTestClassForDirtiesContextDeclaredLocallyOnClassAfterEachTestMethod() throws Exception { Class<?> clazz = DirtiesContextDeclaredLocallyAfterEachTestMethod.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); beforeListener.beforeTestClass(testContext); afterListener.beforeTestClass(testContext); afterListener.afterTestClass(testContext); beforeListener.afterTestClass(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); }
Example #22
Source File: DirtiesContextTestExecutionListenerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void beforeAndAfterTestClassForDirtiesContextDeclaredLocallyOnClassBeforeEachTestMethod() throws Exception { Class<?> clazz = DirtiesContextDeclaredLocallyBeforeEachTestMethod.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); beforeListener.beforeTestClass(testContext); afterListener.beforeTestClass(testContext); afterListener.afterTestClass(testContext); beforeListener.afterTestClass(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); }
Example #23
Source File: DirtiesContextTestExecutionListenerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void beforeAndAfterTestClassForDirtiesContextDeclaredLocallyOnMethod() throws Exception { Class<?> clazz = getClass(); BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); beforeListener.beforeTestClass(testContext); afterListener.beforeTestClass(testContext); afterListener.afterTestClass(testContext); beforeListener.afterTestClass(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); }
Example #24
Source File: DirtiesContextTestExecutionListenerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextViaMetaAnnotationWithOverrides() throws Exception { Class<?> clazz = DirtiesContextViaMetaAnnotationWithOverrides.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("clean")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(1)).markApplicationContextDirty(CURRENT_LEVEL); }
Example #25
Source File: DirtiesContextTestExecutionListenerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextDeclaredLocallyOnClassAfterClass() throws Exception { Class<?> clazz = DirtiesContextDeclaredLocallyAfterClass.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("clean")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); }
Example #26
Source File: DirtiesContextTestExecutionListenerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextDeclaredLocallyOnClassBeforeClass() throws Exception { Class<?> clazz = DirtiesContextDeclaredLocallyBeforeClass.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("clean")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); }
Example #27
Source File: DirtiesContextTestExecutionListenerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextDeclaredViaMetaAnnotationOnClassAfterEachTestMethod() throws Exception { Class<?> clazz = DirtiesContextDeclaredViaMetaAnnotationAfterEachTestMethod.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("clean")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(1)).markApplicationContextDirty(EXHAUSTIVE); }
Example #28
Source File: DirtiesContextTestExecutionListenerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void beforeAndAfterTestClassForDirtiesContextDeclaredViaMetaAnnotationWithOverrides() throws Exception { Class<?> clazz = DirtiesContextViaMetaAnnotationWithOverrides.class; BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); beforeListener.beforeTestClass(testContext); afterListener.beforeTestClass(testContext); afterListener.afterTestClass(testContext); beforeListener.afterTestClass(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); }
Example #29
Source File: DirtiesContextTestExecutionListenerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void beforeAndAfterTestMethodForDirtiesContextDeclaredOnMethodViaMetaAnnotationWithAfterMethodMode() throws Exception { Class<?> clazz = getClass(); BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn( clazz.getDeclaredMethod("dirtiesContextDeclaredViaMetaAnnotationWithAfterMethodMode")); beforeListener.beforeTestMethod(testContext); afterListener.beforeTestMethod(testContext); verify(testContext, times(0)).markApplicationContextDirty(any(HierarchyMode.class)); afterListener.afterTestMethod(testContext); beforeListener.afterTestMethod(testContext); verify(testContext, times(1)).markApplicationContextDirty(EXHAUSTIVE); }
Example #30
Source File: DefaultContextCache.java From java-technology-stack with MIT License | 5 votes |
@Override protected boolean removeEldestEntry(Map.Entry<MergedContextConfiguration, ApplicationContext> eldest) { if (this.size() > DefaultContextCache.this.getMaxSize()) { // Do NOT delete "DefaultContextCache.this."; otherwise, we accidentally // invoke java.util.Map.remove(Object, Object). DefaultContextCache.this.remove(eldest.getKey(), HierarchyMode.CURRENT_LEVEL); } // Return false since we invoke a custom eviction algorithm. return false; }