Package org.springframework.boot.bind

Examples of org.springframework.boot.bind.RelaxedDataBinder


  }

  @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

  }

  @Test
  public void testBindingSsh() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.setConversionService(new DefaultConversionService());
    Map<String, String> map = new HashMap<String, String>();
    map.put("shell.ssh.enabled", "true");
    map.put("shell.ssh.port", "2222");
    map.put("shell.ssh.key_path", "~/.ssh/test.pem");
    binder.bind(new MutablePropertyValues(map));
    assertFalse(binder.getBindingResult().hasErrors());

    Properties p = props.asCrshShellConfig();

    assertEquals("2222", p.get("crash.ssh.port"));
    assertEquals("~/.ssh/test.pem", p.get("crash.ssh.keypath"));
View Full Code Here

  }

  @Test
  public void testBindingSshIgnored() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.setConversionService(new DefaultConversionService());
    Map<String, String> map = new HashMap<String, String>();
    map.put("shell.ssh.enabled", "false");
    map.put("shell.ssh.port", "2222");
    map.put("shell.ssh.key_path", "~/.ssh/test.pem");
    binder.bind(new MutablePropertyValues(map));
    assertFalse(binder.getBindingResult().hasErrors());

    Properties p = props.asCrshShellConfig();

    assertNull(p.get("crash.ssh.port"));
    assertNull(p.get("crash.ssh.keypath"));
View Full Code Here

  }

  @Test
  public void testBindingTelnet() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.setConversionService(new DefaultConversionService());
    Map<String, String> map = new HashMap<String, String>();
    map.put("shell.telnet.enabled", "true");
    map.put("shell.telnet.port", "2222");
    binder.bind(new MutablePropertyValues(map));
    assertFalse(binder.getBindingResult().hasErrors());

    Properties p = props.asCrshShellConfig();

    assertEquals("2222", p.get("crash.telnet.port"));
  }
View Full Code Here

  }

  @Test
  public void testBindingTelnetIgnored() {
    ShellProperties props = new ShellProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
    binder.setConversionService(new DefaultConversionService());
    Map<String, String> map = new HashMap<String, String>();
    map.put("shell.telnet.enabled", "false");
    map.put("shell.telnet.port", "2222");
    binder.bind(new MutablePropertyValues(map));
    assertFalse(binder.getBindingResult().hasErrors());

    Properties p = props.asCrshShellConfig();

    assertNull(p.get("crash.telnet.port"));
  }
View Full Code Here

  }

  @Test
  public void testBindingJaas() {
    JaasAuthenticationProperties props = new JaasAuthenticationProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell.auth.jaas");
    binder.setConversionService(new DefaultConversionService());
    Map<String, String> map = new HashMap<String, String>();
    map.put("shell.auth.jaas.domain", "my-test-domain");
    binder.bind(new MutablePropertyValues(map));
    assertFalse(binder.getBindingResult().hasErrors());

    Properties p = new Properties();
    props.applyToCrshShellConfig(p);

    assertEquals("my-test-domain", p.get("crash.auth.jaas.domain"));
View Full Code Here

  }

  @Test
  public void testBindingKey() {
    KeyAuthenticationProperties props = new KeyAuthenticationProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell.auth.key");
    binder.setConversionService(new DefaultConversionService());
    Map<String, String> map = new HashMap<String, String>();
    map.put("shell.auth.key.path", "~/.ssh/test.pem");
    binder.bind(new MutablePropertyValues(map));
    assertFalse(binder.getBindingResult().hasErrors());

    Properties p = new Properties();
    props.applyToCrshShellConfig(p);

    assertEquals("~/.ssh/test.pem", p.get("crash.auth.key.path"));
View Full Code Here

TOP

Related Classes of org.springframework.boot.bind.RelaxedDataBinder

Copyright © 2018 www.massapicom. 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.