@ -64,7 +64,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testBasicPropertiesBinding ( ) {
public void testBasicPropertiesBinding ( ) {
this . context . register ( TestConfiguration . class ) ;
this . context . register ( TestConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( 1 , this . context . getBeanNamesForType ( TestProperties . class ) . length ) ;
assertEquals ( 1 , this . context . getBeanNamesForType ( TestProperties . class ) . length ) ;
assertEquals ( "foo" , this . context . getBean ( TestProperties . class ) . name ) ;
assertEquals ( "foo" , this . context . getBean ( TestProperties . class ) . name ) ;
@ -105,7 +105,7 @@ public class EnableConfigurationPropertiesTests {
public void testStrictPropertiesBinding ( ) {
public void testStrictPropertiesBinding ( ) {
removeSystemProperties ( ) ;
removeSystemProperties ( ) ;
this . context . register ( StrictTestConfiguration . class ) ;
this . context . register ( StrictTestConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( 1 ,
assertEquals ( 1 ,
this . context . getBeanNamesForType ( StrictTestProperties . class ) . length ) ;
this . context . getBeanNamesForType ( StrictTestProperties . class ) . length ) ;
@ -115,7 +115,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testPropertiesEmbeddedBinding ( ) {
public void testPropertiesEmbeddedBinding ( ) {
this . context . register ( EmbeddedTestConfiguration . class ) ;
this . context . register ( EmbeddedTestConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "spring_foo_name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "spring_foo_name:foo" ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( 1 ,
assertEquals ( 1 ,
this . context . getBeanNamesForType ( EmbeddedTestProperties . class ) . length ) ;
this . context . getBeanNamesForType ( EmbeddedTestProperties . class ) . length ) ;
@ -126,7 +126,7 @@ public class EnableConfigurationPropertiesTests {
public void testIgnoreNestedPropertiesBinding ( ) {
public void testIgnoreNestedPropertiesBinding ( ) {
removeSystemProperties ( ) ;
removeSystemProperties ( ) ;
this . context . register ( IgnoreNestedTestConfiguration . class ) ;
this . context . register ( IgnoreNestedTestConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" , "nested.name:bar" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" , "nested.name:bar" ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( 1 ,
assertEquals ( 1 ,
this . context . getBeanNamesForType ( IgnoreNestedTestProperties . class ) . length ) ;
this . context . getBeanNamesForType ( IgnoreNestedTestProperties . class ) . length ) ;
@ -136,7 +136,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testExceptionOnValidation ( ) {
public void testExceptionOnValidation ( ) {
this . context . register ( ExceptionIfInvalidTestConfiguration . class ) ;
this . context . register ( ExceptionIfInvalidTestConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" ) ;
this . expected . expectCause ( Matchers . < Throwable > instanceOf ( BindException . class ) ) ;
this . expected . expectCause ( Matchers . < Throwable > instanceOf ( BindException . class ) ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
}
}
@ -144,7 +144,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testNoExceptionOnValidation ( ) {
public void testNoExceptionOnValidation ( ) {
this . context . register ( NoExceptionIfInvalidTestConfiguration . class ) ;
this . context . register ( NoExceptionIfInvalidTestConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals (
assertEquals (
1 ,
1 ,
@ -156,7 +156,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testNestedPropertiesBinding ( ) {
public void testNestedPropertiesBinding ( ) {
this . context . register ( NestedConfiguration . class ) ;
this . context . register ( NestedConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" , "nested.name:bar" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" , "nested.name:bar" ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( 1 , this . context . getBeanNamesForType ( NestedProperties . class ) . length ) ;
assertEquals ( 1 , this . context . getBeanNamesForType ( NestedProperties . class ) . length ) ;
assertEquals ( "foo" , this . context . getBean ( NestedProperties . class ) . name ) ;
assertEquals ( "foo" , this . context . getBean ( NestedProperties . class ) . name ) ;
@ -166,7 +166,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testBasicPropertiesBindingWithAnnotationOnBaseClass ( ) {
public void testBasicPropertiesBindingWithAnnotationOnBaseClass ( ) {
this . context . register ( DerivedConfiguration . class ) ;
this . context . register ( DerivedConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( 1 , this . context . getBeanNamesForType ( DerivedProperties . class ) . length ) ;
assertEquals ( 1 , this . context . getBeanNamesForType ( DerivedProperties . class ) . length ) ;
assertEquals ( "foo" , this . context . getBean ( BaseProperties . class ) . name ) ;
assertEquals ( "foo" , this . context . getBean ( BaseProperties . class ) . name ) ;
@ -175,7 +175,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testArrayPropertiesBinding ( ) {
public void testArrayPropertiesBinding ( ) {
this . context . register ( TestConfiguration . class ) ;
this . context . register ( TestConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" , "array:1,2,3" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" , "array:1,2,3" ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( 1 , this . context . getBeanNamesForType ( TestProperties . class ) . length ) ;
assertEquals ( 1 , this . context . getBeanNamesForType ( TestProperties . class ) . length ) ;
assertEquals ( 3 , this . context . getBean ( TestProperties . class ) . getArray ( ) . length ) ;
assertEquals ( 3 , this . context . getBean ( TestProperties . class ) . getArray ( ) . length ) ;
@ -184,7 +184,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testCollectionPropertiesBindingFromYamlArray ( ) {
public void testCollectionPropertiesBindingFromYamlArray ( ) {
this . context . register ( TestConfiguration . class ) ;
this . context . register ( TestConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" , "list[0]:1" , "list[1]:2" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" , "list[0]:1" , "list[1]:2" ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( 2 , this . context . getBean ( TestProperties . class ) . getList ( ) . size ( ) ) ;
assertEquals ( 2 , this . context . getBean ( TestProperties . class ) . getList ( ) . size ( ) ) ;
}
}
@ -192,7 +192,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testPropertiesBindingWithoutAnnotation ( ) {
public void testPropertiesBindingWithoutAnnotation ( ) {
this . context . register ( MoreConfiguration . class ) ;
this . context . register ( MoreConfiguration . class ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( 1 , this . context . getBeanNamesForType ( MoreProperties . class ) . length ) ;
assertEquals ( 1 , this . context . getBeanNamesForType ( MoreProperties . class ) . length ) ;
assertEquals ( "foo" , this . context . getBean ( MoreProperties . class ) . name ) ;
assertEquals ( "foo" , this . context . getBean ( MoreProperties . class ) . name ) ;
@ -227,7 +227,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testBindingDirectlyToFileResolvedFromEnvironment ( ) {
public void testBindingDirectlyToFileResolvedFromEnvironment ( ) {
SpringBootTestUtils . addEnviro ment( this . context , "binding.location:classpath:other.yml" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "binding.location:classpath:other.yml" ) ;
this . context . register ( ResourceBindingProperties . class , TestConfiguration . class ) ;
this . context . register ( ResourceBindingProperties . class , TestConfiguration . class ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( 1 ,
assertEquals ( 1 ,
@ -268,7 +268,7 @@ public class EnableConfigurationPropertiesTests {
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext ( ) ;
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext ( ) ;
parent . register ( TestConfiguration . class ) ;
parent . register ( TestConfiguration . class ) ;
parent . refresh ( ) ;
parent . refresh ( ) ;
SpringBootTestUtils . addEnviro ment( this . context , "name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "name:foo" ) ;
this . context . setParent ( parent ) ;
this . context . setParent ( parent ) ;
this . context . register ( TestConfiguration . class , TestConsumer . class ) ;
this . context . register ( TestConfiguration . class , TestConsumer . class ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
@ -280,7 +280,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testBindingOnlyParentContext ( ) {
public void testBindingOnlyParentContext ( ) {
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext ( ) ;
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext ( ) ;
SpringBootTestUtils . addEnviro ment( parent , "name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( parent , "name:foo" ) ;
parent . register ( TestConfiguration . class ) ;
parent . register ( TestConfiguration . class ) ;
parent . refresh ( ) ;
parent . refresh ( ) ;
this . context . setParent ( parent ) ;
this . context . setParent ( parent ) ;
@ -293,7 +293,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testUnderscoresInPrefix ( ) throws Exception {
public void testUnderscoresInPrefix ( ) throws Exception {
SpringBootTestUtils . addEnviro ment( this . context , "spring_test_external_val:baz" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "spring_test_external_val:baz" ) ;
this . context . register ( SystemExampleConfig . class ) ;
this . context . register ( SystemExampleConfig . class ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( "baz" , this . context . getBean ( SystemEnvVar . class ) . getVal ( ) ) ;
assertEquals ( "baz" , this . context . getBean ( SystemEnvVar . class ) . getVal ( ) ) ;
@ -301,7 +301,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testSimpleAutoConfig ( ) throws Exception {
public void testSimpleAutoConfig ( ) throws Exception {
SpringBootTestUtils . addEnviro ment( this . context , "external.name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "external.name:foo" ) ;
this . context . register ( ExampleConfig . class ) ;
this . context . register ( ExampleConfig . class ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( "foo" , this . context . getBean ( External . class ) . getName ( ) ) ;
assertEquals ( "foo" , this . context . getBean ( External . class ) . getName ( ) ) ;
@ -309,7 +309,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testExplicitType ( ) throws Exception {
public void testExplicitType ( ) throws Exception {
SpringBootTestUtils . addEnviro ment( this . context , "external.name:foo" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "external.name:foo" ) ;
this . context . register ( AnotherExampleConfig . class ) ;
this . context . register ( AnotherExampleConfig . class ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( "foo" , this . context . getBean ( External . class ) . getName ( ) ) ;
assertEquals ( "foo" , this . context . getBean ( External . class ) . getName ( ) ) ;
@ -317,7 +317,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public void testMultipleExplicitTypes ( ) throws Exception {
public void testMultipleExplicitTypes ( ) throws Exception {
SpringBootTestUtils . addEnviro ment( this . context , "external.name:foo" , "another.name:bar" ) ;
SpringBootTestUtils . addEnviro n ment( this . context , "external.name:foo" , "another.name:bar" ) ;
this . context . register ( FurtherExampleConfig . class ) ;
this . context . register ( FurtherExampleConfig . class ) ;
this . context . refresh ( ) ;
this . context . refresh ( ) ;
assertEquals ( "foo" , this . context . getBean ( External . class ) . getName ( ) ) ;
assertEquals ( "foo" , this . context . getBean ( External . class ) . getName ( ) ) ;