[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:
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user