use of cn.taketoday.core.env.MapPropertySource in project today-infrastructure by TAKETODAY.
the class PropertySourceOriginTests method getPropertyNameShouldReturnPropertyName.
@Test
void getPropertyNameShouldReturnPropertyName() {
MapPropertySource propertySource = new MapPropertySource("test", new HashMap<>());
PropertySourceOrigin origin = new PropertySourceOrigin(propertySource, "foo");
assertThat(origin.getPropertyName()).isEqualTo("foo");
}
use of cn.taketoday.core.env.MapPropertySource in project today-infrastructure by TAKETODAY.
the class ResourceBanner method getTitleResolver.
private PropertyResolver getTitleResolver(Class<?> sourceClass) {
PropertySources sources = new PropertySources();
String applicationTitle = getApplicationTitle(sourceClass);
Map<String, Object> titleMap = Collections.singletonMap("application.title", (applicationTitle != null) ? applicationTitle : "");
sources.addFirst(new MapPropertySource("title", titleMap));
return new PropertySourcesPropertyResolver(sources);
}
use of cn.taketoday.core.env.MapPropertySource in project today-infrastructure by TAKETODAY.
the class PropertySourceAnnotationTests method orderingDoesntReplaceExisting.
@Test
void orderingDoesntReplaceExisting() throws Exception {
// SPR-12198: mySource should 'win' as it was registered manually
AnnotationConfigApplicationContext ctxWithoutName = new AnnotationConfigApplicationContext();
MapPropertySource mySource = new MapPropertySource("mine", Collections.singletonMap("testbean.name", "myTestBean"));
ctxWithoutName.getEnvironment().getPropertySources().addLast(mySource);
ctxWithoutName.register(ConfigWithFourResourceLocations.class);
ctxWithoutName.refresh();
assertThat(ctxWithoutName.getEnvironment().getProperty("testbean.name")).isEqualTo("myTestBean");
}
use of cn.taketoday.core.env.MapPropertySource in project today-infrastructure by TAKETODAY.
the class ValidationBindHandlerTests method validateMapValuesWithNonUniformSource.
@Test
void validateMapValuesWithNonUniformSource() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("test.items.itemOne.number", "one");
map.put("test.items.ITEM2.number", "two");
this.sources.add(ConfigurationPropertySources.from(new MapPropertySource("test", map)).iterator().next());
Validator validator = getMapValidator();
this.handler = new ValidationBindHandler(validator);
this.binder.bind(ConfigurationPropertyName.of("test"), Bindable.of(ExampleWithMap.class), this.handler);
}
use of cn.taketoday.core.env.MapPropertySource in project today-infrastructure by TAKETODAY.
the class PropertySourcesPlaceholdersResolverTests method getPropertySources.
private PropertySources getPropertySources() {
PropertySources sources = new PropertySources();
Map<String, Object> source = new HashMap<>();
source.put("FOO", "hello world");
sources.addFirst(new MapPropertySource("test", source));
return sources;
}
Aggregations