1 4 package org.roller.presentation.bookmarks; 5 6 import java.util.List ; 7 import java.util.Set ; 8 9 import javax.servlet.http.HttpServletRequest ; 10 11 import junit.framework.Test; 12 import junit.framework.TestSuite; 13 14 import org.roller.pojos.FolderData; 15 import org.roller.presentation.StrutsActionTestBase; 16 import org.roller.presentation.bookmarks.actions.BookmarksAction; 17 import org.roller.presentation.bookmarks.formbeans.BookmarksForm; 18 19 import com.mockrunner.mock.web.MockActionMapping; 20 import com.mockrunner.mock.web.MockHttpServletRequest; 21 import com.mockrunner.mock.web.MockServletContext; 22 23 27 public class BookmarksActionTest extends StrutsActionTestBase 28 { 29 public void testSelectFolder() 30 { 31 MockServletContext ctx = getMockFactory().getMockServletContext(); 32 ctx.setServletContextName("/roller"); 33 MockHttpServletRequest request = getMockFactory().getMockRequest(); 34 request.setContextPath("/roller"); 35 36 authenticateUser(mWebsite.getUser().getUserName(), "editor"); 37 doFilters(); 38 39 BookmarksForm form = (BookmarksForm) 41 strutsModule.createActionForm(BookmarksForm.class); 42 43 MockActionMapping mapping = strutsModule.getMockActionMapping(); 45 mapping.setupForwards(new String [] {"access-denied","BookmarksForm"}); 46 mapping.setParameter("method"); 47 strutsModule.addRequestParameter("method","selectFolder"); 48 49 strutsModule.actionPerform(BookmarksAction.class, form); 50 51 strutsModule.verifyNoActionMessages(); 53 strutsModule.verifyForward("BookmarksForm"); 54 55 verifyPageContext(); 57 } 58 59 protected void verifyPageContext() 60 { 61 HttpServletRequest req = (HttpServletRequest ) 62 servletModule.getFilteredRequest(); 63 assertTrue(req.getAttribute("folder") instanceof FolderData); 64 assertTrue(req.getAttribute("folders") instanceof List ); 65 assertTrue(req.getAttribute("bookmarks") instanceof Set ); 66 } 67 68 public static Test suite() 69 { 70 return new TestSuite(BookmarksActionTest.class); 71 } 72 } 73 | Popular Tags |