use of cn.taketoday.context.support.ApplicationPropertySourcesProcessor in project today-infrastructure by TAKETODAY.
the class ConditionalTests method testConditionalOnResource.
@Test
public void testConditionalOnResource() throws Exception {
try (StandardApplicationContext context = new StandardApplicationContext()) {
ApplicationPropertySourcesProcessor processor = new ApplicationPropertySourcesProcessor(context);
processor.setPropertiesLocation("info.properties");
processor.postProcessEnvironment();
context.scan("cn.taketoday.context.condition");
BeanDefinitionRegistry registry = context.unwrapFactory(BeanDefinitionRegistry.class);
Assertions.assertFalse(registry.containsBeanDefinition(ConditionalOnResource_.class));
Assertions.assertTrue(registry.containsBeanDefinition(ConditionalOnResource__.class));
Assertions.assertTrue(registry.containsBeanDefinition(ConditionalOnResource___.class));
Assertions.assertTrue(registry.containsBeanDefinition(ConditionalOnResource____.class));
}
}
use of cn.taketoday.context.support.ApplicationPropertySourcesProcessor in project today-infrastructure by TAKETODAY.
the class ConditionalTests method conditionalOnExpression.
@Test
void conditionalOnExpression() throws IOException {
try (StandardApplicationContext context = new StandardApplicationContext()) {
ApplicationPropertySourcesProcessor processor = new ApplicationPropertySourcesProcessor(context);
processor.setPropertiesLocation("info.properties");
processor.postProcessEnvironment();
context.scan("cn.taketoday.context.condition");
BeanDefinitionRegistry registry = context.unwrapFactory(BeanDefinitionRegistry.class);
Assertions.assertTrue(registry.containsBeanDefinition(ConditionalExpression_.class));
Assertions.assertFalse(registry.containsBeanDefinition(ConditionalExpression__.class));
}
}
use of cn.taketoday.context.support.ApplicationPropertySourcesProcessor in project today-infrastructure by TAKETODAY.
the class ConditionalTests method testConditionalOnClass.
// ConditionalOnClass
// ------------------------------
@Test
void testConditionalOnClass() throws IOException {
try (StandardApplicationContext context = new StandardApplicationContext()) {
ApplicationPropertySourcesProcessor processor = new ApplicationPropertySourcesProcessor(context);
processor.setPropertiesLocation("info.properties");
processor.postProcessEnvironment();
context.scan("cn.taketoday.context.condition");
BeanDefinitionRegistry registry = context.unwrapFactory(BeanDefinitionRegistry.class);
Assertions.assertTrue(registry.containsBeanDefinition(ConditionalClass.class));
Assertions.assertTrue(registry.containsBeanDefinition(ConditionalOnMissing.class));
Assertions.assertFalse(registry.containsBeanDefinition(ConditionalMissingClass.class));
Assertions.assertFalse(registry.containsBeanDefinition(ConditionalMissed.class));
}
}
use of cn.taketoday.context.support.ApplicationPropertySourcesProcessor in project today-infrastructure by TAKETODAY.
the class StandardEnvironmentTests method addActiveProfile.
@Test
void addActiveProfile() throws IOException {
try (StandardApplicationContext context = new StandardApplicationContext()) {
ApplicationPropertySourcesProcessor processor = new ApplicationPropertySourcesProcessor(context);
processor.setPropertiesLocation("info.properties");
processor.postProcessEnvironment();
context.scan("cn.taketoday.context.env");
ConfigurableEnvironment environment = context.getEnvironment();
environment.addActiveProfile("prod");
String[] activeProfiles = environment.getActiveProfiles();
assert activeProfiles.length == 3;
assert environment.acceptsProfiles("prod");
}
}
use of cn.taketoday.context.support.ApplicationPropertySourcesProcessor in project today-framework by TAKETODAY.
the class ELFieldTests method testEnv.
@Test
void testEnv() throws IOException {
try (StandardApplicationContext applicationContext = new StandardApplicationContext()) {
User user = new User();
//
user.setAge(20).setBrithday(//
new Date()).setId(1);
ApplicationPropertySourcesProcessor processor = new ApplicationPropertySourcesProcessor(applicationContext);
processor.setPropertiesLocation("info.properties");
processor.postProcessEnvironment();
applicationContext.registerSingleton(user);
applicationContext.register(ELFieldTests.class);
applicationContext.refresh();
ELFieldTests bean = applicationContext.getBean(getClass());
System.err.println(bean);
assert bean.user == user;
assert bean.siteName.equals("TODAY BLOG");
}
}
Aggregations