Search in sources :

Example 1 with AnnotationValidationInterceptor

use of org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor 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

ActionContext (com.opensymphony.xwork2.ActionContext)1 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)1 MockActionInvocation (com.opensymphony.xwork2.mock.MockActionInvocation)1 MockActionProxy (com.opensymphony.xwork2.mock.MockActionProxy)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 AnnotationValidationInterceptor (org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor)1