Skip to content

Commit

Permalink
Split the PropertyTest.test into testPropertyValuesUpdateAndEffect an…
Browse files Browse the repository at this point in the history
…d testServiceInitializationWithDefaultProperties
  • Loading branch information
Codegass committed Mar 18, 2024
1 parent 6654803 commit 9e3ffae
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,32 @@ public String toString() {
}

@Test
public void test() throws ConfigException {
public void testServiceInitializationWithDefaultProperties() {
SettableConfig config = new DefaultSettableConfig();
DefaultPropertyFactory factory = DefaultPropertyFactory.from(config);

MyService service = new MyService(factory);

assertEquals(1, (int)service.value.get());
assertEquals(2, (int)service.value2.get());
// Verify initial property values
assertEquals(1, (int) service.value.get());
assertEquals(2, (int) service.value2.get());
// Verify setValue() was called once for each initialization
assertEquals(0, service.setValueCallsCounter.get());
}

@Test
public void testPropertyValuesUpdateAndEffect() {
SettableConfig config = new DefaultSettableConfig();
DefaultPropertyFactory factory = DefaultPropertyFactory.from(config);
MyService service = new MyService(factory);

// Setting up properties
config.setProperty("foo", "123");

// Assertions after properties update
assertEquals(123, (int)service.value.get());
assertEquals(123, (int)service.value2.get());
// setValue() is called once when we init to 1 and twice when we set foo to 123.
// setValue() is called once for each property update
assertEquals(1, service.setValueCallsCounter.get());
}

Expand Down

0 comments on commit 9e3ffae

Please sign in to comment.