BrooklynFeatureEnablement { public static boolean isEnabled(String property) { synchronized (MUTEX) { if (FEATURE_ENABLEMENTS.containsKey(property)) { return FEATURE_ENABLEMENTS.get(property); } else if (System.getProperty(property) != null) { String rawVal = System.getProperty(property); return Boolean.parseBoolean(rawVal); } else if (FEATURE_ENABLEMENTS_PROPERTIES.containsKey(property)) { return FEATURE_ENABLEMENTS_PROPERTIES.get(property); } else if (FEATURE_ENABLEMENT_DEFAULTS.containsKey(property)) { return FEATURE_ENABLEMENT_DEFAULTS.get(property); } else { return false; } } }  static boolean isEnabled(String property); static void init(BrooklynProperties props); static boolean enable(String property); static boolean disable(String property); static boolean setEnablement(String property, boolean val); static void setDefault(String property, boolean val); @VisibleForTesting static void clearCache(); static final String FEATURE_PROPERTY_PREFIX; static final String FEATURE_POLICY_PERSISTENCE_PROPERTY; static final String FEATURE_ENRICHER_PERSISTENCE_PROPERTY; static final String FEATURE_FEED_PERSISTENCE_PROPERTY; static final String FEATURE_REFERENCED_OBJECTS_REPERSISTENCE_PROPERTY; static final String FEATURE_FEED_REGISTRATION_PROPERTY; static final String FEATURE_CORS_CXF_PROPERTY; static final String FEATURE_BUNDLE_PERSISTENCE_PROPERTY; static final String FEATURE_CATALOG_PERSISTENCE_PROPERTY; static final String FEATURE_DEFAULT_STANDBY_IS_HOT_PROPERTY; static final String FEATURE_PERSIST_ENTITY_SPEC_AS_SUPPLIER; static final String FEATURE_RENAME_THREADS; static final String FEATURE_JITTER_THREADS; static final String FEATURE_BACKWARDS_COMPATIBILITY_INFER_CATALOG_ITEM_ON_REBIND; static final String FEATURE_AUTO_FIX_CATALOG_REF_ON_REBIND; static final String FEATURE_SSH_ASYNC_EXEC; static final String FEATURE_VALIDATE_LOCATION_SSH_KEYS; }
@Test public void testDefaultIsNotEnabled() throws Exception { assertFalse(BrooklynFeatureEnablement.isEnabled("feature.not.referenced.anywhere")); }
@Test public void testReadsEnablementFromProperties() throws Exception { String featureProperty = "brooklyn.experimental.feature.testReadsEnablementFromProperties"; System.setProperty(featureProperty, "true"); try { assertTrue(BrooklynFeatureEnablement.isEnabled(featureProperty)); } finally { System.clearProperty(featureProperty); } }