Polish (Mutable)PropertySources

* PropertySources is now an Iterable<PropertySource> in favor of
  exposing an asList() method
* Otherwise reduced the set of methods exposed by PropertySources to the
  absolute minimum
* Added Javadoc for both types and all methods

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3865 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Chris Beams
2011-01-05 22:25:24 +00:00
parent d29eae3ba0
commit 0821b2c6c2
7 changed files with 174 additions and 114 deletions
@@ -438,16 +438,16 @@ public class EnvironmentIntegrationTests {
// ServletConfig gets precedence
assertThat(environment.getProperty("pCommon"), is("pCommonConfigValue"));
assertThat(propertySources.asList().indexOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.asList().indexOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME))));
assertThat(propertySources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME))));
// but all params are available
assertThat(environment.getProperty("pContext1"), is("pContext1Value"));
assertThat(environment.getProperty("pConfig1"), is("pConfig1Value"));
// Servlet* PropertySources have precedence over System* PropertySources
assertThat(propertySources.asList().indexOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.asList().indexOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
assertThat(propertySources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
// Replace system properties with a mock property source for convenience
MockPropertySource mockSystemProperties = new MockPropertySource(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
@@ -480,8 +480,8 @@ public class EnvironmentIntegrationTests {
assertThat(environment.getProperty("pContext1"), is("pContext1Value"));
// Servlet* PropertySources have precedence over System* PropertySources
assertThat(propertySources.asList().indexOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.asList().indexOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
assertThat(propertySources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
// Replace system properties with a mock property source for convenience
MockPropertySource mockSystemProperties = new MockPropertySource(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
@@ -515,16 +515,16 @@ public class EnvironmentIntegrationTests {
// ServletConfig gets precedence
assertThat(environment.getProperty("pCommon"), is("pCommonConfigValue"));
assertThat(propertySources.asList().indexOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.asList().indexOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME))));
assertThat(propertySources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME))));
// but all params are available
assertThat(environment.getProperty("pContext1"), is("pContext1Value"));
assertThat(environment.getProperty("pConfig1"), is("pConfig1Value"));
// Servlet* PropertySources have precedence over System* PropertySources
assertThat(propertySources.asList().indexOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.asList().indexOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
assertThat(propertySources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
// Replace system properties with a mock property source for convenience
MockPropertySource mockSystemProperties = new MockPropertySource(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);