Package org.springframework.boot.bind

Examples of org.springframework.boot.bind.RelaxedDataBinder.bind()


  private final ServerProperties properties = new ServerProperties();

  @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")));
    assertFalse(binder.getBindingResult().hasErrors());
    assertEquals(InetAddress.getByName("127.0.0.1"), this.properties.getAddress());
  }
View Full Code Here


  }

  @Test
  public void testServletPathAsMapping() throws Exception {
    RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
    binder.bind(new MutablePropertyValues(Collections.singletonMap(
        "server.servletPath", "/foo/*")));
    assertFalse(binder.getBindingResult().hasErrors());
    assertEquals("/foo/*", this.properties.getServletMapping());
    assertEquals("/foo", this.properties.getServletPrefix());
  }
View Full Code Here

  }

  @Test
  public void testServletPathAsPrefix() throws Exception {
    RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
    binder.bind(new MutablePropertyValues(Collections.singletonMap(
        "server.servletPath", "/foo")));
    assertFalse(binder.getBindingResult().hasErrors());
    assertEquals("/foo/*", this.properties.getServletMapping());
    assertEquals("/foo", this.properties.getServletPrefix());
  }
View Full Code Here

  @Test
  public void testBindingAuth() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.bind(new MutablePropertyValues(Collections.singletonMap("shell.auth",
        "spring")));
    assertFalse(binder.getBindingResult().hasErrors());
    assertEquals("spring", props.getAuth());
  }
View Full Code Here

  @Test
  public void testBindingAuthIfEmpty() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.bind(new MutablePropertyValues(Collections.singletonMap("shell.auth", "")));
    assertTrue(binder.getBindingResult().hasErrors());
    assertEquals("simple", props.getAuth());
  }

  @Test
View Full Code Here

  @Test
  public void testBindingCommandRefreshInterval() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.setConversionService(new DefaultConversionService());
    binder.bind(new MutablePropertyValues(Collections.singletonMap(
        "shell.command_refresh_interval", "1")));
    assertFalse(binder.getBindingResult().hasErrors());
    assertEquals(1, props.getCommandRefreshInterval());
  }
View Full Code Here

  @Test
  public void testBindingCommandPathPatterns() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.setConversionService(new DefaultConversionService());
    binder.bind(new MutablePropertyValues(Collections.singletonMap(
        "shell.command_path_patterns", "pattern1, pattern2")));
    assertFalse(binder.getBindingResult().hasErrors());
    assertEquals(2, props.getCommandPathPatterns().length);
    Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" },
        props.getCommandPathPatterns());
View Full Code Here

  @Test
  public void testBindingConfigPathPatterns() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.setConversionService(new DefaultConversionService());
    binder.bind(new MutablePropertyValues(Collections.singletonMap(
        "shell.config_path_patterns", "pattern1, pattern2")));
    assertFalse(binder.getBindingResult().hasErrors());
    assertEquals(2, props.getConfigPathPatterns().length);
    Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" },
        props.getConfigPathPatterns());
View Full Code Here

  @Test
  public void testBindingDisabledPlugins() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.setConversionService(new DefaultConversionService());
    binder.bind(new MutablePropertyValues(Collections.singletonMap(
        "shell.disabled_plugins", "pattern1, pattern2")));
    assertFalse(binder.getBindingResult().hasErrors());
    assertEquals(2, props.getDisabledPlugins().length);
    assertArrayEquals(new String[] { "pattern1", "pattern2" },
        props.getDisabledPlugins());
View Full Code Here

  @Test
  public void testBindingDisabledCommands() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.setConversionService(new DefaultConversionService());
    binder.bind(new MutablePropertyValues(Collections.singletonMap(
        "shell.disabled_commands", "pattern1, pattern2")));
    assertFalse(binder.getBindingResult().hasErrors());
    assertEquals(2, props.getDisabledCommands().length);
    assertArrayEquals(new String[] { "pattern1", "pattern2" },
        props.getDisabledCommands());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.