Skip to content
Open
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 @@ -471,4 +471,48 @@ void testGetConfigFromEnvironmentVariable() {
String path = fileConfig.getConfigFromSys("PATH");
Assertions.assertNotNull(path);
}

@Test
void shouldDelegateFileBackedReadsThroughConfigurationFactory() {
String dataId = "service.disableGlobalTransaction";
String previousValue = System.getProperty(dataId);
try {
System.clearProperty(dataId);
ConfigurationFactory.reload();
Configuration fileConfig = ConfigurationFactory.getInstance();

Assertions.assertEquals("127.0.0.1:8091", fileConfig.getConfig("service.default.grouplist"));
Assertions.assertFalse(fileConfig.getBoolean(dataId));
} finally {
if (previousValue == null) {
System.clearProperty(dataId);
} else {
System.setProperty(dataId, previousValue);
}
ConfigurationFactory.reload();
}
Comment on lines +477 to +493
}

@Test
void shouldReturnDefaultsForMissingConfigurationThroughConfigurationFactory() {
Configuration fileConfig = ConfigurationFactory.getInstance();

Assertions.assertNull(fileConfig.getConfig("adopted.missing.key"));
Assertions.assertEquals("fallback", fileConfig.getLatestConfig("adopted.missing.key", "fallback", 1000L));
Assertions.assertEquals(39, fileConfig.getInt("adopted.missing.int", 39));
Assertions.assertEquals((short) 2, fileConfig.getShort("adopted.missing.short", (short) 2));
}

@Test
void shouldReportMutationOperationOutcomeThroughConfigurationFactory() {
Configuration fileConfig = ConfigurationFactory.getInstance();

Assertions.assertTrue(fileConfig.putConfig("adopted.put.key", "value", 1000L));
Assertions.assertTrue(fileConfig.putConfigIfAbsent("adopted.put-if-absent.key", "value", 1000L));
Assertions.assertTrue(fileConfig.removeConfig("adopted.remove.key", 1000L));
Comment on lines +510 to +512

Assertions.assertFalse(fileConfig.putConfig("adopted.expired.put.key", "value", -1L));
Assertions.assertFalse(fileConfig.putConfigIfAbsent("adopted.expired.put-if-absent.key", "value", -1L));
Assertions.assertFalse(fileConfig.removeConfig("adopted.expired.remove.key", -1L));
}
}
Loading