Search in sources :

Example 1 with RestContext

use of org.jessma.ext.rest.RestContext in project JessMA by ldcsaa.

the class TestRest method main.

public static void main(String[] args) throws Exception {
    MockServletContext servletContext = new MockServletContext();
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    response.setCharacterEncoding(GeneralHelper.DEFAULT_ENCODING);
    RestContext context = new RestContext(RequestType.PUT, "/aaa/111;12|34|56,伤神小怪兽", RenderType.XML);
    MyAction action = new MyAction();
    action.setServletContext(servletContext);
    action.setRequest(request);
    action.setResponse(response);
    action.setRequestAttribute(Rest.Constant.REQ_ATTR_REST_CONTEXT, context);
    action.execute();
    response.getWriter().println("\n-------------------------");
    context = new RestContext(RequestType.PUT, "/大家好/12|34|56", RenderType.JSON);
    action.setRequestAttribute(Rest.Constant.REQ_ATTR_REST_CONTEXT, context);
    action.execute();
    response.getWriter().println("\n-------------------------");
    context = new RestContext(RequestType.GET, "/173/edit", RenderType.XML);
    action.setRequestAttribute(Rest.Constant.REQ_ATTR_REST_CONTEXT, context);
    action.execute();
    String result = response.getContentAsString();
    System.out.println(result);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) RestContext(org.jessma.ext.rest.RestContext) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Aggregations

RestContext (org.jessma.ext.rest.RestContext)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 MockServletContext (org.springframework.mock.web.MockServletContext)1