1 package org.roller.presentation.weblog; 2 3 import javax.servlet.http.HttpServletRequest ; 4 5 import junit.framework.Test; 6 import junit.framework.TestSuite; 7 8 import org.roller.presentation.StrutsActionTestBase; 9 import org.roller.presentation.weblog.actions.WeblogEntryFormAction; 10 import org.roller.presentation.weblog.formbeans.WeblogEntryFormEx; 11 12 import com.mockrunner.mock.web.MockActionMapping; 13 import com.mockrunner.mock.web.MockHttpServletRequest; 14 15 18 public class WeblogEntryActionTest extends StrutsActionTestBase 19 { 20 public void testCreateWeblogEntry() 21 { 22 authenticateUser(mWebsite.getUser().getUserName(), "editor"); 23 24 MockHttpServletRequest mockRequest = getMockFactory().getMockRequest(); 25 mockRequest.setContextPath("/dummy"); 26 27 doFilters(); 28 29 MockActionMapping mapping = strutsModule.getMockActionMapping(); 31 mapping.setupForwards(new String [] { 32 "access-denied","weblogEdit.page","weblogEntryRemove.page"}); 33 mapping.setParameter("method"); 34 strutsModule.addRequestParameter("method","create"); 35 36 WeblogEntryFormEx form = (WeblogEntryFormEx) 38 strutsModule.createActionForm(WeblogEntryFormEx.class); 39 form.setTitle("test_title"); 40 form.setText("Test blog text"); 41 42 strutsModule.actionPerform(WeblogEntryFormAction.class, form); 43 44 strutsModule.verifyNoActionMessages(); 46 strutsModule.verifyForward("weblogEdit.page"); 47 48 verifyPageContext(); 50 } 51 52 protected void verifyPageContext() 53 { 54 HttpServletRequest req = (HttpServletRequest ) 55 servletModule.getFilteredRequest(); 56 assertNotNull(req.getAttribute("model")); 57 } 58 59 public static Test suite() 60 { 61 return new TestSuite(WeblogEntryActionTest.class); 62 } 63 64 } 65 | Popular Tags |