コード例 #1
0
 @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"));
 }
コード例 #2
0
 @Test
 public void testServletPathAsPrefix() throws Exception {
   RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
   binder.bind(new MutablePropertyValues(Collections.singletonMap("server.servletPath", "/foo")));
   assertThat(binder.getBindingResult().hasErrors()).isFalse();
   assertThat(this.properties.getServletMapping()).isEqualTo("/foo/*");
   assertThat(this.properties.getServletPrefix()).isEqualTo("/foo");
 }
コード例 #3
0
 @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");
 }
コード例 #4
0
 /**
  * Bind the environment to the {@link SpringApplication}.
  *
  * @param environment the environment to bind
  * @param application the application to bind to
  */
 protected void bindToSpringApplication(
     ConfigurableEnvironment environment, SpringApplication application) {
   RelaxedDataBinder binder = new RelaxedDataBinder(application, "spring.main");
   binder.setConversionService(this.conversionService);
   binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
 }