@Test public void testGetIntPropertyMultipleTimesWithPropertyChanges() throws Exception { String someKey = "someKey"; Integer someValue = 2; Integer anotherValue = 3; Integer someDefaultValue = -1; someProperties = new Properties(); someProperties.setProperty(someKey, String.valueOf(someValue)); when(configRepository.getConfig()).thenReturn(someProperties); DefaultConfig defaultConfig = new DefaultConfig(someNamespace, configRepository); assertEquals(someValue, defaultConfig.getIntProperty(someKey, someDefaultValue)); Properties anotherProperties = new Properties(); anotherProperties.setProperty(someKey, String.valueOf(anotherValue)); defaultConfig.onRepositoryChange(someNamespace, anotherProperties); assertEquals(anotherValue, defaultConfig.getIntProperty(someKey, someDefaultValue)); }
@Override public synchronized void onRepositoryChange(String namespace, Properties newProperties) { if (newProperties.equals(m_configProperties.get())) { return; } ConfigSourceType sourceType = m_configRepository.getSourceType(); Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); newConfigProperties.putAll(newProperties); Map<String, ConfigChange> actualChanges = updateAndCalcConfigChanges(newConfigProperties, sourceType); if (actualChanges.isEmpty()) { return; } this.fireConfigChange(new ConfigChangeEvent(m_namespace, actualChanges)); Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace); }
DefaultConfig extends AbstractConfig implements RepositoryChangeListener { @Override public synchronized void onRepositoryChange(String namespace, Properties newProperties) { if (newProperties.equals(m_configProperties.get())) { return; } ConfigSourceType sourceType = m_configRepository.getSourceType(); Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); newConfigProperties.putAll(newProperties); Map<String, ConfigChange> actualChanges = updateAndCalcConfigChanges(newConfigProperties, sourceType); if (actualChanges.isEmpty()) { return; } this.fireConfigChange(new ConfigChangeEvent(m_namespace, actualChanges)); Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace); } }
DefaultConfig extends AbstractConfig implements RepositoryChangeListener { @Override public synchronized void onRepositoryChange(String namespace, Properties newProperties) { if (newProperties.equals(m_configProperties.get())) { return; } ConfigSourceType sourceType = m_configRepository.getSourceType(); Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); newConfigProperties.putAll(newProperties); Map<String, ConfigChange> actualChanges = updateAndCalcConfigChanges(newConfigProperties, sourceType); if (actualChanges.isEmpty()) { return; } this.fireConfigChange(new ConfigChangeEvent(m_namespace, actualChanges)); Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace); } DefaultConfig(String namespace, ConfigRepository configRepository); }
DefaultConfig extends AbstractConfig implements RepositoryChangeListener { @Override public synchronized void onRepositoryChange(String namespace, Properties newProperties) { if (newProperties.equals(m_configProperties.get())) { return; } ConfigSourceType sourceType = m_configRepository.getSourceType(); Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); newConfigProperties.putAll(newProperties); Map<String, ConfigChange> actualChanges = updateAndCalcConfigChanges(newConfigProperties, sourceType); if (actualChanges.isEmpty()) { return; } this.fireConfigChange(new ConfigChangeEvent(m_namespace, actualChanges)); Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace); } DefaultConfig(String namespace, ConfigRepository configRepository); @Override String getProperty(String key, String defaultValue); @Override Set<String> getPropertyNames(); @Override ConfigSourceType getSourceType(); @Override synchronized void onRepositoryChange(String namespace, Properties newProperties); }
DefaultConfig extends AbstractConfig implements RepositoryChangeListener { @Override public synchronized void onRepositoryChange(String namespace, Properties newProperties) { if (newProperties.equals(m_configProperties.get())) { return; } ConfigSourceType sourceType = m_configRepository.getSourceType(); Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); newConfigProperties.putAll(newProperties); Map<String, ConfigChange> actualChanges = updateAndCalcConfigChanges(newConfigProperties, sourceType); if (actualChanges.isEmpty()) { return; } this.fireConfigChange(new ConfigChangeEvent(m_namespace, actualChanges)); Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace); } DefaultConfig(String namespace, ConfigRepository configRepository); @Override String getProperty(String key, String defaultValue); @Override Set<String> getPropertyNames(); @Override ConfigSourceType getSourceType(); @Override synchronized void onRepositoryChange(String namespace, Properties newProperties);  }