PropertyUtils { @SuppressWarnings("unchecked") public static <T> T getProperty(Configuration config, String name, T defaultValue) { final Object obj = config.getProperty(name); return obj != null ? (T) obj : defaultValue; }  @SuppressWarnings("unchecked") static T getProperty(Configuration config, String name, T defaultValue);  }
@Test public void getProperty() { Configuration config = EasyMock.createStrictMock(Configuration.class); expect(config.getProperty(eq("host"))).andReturn("java.net"); expect(config.getProperty(eq("port"))).andReturn(null); replay(config); assertThat(PropertyUtils.getProperty(config, "host", "oracle.com"), is("java.net")); assertThat(PropertyUtils.getProperty(config, "port", 8080), is(8080)); verify(config); }