public void testSetPropertiesObjectLongKey() throws Exception { PrivateDestination destination = new PrivateDestination(); PropertyUtils.setProperty(destination, "props.key", "value1"); PropertyUtils.setProperty(destination, "props.a.dotted.key", "value2"); assertEquals("value1", destination.getProps().get("key")); assertEquals("value2", destination.getProps().get("a.dotted.key")); }
public void testSetPropertiesObjectLongKey() throws Exception { PrivateDestination destination = new PrivateDestination(); PropertyUtils.setProperty(destination, "props.key", "value1"); PropertyUtils.setProperty(destination, "props.a.dotted.key", "value2"); assertEquals("value1", destination.getProps().get("key")); assertEquals("value2", destination.getProps().get("a.dotted.key")); }
public void testSetProperties() throws Exception { Destination destination = new Destination(); PropertyUtils.setProperty(destination, "props.key", "value"); assertEquals("value", destination.getProps().getProperty("key")); PropertyUtils.setProperty(destination, "subDestination.props.key", "value"); assertEquals("value", destination.getSubDestination().getProps().getProperty("key")); PropertyUtils.setProperty(destination, "anInteger", "10"); assertEquals(10, destination.getAnInteger()); PropertyUtils.setProperty(destination, "subDestination.anInteger", "20"); assertEquals(20, destination.getSubDestination().getAnInteger()); PropertyUtils.setProperty(destination, "aBoolean", "true"); assertEquals(true, destination.isABoolean()); PropertyUtils.setProperty(destination, "aWriteOnlyInt", "20"); PrivateDestination privateDestination = new PrivateDestination(); try { PropertyUtils.setProperty(privateDestination, "subDestination.props.key", "value"); fail("it is not possible to set the 'subDestination' property, PropertyException should have been thrown"); } catch (PropertyException ex) { assertEquals("cannot set property 'subDestination.props.key' - 'subDestination' is null and cannot be auto-filled", ex.getMessage()); } }
public void testSetProperties() throws Exception { Destination destination = new Destination(); PropertyUtils.setProperty(destination, "props.key", "value"); assertEquals("value", destination.getProps().getProperty("key")); PropertyUtils.setProperty(destination, "subDestination.props.key", "value"); assertEquals("value", destination.getSubDestination().getProps().getProperty("key")); PropertyUtils.setProperty(destination, "anInteger", "10"); assertEquals(10, destination.getAnInteger()); PropertyUtils.setProperty(destination, "subDestination.anInteger", "20"); assertEquals(20, destination.getSubDestination().getAnInteger()); PropertyUtils.setProperty(destination, "aBoolean", "true"); assertEquals(true, destination.isABoolean()); PropertyUtils.setProperty(destination, "aWriteOnlyInt", "20"); PrivateDestination privateDestination = new PrivateDestination(); try { PropertyUtils.setProperty(privateDestination, "subDestination.props.key", "value"); fail("it is not possible to set the 'subDestination' property, PropertyException should have been thrown"); } catch (PropertyException ex) { assertEquals("cannot set property 'subDestination.props.key' - 'subDestination' is null and cannot be auto-filled", ex.getMessage()); } }