Кажется, что ничего в Spring 4.1.17 с Spring Boot 1.2.6.RELEASE работает вообще. Я просто хочу получить доступ к свойствам приложения и, при необходимости, переопределить их при необходимости (без использования взлома для непосредственного ввода PropertySource)
это не работает.
@TestPropertySource(properties = {"elastic.index=test_index"})
и не делает этого.
@TestPropertySource(locations = "/classpath:document.properties")
и не..
@PropertySource("classpath:/document.properties")
полный тестовый сценарий.
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
@TestPropertySource(properties = {"elastic.index=test_index"})
public class PropertyTests {
@Value("${elastic.index}")
String index;
@Configuration
@TestPropertySource(properties = {"elastic.index=test_index"})
static class ContextConfiguration {
}
@Test
public void wtf() {
assertEquals("test_index", index);
}
}
в результате чего
org.junit.ComparisonFailure:
Expected :test_index
Actual :${elastic.index}
Кажется, что существует много противоречивой информации между 3.x и 4.x, и я не могу найти ничего, что сработает наверняка.
Любое понимание будет с благодарностью оценено. Ура!