// query for folder again since session ended
folder = bmgr.getFolder(folder.getId());
// Add bookmark by adding to folder
WeblogBookmark bookmark1 = new WeblogBookmark(
folder,
"TestBookmark1",
"created by testBookmarkCRUD()",
"http://www.example.com",
"http://www.example.com/rss.xml",
new Integer(1),
new Integer(12),
"test.jpg");
bookmark1.setFolder(folder);
folder.addBookmark(bookmark1);
// Add another bookmark
WeblogBookmark bookmark2 = new WeblogBookmark(
folder,
"TestBookmark2",
"created by testBookmarkCRUD()",
"http://www.example.com",
"http://www.example.com/rss.xml",
new Integer(1),
new Integer(12),
"test.jpf");
bookmark2.setFolder(folder);
folder.addBookmark(bookmark2);
TestUtils.endSession(true);
WeblogBookmarkFolder testFolder = null;
WeblogBookmark bookmarkb = null, bookmarka = null;
// See that two bookmarks were stored
testFolder = bmgr.getFolder(folder.getId());
assertEquals(2, testFolder.getBookmarks().size());
Iterator<WeblogBookmark> iter = testFolder.getBookmarks().iterator();
bookmarka = iter.next();
bookmarkb = iter.next();
// Remove one bookmark
bmgr.removeBookmark(bookmarka);
bmgr.removeBookmark(bookmarkb);
bmgr.saveFolder(testFolder);
TestUtils.endSession(true);
// Folder should now contain one bookmark
assertNull(bmgr.getBookmark(bookmarka.getId()));
assertNull(bmgr.getBookmark(bookmarkb.getId()));
testFolder = bmgr.getFolder(folder.getId());
assertEquals(0, testFolder.getBookmarks().size());
// Remove folder
bmgr.removeFolder(testFolder);
TestUtils.endSession(true);
// Folder and one remaining bookmark should be gone
assertNull( bmgr.getBookmark(bookmarkb.getId()) );
assertNull( bmgr.getFolder(folder.getId()) );
}