@TestPropertySource funktioniert nicht für JUnit test mit AnnotationConfigContextLoader im Frühjahr 1.2.6

Es scheint nicht, dass alles, was ich tun, im Frühjahr 4.1.17 mit Spring Boot 1.2.6.RELEASE überhaupt funktioniert. Ich will einfach nur Zugriff auf die Eigenschaften der Anwendung und überschreiben Sie Sie mit dem test, wenn notwendig (nicht über den hack zu injizieren PropertySource manuell)

dieser funktioniert nicht..

@TestPropertySource(properties = {"elastic.index=test_index"})

auch nicht dazu..

@TestPropertySource(locations = "/classpath:document.properties")

nicht so..

@PropertySource("classpath:/document.properties")

vollständigen Testfall..

@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);
    }
}

was in

org.junit.ComparisonFailure: 
Expected :test_index
Actual   :${elastic.index}

Scheint es es gibt eine Menge von widersprüchlichen Informationen, zwischen 3.x und 4.x und ich kann nichts finden, dass wird sicher arbeiten.

Jede Einsicht wäre dankbar geschätzt. Prost!

Schreibe einen Kommentar