In application.yml I have a list of custom configuration for caching.
caches:
- name: cache1
ttl: 30
- name: cache2
ttl: 60
I have an integration test and I want to override the values specified in application.yaml from external file.
I have several external cache configuration file for different tests, test-caches-1.yml, test-caches-2.yml, etc. The contents of file look simple
caches:
- name: test-cache1
ttl: 30
- name: test-cache2
ttl: 60
Here is my test
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@ContextConfiguration(classes = MyApplication.class)
@RunWith(SpringRunner.class)
@ActiveProfiles("test")
@TestPropertySource(
properties = { "features.distributed-cache = true" },
locations = {"classpath:/caches-configuratilon/test-caches.yml"})
public class CachingConfigurationTest {
@Autowired
CachesConfigurationProperties cachesConfigurationProperties;
@Test
public void myTest() {
// ...
}
}
If I remove locations = {"classpath:/caches-configuratilon/test-caches.yml"} attribute during test execution I see all caches from application.yml. If I put the contents of test-caches.yml to application-test.yml I see caches configured there.
But when I put those caches to test-caches.yml there is nothing. Any ideas how can I override a values from application.yml with a values from external file test-caches.yml?
Aucun commentaire:
Enregistrer un commentaire