* Test method for
* 'org.apache.lucene.gdata.storage.db4o.DB4oStorage.storeEntry(ServerBaseEntry)'
*/
@SuppressWarnings("unchecked")
public void testStoreEntry() throws StorageException {
Storage storage = this.controller.getStorage();
try {
ServerBaseEntry e = createServerBaseEntry();
storage.storeEntry(e);
fail("excption exp. for feed for the entry");
} catch (StorageException e) {
//
}
try {
storage.storeEntry(null);
fail("entry is null");
} catch (StorageException e) {
//
}
ServerBaseEntry exEntry = new ServerBaseEntry();
exEntry.setFeedId("some");
try {
storage.storeEntry(exEntry);
fail("entry id is null");
} catch (StorageException e) {
//
}
exEntry.setId("someID");
exEntry.setFeedId(null);
try {
storage.storeEntry(exEntry);
fail("feed id is null");
} catch (StorageException e) {
//
}
storeServerBaseFeed();
ServerBaseEntry e = createServerBaseEntry();
storage.storeEntry(e);
ServerBaseEntry e1 = createServerBaseEntry();
storage.storeEntry(e1);
storage = this.controller.getStorage();
Query query = getContainer().query();
query.constrain(BaseEntry.class);
query.descend("id").constrain(e.getId());
ObjectSet resultSet = query.execute();
assertEquals(1, resultSet.size());
BaseEntry storedEntry = (BaseEntry) resultSet.next();
assertEquals("1", storedEntry.getVersionId());
ServerBaseFeed bFeed = new ServerBaseFeed();
bFeed.setItemsPerPage(25);
bFeed.setId(FEEDID);
bFeed.setStartIndex(1);
bFeed.setServiceType(SERVICENAME);
BaseFeed<BaseFeed, BaseEntry> feed = storage.getFeed(bFeed);
assertEquals(2, feed.getEntries().size());
assertEquals(e.getId(), feed.getEntries().get(1).getId()); // last post
// ->
// previously
// created