protected void setUp() throws Exception { super.setUp(); /** create our standard mock objects */ action = this.getAction(); stack = new OgnlValueStack(); context = stack.getContext(); stack.push(action); request = new WebWorkMockHttpServletRequest(); request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, stack); response = new WebWorkMockHttpServletResponse(); request.setSession(new WebWorkMockHttpSession()); request.setupGetServletPath("/"); writer = new StringWriter(); JspWriter jspWriter = new WebWorkMockJspWriter(writer); servletContext = new WebWorkMockServletContext(); servletContext.setRealPath(new File("nosuchfile.properties").getAbsolutePath()); servletContext.setServletInfo("Resin"); pageContext = new WebWorkMockPageContext(); pageContext.setRequest(request); pageContext.setResponse(response); pageContext.setJspWriter(jspWriter); pageContext.setServletContext(servletContext); DispatcherUtils.initialize(pageContext.getServletContext()); DispatcherUtils du = DispatcherUtils.getInstance(); session = new SessionMap(request); Map extraContext = du.createContextMap( new RequestMap(request), request.getParameterMap(), session, new ApplicationMap(pageContext.getServletContext()), request, response, pageContext.getServletContext()); // let's not set the locale -- there is a test that checks if DispatcherUtils actually picks // this up... // ... but generally we want to just use no locale (let it stay system default) extraContext.remove(ActionContext.LOCALE); stack.getContext().putAll(extraContext); context.put(ServletActionContext.HTTP_REQUEST, request); context.put(ServletActionContext.HTTP_RESPONSE, response); context.put(ServletActionContext.SERVLET_CONTEXT, servletContext); ActionContext.setContext(new ActionContext(context)); Configuration.setConfiguration(null); }
protected void tearDown() throws Exception { pageContext.verify(); request.verify(); }