* and then saving it, so there really is no need for a full moveFolder()
* method. i am leaving this test here for a while just in case we change
* our minds.
*/
public void testMoveFolderContents() throws Exception {
BookmarkManager bmgr = getRoller().getBookmarkManager();
try {
testWeblog = TestUtils.getManagedWebsite(testWeblog);
WeblogBookmarkFolder root = bmgr.getRootFolder(testWeblog);
WeblogBookmarkFolder dest = new WeblogBookmarkFolder(root, "dest", null, testWeblog);
bmgr.saveFolder(dest);
// create source folder f1
WeblogBookmarkFolder f1 = new WeblogBookmarkFolder(root, "f1", null, testWeblog);
bmgr.saveFolder(f1);
// create bookmark b1 inside source folder f1
WeblogBookmark b1 = new WeblogBookmark(
f1, "b1", "testbookmark",
"http://example.com", "http://example.com/rss",
new Integer(1), new Integer(1), "image.gif");
f1.addBookmark(b1);
// create folder f2 inside f1
WeblogBookmarkFolder f2 = new WeblogBookmarkFolder(f1, "f2", null, testWeblog);
bmgr.saveFolder(f2);
// create bookmark b2 inside folder f2
WeblogBookmark b2 = new WeblogBookmark(
f2, "b2", "testbookmark",
"http://example.com", "http://example.com/rss",
new Integer(1), new Integer(1), "image.gif");
f2.addBookmark(b2);
// create folder f3 inside folder f2
WeblogBookmarkFolder f3 = new WeblogBookmarkFolder(f2, "f3", null, testWeblog);
bmgr.saveFolder(f3);
// crete bookmark b3 inside folder f3
WeblogBookmark b3 = new WeblogBookmark(
f3, "b3", "testbookmark",
"http://example.com", "http://example.com/rss",
new Integer(1), new Integer(1), "image.gif");
f3.addBookmark(b3);
TestUtils.endSession(true);
// verify our new tree
dest = bmgr.getFolder(dest.getId());
f1 = bmgr.getFolder(f1.getId());
f2 = bmgr.getFolder(f2.getId());
f3 = bmgr.getFolder(f3.getId());
assertEquals(0, dest.getBookmarks().size());
assertEquals(1, f1.getBookmarks().size());
assertEquals(1, f2.getBookmarks().size());
assertEquals(1, f3.getBookmarks().size());
assertEquals(0, dest.retrieveBookmarks(true).size());
assertEquals(3, f1.retrieveBookmarks(true).size());
// test that parent cannot be moved into child
boolean safe = false;
try {
// Move folder into one of it's children
bmgr.moveFolder(f1, f3);
TestUtils.endSession(true);
} catch (WebloggerException e) {
safe = true;
}
assertTrue(safe);
// move f1 to dest
f1 = bmgr.getFolder( f1.getId()); //Get managed copy
dest = bmgr.getFolder( dest.getId()); //Get managed copy
bmgr.moveFolder(f1, dest);
TestUtils.endSession(true);
// after move, verify number of entries in eacch folder
dest = bmgr.getFolder(dest.getId());
f1 = bmgr.getFolder(f1.getId());
assertEquals(3, dest.retrieveBookmarks(true).size());
// check that paths and child folders are correct
assertEquals("/dest/f1", f1.getPath());
assertEquals(1, dest.getFolders().size());
bmgr.removeFolder(f1);
bmgr.removeFolder(dest);
} catch(Throwable t) {
log.error("Exception running test", t);
throw (Exception) t;
} finally {