1 package org.columba.calendar.store; 2 3 import java.io.File ; 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 file; 16 17 private LocalCalendarStore storage; 18 19 protected void setUp() throws Exception { 20 file = new File ("test_calendar"); 21 22 storage = new LocalCalendarStore(file); 23 } 24 25 public void testAddGet() throws Exception { 26 String 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 { 44 String 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 return; 61 } catch (Exception 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 { 70 } 80 81 } 82 | Popular Tags |