use of org.springframework.boot.bind.RelaxedDataBinder in project spring-boot by spring-projects.
the class ServerPropertiesTests method testServerHeader.
@Test
public void testServerHeader() throws Exception {
RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
binder.bind(new MutablePropertyValues(Collections.singletonMap("server.server-header", "Custom Server")));
assertThat(this.properties.getServerHeader()).isEqualTo("Custom Server");
}
use of org.springframework.boot.bind.RelaxedDataBinder in project spring-boot by spring-projects.
the class ServerPropertiesTests method testServletPathAsPrefix.
@Test
public void testServletPathAsPrefix() throws Exception {
RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
binder.bind(new MutablePropertyValues(Collections.singletonMap("server.servlet.path", "/foo")));
assertThat(binder.getBindingResult().hasErrors()).isFalse();
assertThat(this.properties.getServlet().getServletMapping()).isEqualTo("/foo/*");
assertThat(this.properties.getServlet().getServletPrefix()).isEqualTo("/foo");
}
use of org.springframework.boot.bind.RelaxedDataBinder in project spring-boot by spring-projects.
the class ServerPropertiesTests method testSlashOfContextPathIsDefaultValue.
@Test
public void testSlashOfContextPathIsDefaultValue() {
new RelaxedDataBinder(this.properties, "server").bind(new MutablePropertyValues(Collections.singletonMap("server.servlet.contextPath", "/")));
assertThat(this.properties.getServlet().getContextPath()).isEqualTo("");
}
use of org.springframework.boot.bind.RelaxedDataBinder in project dubbo by alibaba.
the class RelaxedDubboConfigBinder method bind.
@Override
public void bind(Map<String, Object> configurationProperties, boolean ignoreUnknownFields, boolean ignoreInvalidFields, Object configurationBean) {
RelaxedDataBinder relaxedDataBinder = new RelaxedDataBinder(configurationBean);
// Set ignored*
relaxedDataBinder.setIgnoreInvalidFields(ignoreInvalidFields);
relaxedDataBinder.setIgnoreUnknownFields(ignoreUnknownFields);
// Get properties under specified prefix from PropertySources
// Convert Map to MutablePropertyValues
MutablePropertyValues propertyValues = new MutablePropertyValues(configurationProperties);
// Bind
relaxedDataBinder.bind(propertyValues);
}
use of org.springframework.boot.bind.RelaxedDataBinder in project spring-boot by spring-projects.
the class SpringProfileDocumentMatcher method extractSpringProfiles.
protected List<String> extractSpringProfiles(Properties properties) {
SpringProperties springProperties = new SpringProperties();
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new PropertiesPropertySource("profiles", properties));
PropertyValues propertyValues = new PropertySourcesPropertyValues(propertySources);
new RelaxedDataBinder(springProperties, "spring").bind(propertyValues);
List<String> profiles = springProperties.getProfiles();
return profiles;
}
Aggregations