PropertySourceChangeSupport { public void scheduleChangeMonitor(Supplier<Map<String, PropertyValue>> propertySupplier, long duration, TimeUnit timeUnit){ if(changeSupport==ChangeSupport.SUPPORTED) { Objects.requireNonNull(propertySupplier); scheduleTask = executorService.schedule(() -> { load(propertySupplier.get()); }, duration, timeUnit); } } PropertySourceChangeSupport(ChangeSupport changeSupport,
                                       PropertySource propertySource); ChangeSupport getChangeSupport(); String getVersion(); void addChangeListener(BiConsumer<Set<String>, PropertySource> l); void removeChangeListener(BiConsumer<Set<String>, PropertySource> l); void removeAllChangeListeners(); long load(Map<String, PropertyValue> properties); PropertyValue getValue(String key); Map<String, PropertyValue> getProperties(); void scheduleChangeMonitor(Supplier<Map<String, PropertyValue>> propertySupplier, long duration, TimeUnit timeUnit); void cancelSchedule();  }
@Test public void scheduleChangeMonitor() throws InterruptedException { PropertySource ps = BuildablePropertySource.builder().withName("test") .withSimpleProperty("foo", "bar").build(); PropertySourceChangeSupport support = new PropertySourceChangeSupport(ChangeSupport.SUPPORTED, ps); support.load(ps.getProperties()); String v1 = support.getVersion(); support.scheduleChangeMonitor(() -> Collections.emptyMap(), 500, TimeUnit.MILLISECONDS); Thread.sleep(600L); String v2 = support.getVersion(); assertThat(v1).isNotEqualTo(v2); }