DATAGEODE-329 - Fix GemFireProperties.from(:String) IllegalArgumentException message.
This commit is contained in:
@@ -160,13 +160,26 @@ public enum GemFireProperties {
|
||||
return Arrays.stream(values())
|
||||
.filter(it -> equals(it, propertyName))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> newIllegalArgumentException("[%s] is not a valid Apache Geode property"));
|
||||
.orElseThrow(() -> newIllegalArgumentException("[%s] is not a valid Apache Geode property", propertyName));
|
||||
}
|
||||
|
||||
private static boolean equals(GemFireProperties property, String propertyName) {
|
||||
return property != null && property.getName().equals(propertyName);
|
||||
}
|
||||
|
||||
/*
|
||||
private static String normalizePropertyName(@Nullable String propertyName) {
|
||||
|
||||
String safePropertyName = String.valueOf(propertyName).trim();
|
||||
|
||||
boolean gemfireDotPrefixed = safePropertyName.startsWith(PROPERTY_NAME_PREFIX);
|
||||
|
||||
int index = safePropertyName.lastIndexOf(".");
|
||||
|
||||
return index > -1 && gemfireDotPrefixed ? safePropertyName.substring(index + 1) : propertyName;
|
||||
}
|
||||
*/
|
||||
|
||||
private Class<?> nullSafeType(Object target, Class<?> defaultType) {
|
||||
return target != null ? target.getClass() : defaultType;
|
||||
}
|
||||
|
||||
@@ -112,4 +112,56 @@ public class GemFirePropertiesUnitTests {
|
||||
GemFireProperties.class.getName(), ConfigurationProperties.class.getName(), missingGemFireProperties)
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromValidGemFireProperty() {
|
||||
|
||||
assertThat(GemFireProperties.from("cache-xml-file")).isEqualTo(GemFireProperties.CACHE_XML_FILE);
|
||||
//assertThat(GemFireProperties.from("gemfire.locators")).isEqualTo(GemFireProperties.LOCATORS);
|
||||
//assertThat(GemFireProperties.from(" gemfire.remote-locators ")).isEqualTo(GemFireProperties.REMOTE_LOCATORS);
|
||||
}
|
||||
|
||||
private void testFromInvalidGemFireProperty(String propertyName) {
|
||||
|
||||
try {
|
||||
GemFireProperties.from(propertyName);
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
|
||||
assertThat(expected).hasMessage("[%s] is not a valid Apache Geode property", propertyName);
|
||||
assertThat(expected).hasNoCause();
|
||||
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void fromInvalidGemFireDotPrefixedProperty() {
|
||||
testFromInvalidGemFireProperty("gemfire.invalid-property");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void fromInvalidGemFireProperty() {
|
||||
testFromInvalidGemFireProperty("non-existing-property");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void fromValidGeodeDotPrefixedProperty() {
|
||||
testFromInvalidGemFireProperty("geode.log-level");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void fromBlankProperty() {
|
||||
testFromInvalidGemFireProperty(" ");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void fromEmptyProperty() {
|
||||
testFromInvalidGemFireProperty("");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void fromNullProperty() {
|
||||
testFromInvalidGemFireProperty(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user