@Before public void setUp() { controller = new Controller(35.0); Calendar cal = Calendar.getInstance(); cal.set(2012, Calendar.JANUARY, 1, 1, 1, 0); Date d1, d2; d1 = cal.getTime(); t1 = d1.getTime(); cal.set(2012, Calendar.JANUARY, 1, 1, 1, 2); d2 = cal.getTime(); t2 = d2.getTime(); }
@Test public void testConvertNotSupported() throws Exception { final Calendar cal = new GregorianCalendar(2005, 0, 16); try { converter.convert(Object.class, cal.getTime()); fail("Object.class is not supported"); } catch (final Exception e) { // expected } try { converter.convertToDate(Object.class, cal.getTime(), ""); fail("Object.class is not supported"); } catch (final Exception e) { // expected } }
private Date getNewDate(int increment) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); Calendar c = Calendar.getInstance(); c.setTimeZone(TimeZone.getTimeZone("GMT")); c.setTime(sdf.parse(START_DATE)); c.add(Calendar.DATE, increment); return c.getTime(); }
@Test public void today() { try { Calendar today = Calendar.getInstance(); beginOfDay(today); assertTrue(sufficientlyEqual(DynamicDate.getInstance("today"), today.getTime())); } catch (Exception e) { fail(e.getMessage()); } }
@Test public void testAddBirthdayNotification() { FacePamphletProfile test = new FacePamphletProfile("Test Profile"); FacePamphletProfile jimmy = new FacePamphletProfile("Jimmy"); Calendar currentDate = Calendar.getInstance(); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd"); String dateNow = formatter.format(currentDate.getTime()); jimmy.setBirthday(12, 4); test.addFriend(jimmy); test.addBirthdayNotifications(); assertTrue(test.getNotifications().contains("Jimmy's birthday is coming up on 12/4!!")); }
@Test public void testConvertDateToString() throws Exception { final Calendar cal = new GregorianCalendar(2005, 0, 16); final String date = (String) converter.convert(String.class, cal.getTime()); assertEquals(DateUtil.convertDateToString(cal.getTime()), date); }