本文整理汇总了Java中org.springframework.boot.bind.RelaxedDataBinder.bind方法的典型用法代码示例。如果您正苦于以下问题:Java RelaxedDataBinder.bind方法的具体用法?Java RelaxedDataBinder.bind怎么用?Java RelaxedDataBinder.bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.boot.bind.RelaxedDataBinder
的用法示例。
在下文中一共展示了RelaxedDataBinder.bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMatchOutcome
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
ConfigurableEnvironment environment = (ConfigurableEnvironment) context
.getEnvironment();
ResourceProperties properties = new ResourceProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
Boolean match = properties.getChain().getEnabled();
if (match == null) {
boolean webJarsLocatorPresent = ClassUtils.isPresent(WEBJAR_ASSERT_LOCATOR,
getClass().getClassLoader());
return new ConditionOutcome(webJarsLocatorPresent,
"Webjars locator (" + WEBJAR_ASSERT_LOCATOR + ") is "
+ (webJarsLocatorPresent ? "present" : "absent"));
}
return new ConditionOutcome(match,
"Resource chain is " + (match ? "enabled" : "disabled"));
}
示例2: testBindingSsh
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@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"));
}
示例3: testBindingSshIgnored
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@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"));
}
示例4: testBindingSimple
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testBindingSimple() {
SimpleAuthenticationProperties props = new SimpleAuthenticationProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell.auth.simple");
binder.setConversionService(new DefaultConversionService());
Map<String, String> map = new HashMap<String, String>();
map.put("shell.auth.simple.user.name", "username123");
map.put("shell.auth.simple.user.password", "password123");
binder.bind(new MutablePropertyValues(map));
assertFalse(binder.getBindingResult().hasErrors());
Properties p = new Properties();
props.applyToCrshShellConfig(p);
assertEquals("username123", p.get("crash.auth.simple.username"));
assertEquals("password123", p.get("crash.auth.simple.password"));
}
示例5: getExcludeAutoConfigurationsProperty
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
private List<String> getExcludeAutoConfigurationsProperty() {
if (getEnvironment() instanceof ConfigurableEnvironment) {
Excludes excludes = new Excludes();
RelaxedDataBinder binder = new RelaxedDataBinder(excludes,
"spring.autoconfigure.");
binder.bind(new PropertySourcesPropertyValues(
((ConfigurableEnvironment) getEnvironment()).getPropertySources()));
return excludes.getExclude();
}
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(getEnvironment(),
"spring.autoconfigure.");
String[] exclude = resolver.getProperty("exclude", String[].class);
return (Arrays.asList(exclude == null ? new String[0] : exclude));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:EnableAutoConfigurationImportSelector.java
示例6: testAddressBinding
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@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"));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ServerPropertiesTests.java
示例7: testServerHeader
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@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");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:ServerPropertiesTests.java
示例8: testServletPathAsMapping
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testServletPathAsMapping() 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");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ServerPropertiesTests.java
示例9: testServletPathAsPrefix
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@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");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ServerPropertiesTests.java
示例10: preInit
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Override
public void preInit(SpringProcessEngineConfiguration springProcessEngineConfiguration) {
GenericProperties genericProperties = camundaBpmProperties.getGenericProperties();
final Map<String, Object> properties = genericProperties.getProperties();
if (!CollectionUtils.isEmpty(properties)) {
RelaxedDataBinder relaxedDataBinder = new RelaxedDataBinder(springProcessEngineConfiguration);
relaxedDataBinder.setIgnoreInvalidFields(genericProperties.isIgnoreInvalidFields());
relaxedDataBinder.setIgnoreUnknownFields(genericProperties.isIgnoreUnknownFields());
relaxedDataBinder.bind(getPropertyValues(properties));
logger.debug("properties bound to configuration: {}", genericProperties);
}
}
示例11: testBindingAuth
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@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());
}
示例12: testServletPathAsMapping
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@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());
}
示例13: testBindingCommandRefreshInterval
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@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());
}
示例14: testBindingCommandPathPatterns
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@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());
}
示例15: testBindingConfigPathPatterns
import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@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());
}