Support resource patterns in @TestPropertySource locations
Inspired by the recently added support for resource patterns in
@PropertySource locations, this commit adds the same support for
resource locations in @TestPropertySource.
For example, assuming the `config` folder in the classpath contains
only 3 files matching the pattern `file?.properties`,
... the following:
@TestPropertySource("classpath:/config/file1.properties")
@TestPropertySource("classpath:/config/file2.properties")
@TestPropertySource("classpath:/config/file3.properties")
... or:
@TestPropertySource({
"classpath:/config/file1.properties",
"classpath:/config/file2.properties",
"classpath:/config/file3.properties"
})
... can now be replaced by:
@TestPropertySource("classpath*:/config/file?.properties")
See gh-21325
Closes gh-31055
This commit is contained in:
1
spring-test/src/test/resources/org/springframework/test/context/env/pattern/file1.properties
vendored
Normal file
1
spring-test/src/test/resources/org/springframework/test/context/env/pattern/file1.properties
vendored
Normal file
@@ -0,0 +1 @@
|
||||
from.p1 = 1
|
||||
1
spring-test/src/test/resources/org/springframework/test/context/env/pattern/file2.properties
vendored
Normal file
1
spring-test/src/test/resources/org/springframework/test/context/env/pattern/file2.properties
vendored
Normal file
@@ -0,0 +1 @@
|
||||
from.p2 = 2
|
||||
1
spring-test/src/test/resources/org/springframework/test/context/env/pattern/file3.properties
vendored
Normal file
1
spring-test/src/test/resources/org/springframework/test/context/env/pattern/file3.properties
vendored
Normal file
@@ -0,0 +1 @@
|
||||
from.p3 = 3
|
||||
Reference in New Issue
Block a user