Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ConfigManagerTest to Include Assertions for Automated Validation #711

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
package com.netflix.archaius;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.concurrent.atomic.AtomicReference;

import com.netflix.archaius.api.Property;
import com.netflix.archaius.api.PropertyFactory;
import com.netflix.archaius.config.DefaultCompositeConfig;
Expand All @@ -39,19 +43,26 @@ public void testBasicReplacement() throws ConfigException {
.put("region", "us-east")
.put("c", 123)
.build()));


PropertyFactory factory = DefaultPropertyFactory.from(config);

Property<String> prop = factory.getProperty("abc").asString("defaultValue");


// Use an AtomicReference to capture the property value change
AtomicReference<String> capturedValue = new AtomicReference<>("");
prop.addListener(new DefaultPropertyListener<String>() {
@Override
public void onChange(String next) {
System.out.println("Configuration changed : " + next);
capturedValue.set(next);
}
});


// Set property which should trigger the listener
dyn.setProperty("abc", "${c}");

// Assert that the capturedValue was updated correctly
assertEquals("123", capturedValue.get(), "Configuration change did not occur as expected");

}
}
Loading