SystemPropertyHelper { public static Optional<Boolean> getProductBooleanProperty(String name) { String property = getProperty(name); return property != null ? Optional.of(Boolean.parseBoolean(property)) : Optional.empty(); }  static Optional<Boolean> getProductBooleanProperty(String name); static Optional<Integer> getProductIntegerProperty(String name); static Optional<String> getProductStringProperty(String name); static String getProperty(String name); static boolean restoreSetOperationTransactionBehavior(); static boolean restoreIdleExpirationBehavior(); static final String GEODE_PREFIX; static final String GEMFIRE_PREFIX; static final String EVICTION_SCAN_ASYNC; static final String EVICTION_SCAN_MAX_THREADS; static final String EVICTION_SCAN_THRESHOLD_PERCENT; static final String EVICTION_SEARCH_MAX_ENTRIES; static final String EARLY_ENTRY_EVENT_SERIALIZATION; static final String DEFAULT_DISK_DIRS_PROPERTY; static final String HA_REGION_QUEUE_EXPIRY_TIME_PROPERTY; static final String THREAD_ID_EXPIRY_TIME_PROPERTY; static final String PERSISTENT_VIEW_RETRY_TIMEOUT_SECONDS; static final String USE_HTTP_SYSTEM_PROPERTY; static final String PACKAGES_TO_SCAN; static final String PARALLEL_DISK_STORE_RECOVERY; }
@Test public void getBooleanPropertyReturnsEmptyOptionalIfProperiesMissing() { String testProperty = "notSetProperty"; assertThat(SystemPropertyHelper.getProductBooleanProperty(testProperty).isPresent()).isFalse(); }
@Test public void getBooleanPropertyPrefersGeodePrefix() { String testProperty = "testBooleanProperty"; String gemfirePrefixProperty = "gemfire." + testProperty; String geodePrefixProperty = "geode." + testProperty; System.setProperty(geodePrefixProperty, "true"); System.setProperty(gemfirePrefixProperty, "false"); assertThat(SystemPropertyHelper.getProductBooleanProperty(testProperty).get()).isTrue(); System.clearProperty(geodePrefixProperty); System.clearProperty(gemfirePrefixProperty); }
@Test public void getBooleanPropertyReturnsGemfirePrefixIfGeodeMissing() { String testProperty = "testBooleanProperty"; String gemfirePrefixProperty = "gemfire." + testProperty; System.setProperty(gemfirePrefixProperty, "true"); assertThat(SystemPropertyHelper.getProductBooleanProperty(testProperty).get()).isTrue(); System.clearProperty(gemfirePrefixProperty); }
@Test public void getBooleanPropertyParallelDiskStoreRecovery() { assertThat(SystemPropertyHelper .getProductBooleanProperty(SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY).isPresent()) .isFalse(); assertThat(SystemPropertyHelper .getProductBooleanProperty(SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY).orElse(true)) .isTrue(); System.setProperty(SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY, "true"); assertThat(SystemPropertyHelper .getProductBooleanProperty(SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY).isPresent()) .isFalse(); System.setProperty(GEODE_PREFIX + SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY, "true"); assertThat(SystemPropertyHelper .getProductBooleanProperty(SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY).get()) .isTrue(); System.setProperty(GEODE_PREFIX + SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY, "false"); assertThat(SystemPropertyHelper .getProductBooleanProperty(SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY).get()) .isFalse(); System.clearProperty(GEODE_PREFIX + SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY); System.setProperty(GEMFIRE_PREFIX + SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY, "true"); assertThat(SystemPropertyHelper .getProductBooleanProperty(SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY).get()) .isTrue(); System.setProperty(GEMFIRE_PREFIX + SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY, "false"); assertThat(SystemPropertyHelper .getProductBooleanProperty(SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY).get()) .isFalse(); System.setProperty(GEODE_PREFIX + SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY, "true"); System.setProperty(GEMFIRE_PREFIX + SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY, "false"); assertThat(SystemPropertyHelper .getProductBooleanProperty(SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY).get()) .isTrue(); System.clearProperty(SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY); System.clearProperty(GEODE_PREFIX + SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY); System.clearProperty(GEMFIRE_PREFIX + SystemPropertyHelper.PARALLEL_DISK_STORE_RECOVERY); }