1
2
3
4
5
6
7 package net.stff.ical.test;
8
9 import java.util.Calendar;
10 import java.util.Date;
11 import java.util.Vector;
12
13 import junit.framework.TestCase;
14 import net.stff.ical.beans.CalendarDay;
15 import net.stff.ical.beans.IEvent;
16 import net.stff.ical.beans.VEvent;
17
18 /***
19 * @author buntekuh
20 *
21 */
22 public class TestCalendarDay extends TestCase {
23
24 public static void main(String[] args) {
25 junit.textui.TestRunner.run(TestCalendarDay.class);
26 }
27
28
29
30
31 protected void setUp() throws Exception {
32 super.setUp();
33 }
34
35
36
37
38 protected void tearDown() throws Exception {
39 super.tearDown();
40 }
41
42 /***
43 * Constructor for TestCalendarDay.
44 * @param name
45 */
46 public TestCalendarDay(String name) {
47 super(name);
48 }
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 public final void testScheduleEvents() {
86
87 IEvent e1, e2, e3;
88 Vector v= new Vector();
89 CalendarDay cd= new CalendarDay();
90
91
92 e1= new IEvent();
93 e1.setSummary("e1");
94 e1.setDtstart(VEvent.parseDate("20040708T010000"));
95 e1.setDtend(VEvent.parseDate("20040708T070000"));
96 v.add(e1);
97 e2= new IEvent();
98 e2.setSummary("e2");
99 e2.setDtstart(VEvent.parseDate("20040708T050000"));
100 e2.setDtend(VEvent.parseDate("20040708T090000"));
101 v.add(e2);
102 e3= new IEvent();
103 e3.setSummary("e3");
104 e3.setDtstart(VEvent.parseDate("20040708T080000"));
105 e3.setDtend(VEvent.parseDate("20040708T100000"));
106 v.add(e3);
107
108
109
110
111
112 Date s= VEvent.parseDate("20040708T000000");
113 Calendar cc= Calendar.getInstance();
114 cc.setTime(s);
115 cd.schedule(v, cc, 12, 60);
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133 Object[][] tt= cd.getTimetable();
134 int[] dim= cd.getDimensions();
135 assertEquals(12, dim[0]);
136 assertEquals(2, dim[1]);
137
138 assertNull(tt[0][0]);
139 assertNull(tt[0][1]);
140 IEvent ev= (IEvent)tt[1][0];
141 assertEquals("e1", ev.getSummary());
142 assertEquals(ev.getDuration(), 6);
143 assertNull(tt[1][1]);
144
145 assertEquals("persist", tt[5][0]);
146 ev= (IEvent)tt[5][1];
147 assertEquals("e2", ev.getSummary());
148 assertEquals(ev.getDuration(), 4);
149
150 assertNull(tt[7][0]);
151
152 ev= (IEvent)tt[8][0];
153 assertEquals("e3", ev.getSummary());
154
155 assertNull(tt[10][0]);
156
157 }
158
159 }