Ensure Weblogic and Websphere JMX are covered
To ensure an MBeanServer is available when needed you have to look in JNDI before resorting to the JDK platform factory. I had to copy some private code from Spring, but it seems worth it. Fixes gh-1092
This commit is contained in:
@@ -22,10 +22,12 @@ import javax.validation.constraints.NotNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.Errors;
|
||||
@@ -129,6 +131,16 @@ public class ConfigurationPropertiesBindingPostProcessorTests {
|
||||
equalTo(FooEnum.FOO));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueBindingForDefaults() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "default.value:foo");
|
||||
this.context.register(PropertyWithValue.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(PropertyWithValue.class).getValue(),
|
||||
equalTo("foo"));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties
|
||||
public static class TestConfigurationWithValidatingSetter {
|
||||
@@ -263,4 +275,27 @@ public class ConfigurationPropertiesBindingPostProcessorTests {
|
||||
static enum FooEnum {
|
||||
FOO, BAZ, BAR
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties
|
||||
@ConfigurationProperties(prefix = "test")
|
||||
public static class PropertyWithValue {
|
||||
|
||||
@Value("${default.value}")
|
||||
private String value;
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static PropertySourcesPlaceholderConfigurer configurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user