1
0

[HUDI-3633] Allow non-string values to be set in TypedProperties (#5045)

* [HUDI-3633] Allow non-string values to be set in TypedProperties

* Override getProperty to ignore instanceof string check
This commit is contained in:
Sagar Sumit
2022-03-16 00:03:22 +05:30
committed by GitHub
parent 5e8ff8d793
commit d514570e90
2 changed files with 36 additions and 2 deletions

View File

@@ -83,5 +83,27 @@ public class TestTypedProperties {
assertTrue(typedProperties.getBoolean("key1"));
assertTrue(typedProperties.getBoolean("key1", false));
assertFalse(typedProperties.getBoolean("key2", false));
// test getBoolean with non-string value for key2
properties.put("key2", true);
typedProperties = new TypedProperties(properties);
assertTrue(typedProperties.getBoolean("key1", false));
assertTrue(typedProperties.getBoolean("key2", false));
// put non-string value in TypedProperties
typedProperties.put("key3", true);
assertTrue(typedProperties.getBoolean("key3", false));
}
@Test
public void testTypedPropertiesWithNonStringValue() {
Properties properties = new Properties();
properties.put("key1", "1");
properties.put("key2", 2);
TypedProperties props = new TypedProperties(properties);
assertEquals(1, props.getInteger("key1"));
assertEquals(2, props.getInteger("key2"));
// put non-string value in TypedProperties
props.put("key2", 3);
assertEquals(3, props.getInteger("key2"));
}
}