Java Code Examples for org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate

The following examples show how to use org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate. These examples are extracted from open source projects. 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 Project: spring-analysis-note   Source File: TestContextTestUtils.java    License: MIT License 4 votes vote down vote up
public static TestContext buildTestContext(Class<?> testClass, ContextCache contextCache) {
	return buildTestContext(testClass, new DefaultCacheAwareContextLoaderDelegate(contextCache));
}
 
Example 2
Source Project: java-technology-stack   Source File: TestContextTestUtils.java    License: MIT License 4 votes vote down vote up
public static TestContext buildTestContext(Class<?> testClass, ContextCache contextCache) {
	return buildTestContext(testClass, new DefaultCacheAwareContextLoaderDelegate(contextCache));
}
 
Example 3
public static TestContext buildTestContext(Class<?> testClass, ContextCache contextCache) {
	return buildTestContext(testClass, new DefaultCacheAwareContextLoaderDelegate(contextCache));
}
 
Example 4
Source Project: moduliths   Source File: TestUtils.java    License: Apache License 2.0 3 votes vote down vote up
public static void assertDependencyMissing(Class<?> testClass, Class<?> expectedMissingDependency) {

		CacheAwareContextLoaderDelegate delegate = new DefaultCacheAwareContextLoaderDelegate();
		BootstrapContext bootstrapContext = new DefaultBootstrapContext(testClass, delegate);

		SpringBootTestContextBootstrapper bootstrapper = new SpringBootTestContextBootstrapper();
		bootstrapper.setBootstrapContext(bootstrapContext);

		MergedContextConfiguration configuration = bootstrapper.buildMergedContextConfiguration();

		AssertableApplicationContext context = AssertableApplicationContext.get(() -> {

			SpringBootContextLoader loader = new SpringBootContextLoader();

			try {

				return (ConfigurableApplicationContext) loader.loadContext(configuration);

			} catch (Exception e) {

				if (e instanceof RuntimeException) {
					throw (RuntimeException) e;
				}

				throw new RuntimeException(e);
			}
		});

		assertThat(context).hasFailed();

		assertThat(context).getFailure().isInstanceOfSatisfying(UnsatisfiedDependencyException.class, it -> {
			assertThat(it.getMostSpecificCause()).isInstanceOfSatisfying(NoSuchBeanDefinitionException.class, ex -> {
				assertThat(ex.getBeanType()).isEqualTo(expectedMissingDependency);
			});
		});
	}