SignupAction extends BaseAction { public String execute() { if (cancel != null) { return CANCEL; } if (ServletActionContext.getRequest().getMethod().equals("GET")) { return INPUT; } return SUCCESS; }  void setCancel(String cancel); void setUser(User user); User getUser(); String execute(); String doDefault(); String save();  }
@Test public void testDisplayForm() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(null, "GET", "/signup.html"); ServletActionContext.setRequest(request); assertEquals("input", action.execute()); }
@Test public void testExecutePost() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(null, "POST", "/signup.html"); ServletActionContext.setRequest(request); assertEquals(Action.SUCCESS, action.execute()); }