org.springframework.test.context.BootstrapContext Java Examples
The following examples show how to use
org.springframework.test.context.BootstrapContext.
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: AbstractContextConfigurationUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) { CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = Mockito.mock(CacheAwareContextLoaderDelegate.class); BootstrapContext bootstrapContext = BootstrapTestUtils.buildBootstrapContext(testClass, cacheAwareContextLoaderDelegate); TestContextBootstrapper bootstrapper = BootstrapTestUtils.resolveTestContextBootstrapper(bootstrapContext); return bootstrapper.buildMergedContextConfiguration(); }
Example #2
Source File: AbstractTestContextBootstrapper.java From spring-analysis-note with MIT License | 4 votes |
@Override public void setBootstrapContext(BootstrapContext bootstrapContext) { this.bootstrapContext = bootstrapContext; }
Example #3
Source File: AbstractTestContextBootstrapper.java From spring-analysis-note with MIT License | 4 votes |
@Override public BootstrapContext getBootstrapContext() { Assert.state(this.bootstrapContext != null, "No BootstrapContext set"); return this.bootstrapContext; }
Example #4
Source File: AbstractTestContextBootstrapper.java From java-technology-stack with MIT License | 4 votes |
@Override public void setBootstrapContext(BootstrapContext bootstrapContext) { this.bootstrapContext = bootstrapContext; }
Example #5
Source File: AbstractTestContextBootstrapper.java From java-technology-stack with MIT License | 4 votes |
@Override public BootstrapContext getBootstrapContext() { Assert.state(this.bootstrapContext != null, "No BootstrapContext set"); return this.bootstrapContext; }
Example #6
Source File: AbstractContextConfigurationUtilsTests.java From java-technology-stack with MIT License | 4 votes |
MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) { CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = Mockito.mock(CacheAwareContextLoaderDelegate.class); BootstrapContext bootstrapContext = BootstrapTestUtils.buildBootstrapContext(testClass, cacheAwareContextLoaderDelegate); TestContextBootstrapper bootstrapper = BootstrapTestUtils.resolveTestContextBootstrapper(bootstrapContext); return bootstrapper.buildMergedContextConfiguration(); }
Example #7
Source File: AbstractTestContextBootstrapper.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void setBootstrapContext(BootstrapContext bootstrapContext) { this.bootstrapContext = bootstrapContext; }
Example #8
Source File: AbstractTestContextBootstrapper.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public BootstrapContext getBootstrapContext() { return this.bootstrapContext; }
Example #9
Source File: AbstractContextConfigurationUtilsTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) { CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = Mockito.mock(CacheAwareContextLoaderDelegate.class); BootstrapContext bootstrapContext = BootstrapTestUtils.buildBootstrapContext(testClass, cacheAwareContextLoaderDelegate); TestContextBootstrapper bootstrapper = BootstrapTestUtils.resolveTestContextBootstrapper(bootstrapContext); return bootstrapper.buildMergedContextConfiguration(); }
Example #10
Source File: TestUtils.java From moduliths with Apache License 2.0 | 3 votes |
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); }); }); }