spring-framework / org.springframework.test.context.support / TestPropertySourceUtils / addPropertiesFilesToEnvironment

addPropertiesFilesToEnvironment

open static fun addPropertiesFilesToEnvironment(context: ConfigurableApplicationContext, vararg locations: String): Unit

Add the Properties files from the given resource locations to the Environment of the supplied context.

This method simply delegates to #addPropertiesFilesToEnvironment(ConfigurableEnvironment, ResourceLoader, String...).

Parameters

context - the application context whose environment should be updated; never null

locations - the resource locations of Properties files to add to the environment; potentially empty but never null

Exceptions

IllegalStateException - if an error occurs while processing a properties file

Since
4.1.5

See Also
ResourcePropertySourceTestPropertySource#locations#addPropertiesFilesToEnvironment(ConfigurableEnvironment, ResourceLoader, String...)

open static fun addPropertiesFilesToEnvironment(environment: ConfigurableEnvironment, resourceLoader: ResourceLoader, vararg locations: String): Unit

Add the Properties files from the given resource locations to the supplied ConfigurableEnvironment.

Property placeholders in resource locations (i.e., ${...}) will be resolved against the Environment.

Each properties file will be converted to a ResourcePropertySource that will be added to the PropertySources of the environment with highest precedence.

Parameters

environment - the environment to update; never null

resourceLoader - the ResourceLoader to use to load each resource; never null

locations - the resource locations of Properties files to add to the environment; potentially empty but never null

Exceptions

IllegalStateException - if an error occurs while processing a properties file

Since
4.3

See Also
ResourcePropertySourceTestPropertySource#locations#addPropertiesFilesToEnvironment(ConfigurableApplicationContext, String...)