public void testAddBookmarkToFolder() throws Exception {
BookmarkManager bmgr = getRoller().getBookmarkManager();
FolderData folder = null;
BookmarkData bookmark1 = null, bookmark2 = null;
FolderData root = bmgr.getRootFolder(testWeblog);
folder = new FolderData();
folder.setName("TestFolder1");
folder.setDescription("created by testAddBookmarkToFolder()");
folder.setWebsite(testWeblog);
folder.setParent(root);
bmgr.saveFolder(folder);
// Add bookmark by adding to folder
bookmark1 = new BookmarkData(
folder,
"TestBookmark1",
"created by testAddBookmarkToFolder()",
"http://www.example.com",
"http://www.example.com/rss.xml",
new Integer(1),
new Integer(12),
"test.jpg");
folder.addBookmark(bookmark1);
// Add another bookmark
bookmark2 = new BookmarkData(
folder,
"TestBookmark2",
"created by testAddBookmarkToFolder()",
"http://www.example.com",
"http://www.example.com/rss.xml",
new Integer(1),
new Integer(12),
"test.jpf");
folder.addBookmark(bookmark2);
TestUtils.endSession(true);
FolderData testFolder = null;
BookmarkData bookmarkb = null, bookmarka = null;
// See that two bookmarks were stored
testFolder = bmgr.getFolder(folder.getId());
assertEquals(2, testFolder.getBookmarks().size());
bookmarka = (BookmarkData)testFolder.getBookmarks().iterator().next();
bookmarkb = (BookmarkData)testFolder.getBookmarks().iterator().next();
// Remove one bookmark
testFolder.removeBookmark(bookmarka);
bmgr.removeBookmark(bookmarka);
TestUtils.endSession(true);
// Folder should now contain one bookmark
testFolder = bmgr.getFolder(folder.getId());
assertEquals(1, testFolder.getBookmarks().size());
TestUtils.endSession(true);
// Remove folder
testFolder = bmgr.getFolder(folder.getId());
bmgr.removeFolder(testFolder);
TestUtils.endSession(true);
// Folder and one remaining bookmark should be gone
assertNull( bmgr.getBookmark(bookmarkb.getId()) );
assertNull( bmgr.getFolder(folder.getId()) );
}