}
public void testSubscriptionEntryStorage() throws Exception {
PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
{ // save subscription
PlanetSubscriptionData sub = new PlanetSubscriptionData();
sub.setFeedURL("test_url");
planet.saveSubscription(sub);
TestUtils.endSession(true);
}
{ // retrieve subscription and add entries
PlanetSubscriptionData sub = planet.getSubscription("test_url");
assertNotNull(sub);
PlanetEntryData entry1 = new PlanetEntryData();
entry1.setPermalink("test_entry1");
entry1.setCategoriesString("test,test2");
entry1.setPubTime(new Timestamp(System.currentTimeMillis()));
entry1.setSubscription(sub);
planet.saveEntry(entry1);
sub.addEntry(entry1);
PlanetEntryData entry2 = new PlanetEntryData();
entry2.setPermalink("test_entry2");
entry2.setCategoriesString("test_cat1,test_cat2,test_cat3");
entry2.setPubTime(new Timestamp(System.currentTimeMillis()));
entry2.setSubscription(sub);
planet.saveEntry(entry2);
sub.addEntry(entry2);
// save entries
planet.saveSubscription(sub);
TestUtils.endSession(true);
// get sub and check it's entries
sub = planet.getSubscription("test_url");
assertEquals(2, sub.getEntries().size());
}
{
// add a single entry
PlanetSubscriptionData sub = planet.getSubscription("test_url");
assertNotNull(sub);
PlanetEntryData entry3 = new PlanetEntryData();
entry3.setPermalink("test_entry3");
entry3.setCategoriesString("test,test3");
entry3.setSubscription(sub);
entry3.setPubTime(new Timestamp(System.currentTimeMillis()));
planet.saveEntry(entry3);
TestUtils.endSession(true);
// verify entry was added
sub = planet.getSubscription("test_url");
assertEquals(3, sub.getEntries().size());
}
{
// purge entries
PlanetSubscriptionData sub = planet.getSubscription("test_url");
sub.purgeEntries();
planet.saveSubscription(sub);
TestUtils.endSession(true);
// make sure they were removed
sub = planet.getSubscription("test_url");
assertEquals(0, sub.getEntries().size());
}
{
// remove test subscription
PlanetSubscriptionData sub = planet.getSubscription("test_url");
planet.deleteSubscription(sub);
TestUtils.endSession(true);
// make sure sub is gone
sub = planet.getSubscription("test_url");
assertNull(sub);
}
}