diff options
author | Ofir Sonsino <os0695@intl.att.com> | 2018-08-12 12:20:55 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-08-12 12:20:55 +0000 |
commit | 91b057331b92ecf7f3c2d495681b05295dc8346c (patch) | |
tree | 0ce3f821ada8ad518784f7f9869db4b537ba3237 /vid-automation/src/main/java/vid/automation/test/infra/FeaturesTogglingConfiguration.java | |
parent | 9152b2ae03c4751b492a219993d85d522c58b383 (diff) | |
parent | 4a4dcc5185f8ba5a28c7f9fef509f32c0c2389e6 (diff) |
Merge "vid-automation selenium tests"
Diffstat (limited to 'vid-automation/src/main/java/vid/automation/test/infra/FeaturesTogglingConfiguration.java')
-rw-r--r-- | vid-automation/src/main/java/vid/automation/test/infra/FeaturesTogglingConfiguration.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/vid-automation/src/main/java/vid/automation/test/infra/FeaturesTogglingConfiguration.java b/vid-automation/src/main/java/vid/automation/test/infra/FeaturesTogglingConfiguration.java new file mode 100644 index 00000000..a3e14539 --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/infra/FeaturesTogglingConfiguration.java @@ -0,0 +1,52 @@ +package vid.automation.test.infra; + + +import org.apache.commons.io.FileUtils; +import org.togglz.core.context.StaticFeatureManagerProvider; +import org.togglz.core.manager.FeatureManager; +import org.togglz.core.manager.FeatureManagerBuilder; +import org.togglz.core.repository.StateRepository; +import org.togglz.core.repository.file.FileBasedStateRepository; + +import java.io.File; +import java.io.IOException; +import java.net.URL; + +import static org.apache.commons.codec.Charsets.UTF_8; + + +public class FeaturesTogglingConfiguration { + + private static FeatureManager createFeatureManager() { + return new FeatureManagerBuilder() + .featureEnum(Features.class) + .stateRepository(getStateRepository()) + .build(); + } + + public static void initializeFeatureManager(){ + StaticFeatureManagerProvider.setFeatureManager(createFeatureManager()); + for (Features feature : Features.values()) { + System.out.println("FeaturesTogglingConfiguration: " + feature.name() + ": " + feature.isActive()); + } + } + + private static StateRepository getStateRepository() { + + final URL propertiesAsResource = FeaturesTogglingConfiguration.class.getClassLoader().getResource("features.properties"); + + final String featuresFile = + System.getProperty( + "FEATURES_FILE", + propertiesAsResource != null ? propertiesAsResource.getFile() : null + ); + + System.out.println("features file: " + featuresFile); + try { + System.out.println(FileUtils.readFileToString(new File(featuresFile), UTF_8)); + } catch (IOException e) { + // YOLO + } + return new FileBasedStateRepository(new File(featuresFile)); + } +} |