/** * Creates the {@link com.mockrunner.mock.web.MockActionMapping} using <code>new</code>. * This method can be overridden to return a subclass of {@link com.mockrunner.mock.web.MockActionMapping}. * @return the {@link com.mockrunner.mock.web.MockActionMapping} */ public MockActionMapping createMockActionMapping() { return new MockActionMapping(); }
@Test public void testValidationError() { getActionMockObjectFactory().getMockServletContext().setAttribute("counter", 0); getActionMockObjectFactory().getMockActionMapping().setPath("/greetings"); actionPerform(GreetingsAction.class, GreetingsValidatorForm.class); verifyNumberActionErrors(1); verifyActionErrorPresent("errors.required"); addRequestParameter("name", "y"); actionPerform(GreetingsAction.class, GreetingsValidatorForm.class); verifyNumberActionErrors(1); verifyActionErrorPresent("errors.minlength"); } }
@Test public void testForward() { getActionMockObjectFactory().getMockActionMapping().setParameter("method"); addRequestParameter("method", "Add"); actionPerform(ShoppingCartAction.class); verifyForward("add"); addRequestParameter("method", "Order"); actionPerform(ShoppingCartAction.class); verifyForward("order"); } }
@Test public void testSuccesfulGreetings() { getActionMockObjectFactory().getMockServletContext().setAttribute("counter", 0); getActionMockObjectFactory().getMockActionMapping().setPath("/greetings"); addRequestParameter("name", "testname"); actionPerform(GreetingsAction.class, GreetingsValidatorForm.class); assertEquals("Hello testname, you are visitor 1", getRequestAttribute("greetings")); getActionMockObjectFactory().getMockServletContext().setAttribute("counter", 6); verifyNoActionErrors(); actionPerform(GreetingsAction.class, GreetingsValidatorForm.class); assertEquals("Hello testname, you are visitor 7", getRequestAttribute("greetings")); verifyNoActionErrors(); verifyForward("success"); }
/** * Creates the {@link com.mockrunner.mock.web.MockActionMapping} using <code>new</code>. * This method can be overridden to return a subclass of {@link com.mockrunner.mock.web.MockActionMapping}. * @return the {@link com.mockrunner.mock.web.MockActionMapping} */ public MockActionMapping createMockActionMapping() { return new MockActionMapping(); }
/** * Creates the {@link com.mockrunner.mock.web.MockActionMapping} using <code>new</code>. * This method can be overridden to return a subclass of {@link com.mockrunner.mock.web.MockActionMapping}. * @return the {@link com.mockrunner.mock.web.MockActionMapping} */ public MockActionMapping createMockActionMapping() { return new MockActionMapping(); }