类org.springframework.test.context.TestContextTestUtils源码实例Demo

下面列出了怎么用org.springframework.test.context.TestContextTestUtils的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spring-analysis-note   文件: ContextCacheTests.java
@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);
}
 
源代码2 项目: spring-analysis-note   文件: ContextCacheTests.java
@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);
}
 
源代码3 项目: spring-analysis-note   文件: ContextCacheTests.java
@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);
}
 
源代码4 项目: spring-analysis-note   文件: ContextCacheTests.java
@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);
}
 
源代码5 项目: java-technology-stack   文件: ContextCacheTests.java
@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);
}
 
源代码6 项目: java-technology-stack   文件: ContextCacheTests.java
@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);
}
 
源代码7 项目: java-technology-stack   文件: ContextCacheTests.java
@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);
}
 
源代码8 项目: java-technology-stack   文件: ContextCacheTests.java
@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);
}
 
源代码9 项目: spring4-understanding   文件: ContextCacheTests.java
@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);
}
 
源代码10 项目: spring4-understanding   文件: ContextCacheTests.java
@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);
}
 
源代码11 项目: spring4-understanding   文件: ContextCacheTests.java
@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);
}
 
源代码12 项目: spring4-understanding   文件: ContextCacheTests.java
@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);
}
 
源代码13 项目: spring-analysis-note   文件: ContextCacheTests.java
@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);
}
 
源代码14 项目: spring-analysis-note   文件: ContextCacheTests.java
@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);
}
 
源代码15 项目: java-technology-stack   文件: ContextCacheTests.java
@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);
}
 
源代码16 项目: java-technology-stack   文件: ContextCacheTests.java
@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);
}
 
源代码17 项目: spring4-understanding   文件: ContextCacheTests.java
@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);
}
 
源代码18 项目: spring4-understanding   文件: ContextCacheTests.java
@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);
}
 
源代码19 项目: spring-analysis-note   文件: ContextCacheTests.java
private ApplicationContext loadContext(Class<?> testClass) {
	TestContext testContext = TestContextTestUtils.buildTestContext(testClass, contextCache);
	return testContext.getApplicationContext();
}
 
源代码20 项目: java-technology-stack   文件: ContextCacheTests.java
private ApplicationContext loadContext(Class<?> testClass) {
	TestContext testContext = TestContextTestUtils.buildTestContext(testClass, contextCache);
	return testContext.getApplicationContext();
}
 
源代码21 项目: spring4-understanding   文件: ContextCacheTests.java
private ApplicationContext loadContext(Class<?> testClass) {
	TestContext testContext = TestContextTestUtils.buildTestContext(testClass, contextCache);
	return testContext.getApplicationContext();
}
 
 同包方法