public void testSmartGetProperties() throws Exception { Destination destination = new Destination(); destination.setAnInteger(10); destination.setABoolean(true); Properties props = new Properties(); props.setProperty("number1", "one"); props.setProperty("number2", "two"); destination.setProps(props); Map map = PropertyUtils.getProperties(destination); assertEquals(13, map.size()); assertEquals("one", map.get("props.number1")); assertEquals("two", map.get("props.number2")); assertEquals(new Integer(10), map.get("anInteger")); assertEquals(Boolean.TRUE, map.get("aBoolean")); assertEquals(Boolean.FALSE, map.get("anotherBoolean")); assertNull(map.get("subDestination")); }
public void testSmartGetProperties() throws Exception { Destination destination = new Destination(); destination.setAnInteger(10); destination.setABoolean(true); Properties props = new Properties(); props.setProperty("number1", "one"); props.setProperty("number2", "two"); destination.setProps(props); Map map = PropertyUtils.getProperties(destination); assertEquals(13, map.size()); assertEquals("one", map.get("props.number1")); assertEquals("two", map.get("props.number2")); assertEquals(new Integer(10), map.get("anInteger")); assertEquals(Boolean.TRUE, map.get("aBoolean")); assertEquals(Boolean.FALSE, map.get("anotherBoolean")); assertNull(map.get("subDestination")); }
public void testGetPrimitiveTypes() throws Exception { Destination destination = new Destination(); destination.setAString("this is my string"); destination.setABoolean(true); destination.setAByte((byte) 100); destination.setAShort((short) 20000); destination.setAnInteger(300000); destination.setALong(4000000L); destination.setAFloat(3.14f); destination.setADouble(0.654987); assertEquals("this is my string", PropertyUtils.getProperty(destination, "aString")); assertEquals(Boolean.TRUE, PropertyUtils.getProperty(destination, "aBoolean")); assertEquals(new Byte((byte) 100), PropertyUtils.getProperty(destination, "aByte")); assertEquals(new Short((short) 20000), PropertyUtils.getProperty(destination, "aShort")); assertEquals(new Integer(300000), PropertyUtils.getProperty(destination, "anInteger")); assertEquals(new Long(4000000L), PropertyUtils.getProperty(destination, "aLong")); assertEquals(new Float(3.14f), PropertyUtils.getProperty(destination, "aFloat")); assertEquals(new Double(0.654987), PropertyUtils.getProperty(destination, "aDouble")); }
public void testGetPrimitiveTypes() throws Exception { Destination destination = new Destination(); destination.setAString("this is my string"); destination.setABoolean(true); destination.setAByte((byte) 100); destination.setAShort((short) 20000); destination.setAnInteger(300000); destination.setALong(4000000L); destination.setAFloat(3.14f); destination.setADouble(0.654987); assertEquals("this is my string", PropertyUtils.getProperty(destination, "aString")); assertEquals(Boolean.TRUE, PropertyUtils.getProperty(destination, "aBoolean")); assertEquals(new Byte((byte) 100), PropertyUtils.getProperty(destination, "aByte")); assertEquals(new Short((short) 20000), PropertyUtils.getProperty(destination, "aShort")); assertEquals(new Integer(300000), PropertyUtils.getProperty(destination, "anInteger")); assertEquals(new Long(4000000L), PropertyUtils.getProperty(destination, "aLong")); assertEquals(new Float(3.14f), PropertyUtils.getProperty(destination, "aFloat")); assertEquals(new Double(0.654987), PropertyUtils.getProperty(destination, "aDouble")); }