Using Spring 4, I've got the following test setup:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = JpaConfig.class)
@ActiveProfiles(resolver = TestResolver.class)
public class SimpleTest {
The TestResolver has been implemented as:
public class TestResolver implements ActiveProfilesResolver {
@Override
public String[] resolve(Class<?> aClass) {
String[] profiles = new String[1];
profiles[0] = "test";
return profiles;
}
}
JpaConfig has been annotated with PropertySource
@Configuration
@PropertySource("classpath:properties/application-${spring.profiles.active:dev}.properties")
@EnableJpaRepositories(basePackages={"com.my.namespace.repositories"})
public class JpaConfig {
Whenever I run the SimpleTest it tries to locate: properties/application-dev.properties while I expected it to be properties/application-test.properties.
What's I'm trying to accomplish here has been based on the following post: Spring integration tests with profile