KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > calendar > store > LocalCalendarStoreTest


1 package org.columba.calendar.store;
2
3 import java.io.File JavaDoc;
4
5 import junit.framework.TestCase;
6
7 import org.columba.calendar.base.UUIDGenerator;
8 import org.columba.calendar.model.Event;
9 import org.columba.calendar.model.EventInfo;
10 import org.columba.calendar.model.api.IComponentInfo;
11 import org.columba.calendar.store.api.StoreException;
12
13 public class LocalCalendarStoreTest extends TestCase {
14
15     private File JavaDoc file;
16
17     private LocalCalendarStore storage;
18
19     protected void setUp() throws Exception JavaDoc {
20         file = new File JavaDoc("test_calendar");
21
22         storage = new LocalCalendarStore(file);
23     }
24
25     public void testAddGet() throws Exception JavaDoc {
26         String JavaDoc uuid = new UUIDGenerator().newUUID();
27
28         Event model = new Event(uuid);
29         model.setSummary("summary");
30         model.setDescription("description");
31         
32         EventInfo eventInfo = new EventInfo(uuid, "calendar1", model);
33         storage.add(eventInfo);
34
35         boolean exists = storage.exists(uuid);
36         assertTrue(exists);
37
38         IComponentInfo result = storage.get(uuid);
39         assertNotNull(result);
40
41     }
42
43     public void testRemove() throws Exception JavaDoc {
44         String JavaDoc uuid = new UUIDGenerator().newUUID();
45
46         Event model = new Event(uuid);
47         model.setSummary("summary");
48         model.setDescription("description");
49         
50         EventInfo eventInfo = new EventInfo(uuid, "calendar1", model);
51
52         storage.add(eventInfo);
53
54         storage.remove(uuid);
55
56         try {
57             IComponentInfo result = storage.get(uuid);
58         } catch (StoreException e) {
59             // that is the expected case
60
return;
61         } catch (Exception JavaDoc e) {
62             fail("Expected a StoreException, not " + e.getMessage());
63         }
64         
65         fail("Expected a StoreException");
66
67     }
68
69     protected void tearDown() throws Exception JavaDoc {
70 // // delete all data in directory
71
// File[] list = file.listFiles();
72
//
73
// for (int i = 0; i < list.length; i++) {
74
// list[i].delete();
75
// }
76
//
77
// // delete folder
78
// file.delete();
79
}
80
81 }
82
Popular Tags