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

The following examples show how to use org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate. 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: TestContextTestUtils.java    From spring-analysis-note with 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 File: TestContextTestUtils.java    From java-technology-stack with MIT License 4 votes vote down vote up
public static TestContext buildTestContext(Class<?> testClass, ContextCache contextCache) {
	return buildTestContext(testClass, new DefaultCacheAwareContextLoaderDelegate(contextCache));
}
 
Example #3
Source File: TestContextTestUtils.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public static TestContext buildTestContext(Class<?> testClass, ContextCache contextCache) {
	return buildTestContext(testClass, new DefaultCacheAwareContextLoaderDelegate(contextCache));
}
 
Example #4
Source File: TestUtils.java    From moduliths with 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);
			});
		});
	}