blob: a3e14539cab239365ded643146ecf36039ddb8f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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));
}
}
|