I would like to have a properties setup which can, on certain environments, override specific properties. For example, our default JDBC properties for dev are:
I had a similar issue with overwriting already existing properties in integration tests
I came up with this solution:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {
SomeProdConfig.class,
MyWebTest.TestConfig.class
})
@WebIntegrationTest
public class MyWebTest {
@Configuration
public static class TestConfig {
@Inject
private Environment env;
@PostConstruct
public void overwriteProperties() throws Exception {
final Map systemProperties = ((ConfigurableEnvironment) env)
.getSystemProperties();
systemProperties.put("some.prop", "test.value");
}
}