KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > calendar > HolidayTest


1 package org.jbpm.calendar;
2
3 import java.text.*;
4 import java.util.Calendar JavaDoc;
5 import java.util.Date JavaDoc;
6
7 import junit.framework.*;
8
9 public class HolidayTest extends TestCase {
10
11   public void testHolidaySingleDayParsing() throws Exception JavaDoc {
12     DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
13     Holiday holiday = new Holiday("21/07/2005", dateFormat, null);
14     
15     Calendar JavaDoc calendar = BusinessCalendar.getCalendar();
16     calendar.set(Calendar.YEAR, 2005);
17     calendar.set(Calendar.MONTH, Calendar.JULY);
18     calendar.set(Calendar.DAY_OF_MONTH, 21);
19     calendar.set(Calendar.HOUR_OF_DAY, 0);
20     calendar.set(Calendar.MINUTE, 0);
21     calendar.set(Calendar.SECOND, 0);
22     calendar.set(Calendar.MILLISECOND, 0);
23     Date JavaDoc expectedFromDay = calendar.getTime();
24
25     assertEquals(expectedFromDay, holiday.fromDay);
26     
27     calendar.set(Calendar.YEAR, 2005);
28     calendar.set(Calendar.MONTH, Calendar.JULY);
29     calendar.set(Calendar.DAY_OF_MONTH, 22);
30     calendar.set(Calendar.HOUR_OF_DAY, 0);
31     calendar.set(Calendar.MINUTE, 0);
32     calendar.set(Calendar.SECOND, 0);
33     calendar.set(Calendar.MILLISECOND, 0);
34     Date JavaDoc expectedToDay = calendar.getTime();
35
36     assertEquals(expectedToDay, holiday.toDay);
37   }
38
39   public void testHolidayMulitDayParsing() throws Exception JavaDoc {
40     DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
41     Holiday holiday = new Holiday("1/7/2005 - 31/8/2005", dateFormat, null);
42
43     Calendar JavaDoc calendar = BusinessCalendar.getCalendar();
44     calendar.set(Calendar.YEAR, 2005);
45     calendar.set(Calendar.MONTH, Calendar.JULY);
46     calendar.set(Calendar.DAY_OF_MONTH, 1);
47     calendar.set(Calendar.HOUR_OF_DAY, 0);
48     calendar.set(Calendar.MINUTE, 0);
49     calendar.set(Calendar.SECOND, 0);
50     calendar.set(Calendar.MILLISECOND, 0);
51     Date JavaDoc expectedFromDay = calendar.getTime();
52
53     assertEquals(expectedFromDay, holiday.fromDay);
54     
55     calendar.set(Calendar.YEAR, 2005);
56     calendar.set(Calendar.MONTH, Calendar.SEPTEMBER);
57     calendar.set(Calendar.DAY_OF_MONTH, 1);
58     calendar.set(Calendar.HOUR_OF_DAY, 0);
59     calendar.set(Calendar.MINUTE, 0);
60     calendar.set(Calendar.SECOND, 0);
61     calendar.set(Calendar.MILLISECOND, 0);
62     Date JavaDoc expectedToDay = calendar.getTime();
63
64     assertEquals(expectedToDay, holiday.toDay);
65   }
66 }
67
Popular Tags