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);
}
Aggregations