org.springframework.test.context.TestContextTestUtils Java Examples
The following examples show how to use
org.springframework.test.context.TestContextTestUtils.
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 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 #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 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 #4
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 #5
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 #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 java-technology-stack 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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
Source File: ContextCacheTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void removeContextHierarchyCacheLevel3Then2WithExhaustiveMode() { // 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 // Should wipe the cache. contextCache.remove(getMergedContextConfiguration(testContext3a), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 3-A", 0, 1, 4); assertParentContextCount(0); // Remove Level 2 // Should not actually do anything since the cache was cleared in the // previous step. So the stats should remain the same. contextCache.remove(getMergedContextConfiguration(testContext3b).getParent(), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 2", 0, 1, 4); assertParentContextCount(0); }
Example #14
Source File: ContextCacheTests.java From spring-analysis-note with MIT License | 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 #15
Source File: ContextCacheTests.java From java-technology-stack with MIT License | 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 #16
Source File: ContextCacheTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void removeContextHierarchyCacheLevel3Then2WithExhaustiveMode() { // 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 // Should wipe the cache. contextCache.remove(getMergedContextConfiguration(testContext3a), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 3-A", 0, 1, 4); assertParentContextCount(0); // Remove Level 2 // Should not actually do anything since the cache was cleared in the // previous step. So the stats should remain the same. contextCache.remove(getMergedContextConfiguration(testContext3b).getParent(), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 2", 0, 1, 4); assertParentContextCount(0); }
Example #17
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 #18
Source File: ContextCacheTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void removeContextHierarchyCacheLevel3Then2WithExhaustiveMode() { // 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 // Should wipe the cache. contextCache.remove(getMergedContextConfiguration(testContext3a), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 3-A", 0, 1, 4); assertParentContextCount(0); // Remove Level 2 // Should not actually do anything since the cache was cleared in the // previous step. So the stats should remain the same. contextCache.remove(getMergedContextConfiguration(testContext3b).getParent(), HierarchyMode.EXHAUSTIVE); assertContextCacheStatistics(contextCache, "removed level 2", 0, 1, 4); assertParentContextCount(0); }
Example #19
Source File: ContextCacheTests.java From java-technology-stack with MIT License | 4 votes |
private ApplicationContext loadContext(Class<?> testClass) { TestContext testContext = TestContextTestUtils.buildTestContext(testClass, contextCache); return testContext.getApplicationContext(); }
Example #20
Source File: ContextCacheTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
private ApplicationContext loadContext(Class<?> testClass) { TestContext testContext = TestContextTestUtils.buildTestContext(testClass, contextCache); return testContext.getApplicationContext(); }
Example #21
Source File: ContextCacheTests.java From spring-analysis-note with MIT License | 4 votes |
private ApplicationContext loadContext(Class<?> testClass) { TestContext testContext = TestContextTestUtils.buildTestContext(testClass, contextCache); return testContext.getApplicationContext(); }