use of cn.taketoday.context.support.MockEnvironment in project today-infrastructure by TAKETODAY.
the class EnableCachingIntegrationTests method beanConditionOn.
@Test
public void beanConditionOn() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.setEnvironment(new MockEnvironment().withProperty("bar.enabled", "true"));
ctx.register(BeanConditionConfig.class);
ctx.refresh();
this.context = ctx;
FooService service = this.context.getBean(FooService.class);
Cache cache = getCache();
Object key = new Object();
Object value = service.getWithCondition(key);
assertCacheHit(key, value, cache);
value = service.getWithCondition(key);
assertCacheHit(key, value, cache);
assertThat(this.context.getBean(BeanConditionConfig.Bar.class).count).isEqualTo(2);
}
use of cn.taketoday.context.support.MockEnvironment in project today-infrastructure by TAKETODAY.
the class EnableMBeanExportConfigurationTests method testPlaceholderBased.
@Test
public void testPlaceholderBased() throws Exception {
MockEnvironment env = new MockEnvironment();
env.setProperty("serverName", "server");
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.setEnvironment(env);
context.register(PlaceholderBasedConfiguration.class);
context.refresh();
this.ctx = context;
validateAnnotationTestBean();
}
use of cn.taketoday.context.support.MockEnvironment in project today-infrastructure by TAKETODAY.
the class EnvironmentConverterTests method convertedEnvironmentHasSameConversionService.
@Test
void convertedEnvironmentHasSameConversionService() {
AbstractEnvironment originalEnvironment = new MockEnvironment();
ConfigurableConversionService conversionService = mock(ConfigurableConversionService.class);
originalEnvironment.setConversionService(conversionService);
StandardEnvironment convertedEnvironment = EnvironmentConverter.convertIfNecessary(getClass().getClassLoader(), originalEnvironment, StandardEnvironment.class);
assertThat(convertedEnvironment.getConversionService()).isEqualTo(conversionService);
}
Aggregations