Search in sources :

Example 61 with MockActionProxy

use of com.opensymphony.xwork2.mock.MockActionProxy in project struts by apache.

the class JSONActionRedirectResultTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    this.response = new MockHttpServletResponse();
    this.request = new MockHttpServletRequest();
    this.context = ActionContext.getContext();
    this.context.put(StrutsStatics.HTTP_RESPONSE, this.response);
    this.context.put(StrutsStatics.HTTP_REQUEST, this.request);
    this.stack = context.getValueStack();
    this.servletContext = new MockServletContext();
    this.context.put(StrutsStatics.SERVLET_CONTEXT, this.servletContext);
    this.invocation = new MockActionInvocation();
    this.invocation.setInvocationContext(this.context);
    this.invocation.setStack(this.stack);
    MockActionProxy mockActionProxy = new MockActionProxy();
    mockActionProxy.setConfig(new ActionConfig.Builder(null, null, null).build());
    this.invocation.setProxy(mockActionProxy);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockActionInvocation(com.opensymphony.xwork2.mock.MockActionInvocation) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) MockServletContext(org.springframework.mock.web.MockServletContext) MockActionProxy(com.opensymphony.xwork2.mock.MockActionProxy)

Example 62 with MockActionProxy

use of com.opensymphony.xwork2.mock.MockActionProxy in project struts by apache.

the class JSONValidationInterceptorTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    ActionConfig config = new ActionConfig.Builder("", "name", "").build();
    this.action = new TestAction();
    this.interceptor = new JSONValidationInterceptor();
    this.validationInterceptor = new AnnotationValidationInterceptor();
    container.inject(validationInterceptor);
    this.request = new StrutsMockHttpServletRequest();
    stringWriter = new StringWriter();
    PrintWriter writer = new PrintWriter(stringWriter);
    this.response = new StrutsMockHttpServletResponse();
    response.setWriter(writer);
    ActionContext context = ActionContext.getContext();
    context.put(StrutsStatics.HTTP_REQUEST, request);
    context.put(StrutsStatics.HTTP_RESPONSE, response);
    StrutsMockServletContext servletContext = new StrutsMockServletContext();
    context.put(StrutsStatics.SERVLET_CONTEXT, servletContext);
    invocation = new MockActionInvocation();
    ActionContext.getContext().withActionInvocation(invocation);
    invocation.setAction(action);
    invocation.setInvocationContext(context);
    MockActionProxy proxy = new MockActionProxy();
    proxy.setMethod("execute");
    proxy.setAction(action);
    proxy.setConfig(config);
    invocation.setProxy(proxy);
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) MockActionInvocation(com.opensymphony.xwork2.mock.MockActionInvocation) ActionContext(com.opensymphony.xwork2.ActionContext) StringWriter(java.io.StringWriter) MockActionProxy(com.opensymphony.xwork2.mock.MockActionProxy) AnnotationValidationInterceptor(org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor) PrintWriter(java.io.PrintWriter)

Aggregations

MockActionProxy (com.opensymphony.xwork2.mock.MockActionProxy)43 MockActionInvocation (com.opensymphony.xwork2.mock.MockActionInvocation)34 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)29 ActionInvocation (com.opensymphony.xwork2.ActionInvocation)19 ActionProxy (com.opensymphony.xwork2.ActionProxy)17 HashMap (java.util.HashMap)15 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)13 ActionContext (com.opensymphony.xwork2.ActionContext)12 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)11 SimpleFooAction (com.opensymphony.xwork2.SimpleFooAction)10 ServletActionContext (org.apache.struts2.ServletActionContext)10 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)10 OgnlUtil (com.opensymphony.xwork2.ognl.OgnlUtil)8 ActionMapper (org.apache.struts2.dispatcher.mapper.ActionMapper)7 IMocksControl (org.easymock.IMocksControl)7 ValueStack (com.opensymphony.xwork2.util.ValueStack)6 DefaultUrlHelper (org.apache.struts2.views.util.DefaultUrlHelper)6 Mock (com.mockobjects.dynamic.Mock)5 Action (com.opensymphony.xwork2.Action)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5