예제 #1
0
 public void testAdjustRight() {
   WeekFramerImpl framer = new WeekFramerImpl(new TestCalendarFactory());
   Date adjustedMonday = framer.adjustRight(newMonday());
   Date adjustedSunday = framer.adjustRight(newSunday());
   assertEquals(adjustedMonday, adjustedSunday);
   Calendar c = (Calendar) Calendar.getInstance().clone();
   c.setTime(adjustedMonday);
   assertEquals("Unexpected day of week", Calendar.MONDAY, c.get(Calendar.DAY_OF_WEEK));
   c.add(Calendar.MILLISECOND, -1);
   assertEquals("Unexpected day of week", Calendar.SUNDAY, c.get(Calendar.DAY_OF_WEEK));
 }
예제 #2
0
 public void testJumpLeft() {
   WeekFramerImpl framer = new WeekFramerImpl(new TestCalendarFactory());
   Date adjustedMonday = framer.jumpLeft(newMonday());
   Date adjustedSunday = framer.jumpLeft(newSunday());
   assertNotSame(adjustedMonday, adjustedSunday);
   Calendar c = (Calendar) Calendar.getInstance().clone();
   c.setTime(adjustedMonday);
   assertTrue(
       "Unexpected day of week, date=" + c.getTime(),
       Calendar.MONDAY == c.get(Calendar.DAY_OF_WEEK));
   assertNotSame(adjustedMonday, newMonday());
   c.setTime(adjustedSunday);
   assertEquals(
       "Unexpected day of week, date=" + c.getTime(),
       Calendar.SUNDAY,
       c.get(Calendar.DAY_OF_WEEK));
   assertNotSame(adjustedMonday, newSunday());
 }