spring-framework/framework-docs/modules/ROOT/pages/testing
Sam Brannen 04cce0bafd Support custom properties file formats in @TestPropertySource
Spring Framework 4.3 introduced the `PropertySourceFactory` SPI for use
with `@PropertySource` on `@Configuration` classes; however, prior to
this commit there was no mechanism to support custom properties file
formats in `@TestPropertySource` for integration tests.

This commit introduces support for configuring a custom
`PropertySourceFactory` via a new `factory` attribute in
`@TestPropertySource` in order to support custom file formats such as
JSON, YAML, etc.

For example, if you create a YamlPropertySourceFactory, you can use it
in integration tests as follows.

@SpringJUnitConfig
@TestPropertySource(locations = "/test.yaml", factory = YamlPropertySourceFactory.class)
class MyTestClass { /* ... /* }

If a custom factory is not specified, traditional `*.properties` and
`*.xml` based `java.util.Properties` file formats are supported, which
was the existing behavior.

Closes gh-30981
2023-08-04 14:57:22 +03:00
..
annotations Fix link text from "null" to "Component Classes" in Testing chapter 2023-06-22 11:35:23 +02:00
spring-mvc-test-framework Fix migration to asciidoctor tabs 2023-05-09 12:15:43 +01:00
testcontext-framework Support custom properties file formats in @TestPropertySource 2023-08-04 14:57:22 +03:00
annotations.adoc Enable Section Summary TOC for small pages 2023-05-04 15:35:05 +01:00
appendix.adoc Trim IDs with parent 2023-05-04 15:35:05 +01:00
integration.adoc Fix cross references 2023-05-04 15:35:05 +01:00
introduction.adoc Enable Section Summary TOC for small pages 2023-05-04 15:35:05 +01:00
resources.adoc Fix cross references 2023-05-04 15:35:05 +01:00
spring-mvc-test-client.adoc Migrate to Asciidoctor Tabs 2023-05-04 15:35:05 +01:00
spring-mvc-test-framework.adoc Enable Section Summary TOC for small pages 2023-05-04 15:35:05 +01:00
support-jdbc.adoc Fix cross references 2023-05-04 15:35:05 +01:00
testcontext-framework.adoc Enable Section Summary TOC for small pages 2023-05-04 15:35:05 +01:00
unit.adoc Fix cross references 2023-05-04 15:35:05 +01:00
webtestclient.adoc Fix migration to asciidoctor tabs 2023-05-09 12:15:43 +01:00