use of org.springframework.boot.bind.RelaxedDataBinder in project spring-boot by spring-projects.
the class ServerPropertiesTests method testAddressBinding.
@Test
public void testAddressBinding() throws Exception {
RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
binder.bind(new MutablePropertyValues(Collections.singletonMap("server.address", "127.0.0.1")));
assertThat(binder.getBindingResult().hasErrors()).isFalse();
assertThat(this.properties.getAddress()).isEqualTo(InetAddress.getByName("127.0.0.1"));
}
use of org.springframework.boot.bind.RelaxedDataBinder in project spring-boot by spring-projects.
the class ServerPropertiesTests method testPortBinding.
@Test
public void testPortBinding() throws Exception {
new RelaxedDataBinder(this.properties, "server").bind(new MutablePropertyValues(Collections.singletonMap("server.port", "9000")));
assertThat(this.properties.getPort().intValue()).isEqualTo(9000);
}
use of org.springframework.boot.bind.RelaxedDataBinder in project spring-boot by spring-projects.
the class ServerPropertiesTests method testTrailingSlashOfContextPathIsRemoved.
@Test
public void testTrailingSlashOfContextPathIsRemoved() {
new RelaxedDataBinder(this.properties, "server").bind(new MutablePropertyValues(Collections.singletonMap("server.servlet.contextPath", "/foo/")));
assertThat(this.properties.getServlet().getContextPath()).isEqualTo("/foo");
}
use of org.springframework.boot.bind.RelaxedDataBinder in project spring-boot by spring-projects.
the class ServerPropertiesTests method testServletPathAsMapping.
@Test
public void testServletPathAsMapping() 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 DataSourceBuilder method bind.
private void bind(DataSource result) {
MutablePropertyValues properties = new MutablePropertyValues(this.properties);
new RelaxedDataBinder(result).withAlias("url", "jdbcUrl").withAlias("username", "user").bind(properties);
}
Aggregations