public void testDialogContentAction() throws Exception { DialogContentAction dialogContent = new DialogContentAction(); String result = dialogContent.execute(); assertTrue("Expected a success result!", ActionSupport.SUCCESS.equals(result)); assertTrue( "Expected the default message!", dialogContent.getText(DialogContentAction.MESSAGE).equals(dialogContent.getMessage())); }
@Override public String intercept(ActionInvocation invocation) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); Map<String, String[]> params = request.getParameterMap(); String result = invocation.invoke(); HttpSession session = request.getSession(); Object userObj = session.getAttribute("sysUser"); if (userObj == null || !(userObj instanceof AdminUser)) { return result; } adminLog = createLogBean(params); if (ActionSupport.SUCCESS.equalsIgnoreCase(result)) { adminLog.setResult(1); } else if (ActionSupport.INPUT.equalsIgnoreCase(result)) { adminLog.setResult(2); } else if (ActionSupport.ERROR.equalsIgnoreCase(result)) { adminLog.setResult(3); } else if ("limit".equalsIgnoreCase(result)) { adminLog.setResult(4); } WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext()); logService = webApplicationContext.getBean("logService", AdminLogService.class); TaskController.createTaskAndRun( new Task() { @Override public void run() { adminLog.setOperTime(new Timestamp(new Date().getTime())); logService.add(adminLog); } }); return result; }