on 10-11-2016 5:37 PM
Hi,
I'm having trouble with setting some bean to be active only when spring profile is set to production.
Basically, what happens is that when I run my integration tests,it looks like my production profile is also active, and it shouldn't be.
Relevant part of local_tenant_junit.properties:
spring.profiles.active=myextension_test
myextension's relevant part of project.properties:
spring.profiles.active=myextension_prod
Now the things get interesting. Here is the part of my test class:
@Resource
private Environment environment;
@Resource
private ConfigurationService configurationService;
@Test
public void dummyTest() {
String first = (String ) configurationService.getConfiguration().getProperty("spring.profiles.active");
String[] second = environment.getActiveProfiles();
assertTrue(true);
}
When I run this test, variable "first" has value "myextension_test", and variable "second" has value ["myextension_test", "myextension_prod", "tenant_junit"]. How come that these 2 variables differ? I was expecting only myextension_test profiile to be active. OK, I understand tenant_junit also, but why did Hybris also activated myextension_prod profile ? Looks like local_tenant_junit.properties merged with project.properties, instead of overriding it.
I ran my tests with "ant integrationtests" command.
Did anybody have similar problems?
Thanks in advance, Antun
I managed to make a workaround by using @Conditional annotation, in case anyone is interested.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.