// 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");
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");
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());
bookmarka = (WeblogBookmark)testFolder.getBookmarks().iterator().next();
bookmarkb = (WeblogBookmark)testFolder.getBookmarks().iterator().next();
// Remove one bookmark
bmgr.removeBookmark(bookmarka);
bmgr.saveFolder(testFolder);
TestUtils.endSession(true);
// Folder should now contain one bookmark
testFolder = bmgr.getFolder(folder.getId());
assertEquals(1, 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()) );
}