/** * Get the value of property {@code name} as a Long. * * @param name property name. * @return property value as a Long, or {@code null} if the property * does not exist. * @throws NumberFormatException if value does not represent a Long. */ public Long getLong(String name) { return getLong(name, null); }
/** * Get the value of property {@code name} as a Long. * * @param name property name. * @return property value as a Long, or {@code null} if the property * does not exist. * @throws NumberFormatException if value does not represent a Long. */ public Long getLong(String name) { return getLong(name, null); }
@Test public void testLong() { Long one = 1L; Long two = 2L; assertEquals(opt.getLong(KEY, one), one); assertNull(opt.getLong(KEY, null)); assertNull(opt.getLong(KEY)); opt.setLong(KEY, two); assertEquals(opt.getLong(KEY, one), two); assertEquals(opt.getLong(KEY, null), two); assertEquals(opt.getLong(KEY), two); opt.setLong(KEY, null); assertEquals(opt.getLong(KEY, one), one); assertNull(opt.getLong(KEY, null)); assertNull(opt.getLong(KEY)); }
@Test(dataProvider = "longCases") public void testLongFromString(String longString, Long expected) { opt.set(KEY, longString); assertEquals(opt.getLong(KEY), expected); }
@Test(expectedExceptions = NumberFormatException.class) public void testBadLong() { opt.set(KEY, "9223372036854775808"); opt.getLong(KEY); }