I tried to follow the Togglz guide for Spring Boot, so added all necessary dependencies, created a feature enum:
public enum RetrospectiveBoardFeatures implements Feature {
@Label("Name by cookie")
NAME_BY_COOKIE,
@Label("Name by login")
NAME_BY_LOGIN;
public boolean isActive() {
return FeatureContext.getFeatureManager().isActive(this);
}
}
, configured a EnumBasedFeatureProvider to make that enum known to Spring/Togglz:
@SpringBootApplication
public class Application {
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public FeatureProvider featureProvider() {
return new EnumBasedFeatureProvider(RetrospectiveBoardFeatures.class);
}
}
This all works fine until I wrote a small unit test to see if the feature toggle configuration is applied to my enum (from application.yml):
togglz:
features:
NAME_BY_COOKIE:
enabled: true
NAME_BY_LOGIN:
enabled: false
Test:
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = Application.class)
public class RetrospetiveBoardFeaturesTest {
@Test
public void testCookieFeature() {
assertThat(RetrospetiveBoardFeatures.NAME_BY_COOKIE.isActive(), is(true));
}
}
So my expected result was not met (feature active). Then I added the enabled by default annotation and my feature got active. According to the guide (how I understood it) I don't need to add anything that reads my configuration from Spring and make them known to Togglz. The Togglz samples on GitHub also didn't do anything in this regard (and by looking what Togglz provide in the Spring-Boot starter there is a feature property provider already set up). Maybe I have some wrong versions selected (Spring boot 2.0.1.RELEASE and Togglz 2.5.0.Final)? What did I wrong?