@ -34,6 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
@@ -34,6 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/ * *
* @author Chris Beams
* @author Yanming Zhou
* @since 3 . 1
* /
class PropertySourcesPropertyResolverTests {
@ -300,6 +301,43 @@ class PropertySourcesPropertyResolverTests {
@@ -300,6 +301,43 @@ class PropertySourcesPropertyResolverTests {
. withMessageContaining ( "Circular" ) ;
}
@Test
void resolveNestedPlaceholdersIfValueIsCharSequence ( ) {
MutablePropertySources ps = new MutablePropertySources ( ) ;
ps . addFirst ( new MockPropertySource ( )
. withProperty ( "p1" , "v1" )
. withProperty ( "p2" , "v2" )
. withProperty ( "p3" , new CharSequence ( ) {
static final String underlying = "${p1}:${p2}" ;
@Override
public int length ( ) {
return underlying . length ( ) ;
}
@Override
public char charAt ( int index ) {
return underlying . charAt ( index ) ;
}
@Override
public CharSequence subSequence ( int start , int end ) {
return underlying . subSequence ( start , end ) ;
}
@Override
public String toString ( ) {
return underlying ;
}
} )
) ;
ConfigurablePropertyResolver pr = new PropertySourcesPropertyResolver ( ps ) ;
assertThat ( pr . getProperty ( "p1" ) ) . isEqualTo ( "v1" ) ;
assertThat ( pr . getProperty ( "p2" ) ) . isEqualTo ( "v2" ) ;
assertThat ( pr . getProperty ( "p3" ) ) . isEqualTo ( "v1:v2" ) ;
}
@Test
void ignoreUnresolvableNestedPlaceholdersIsConfigurable ( ) {
MutablePropertySources ps = new MutablePropertySources ( ) ;