Search in sources :

Example 1 with JSONResponse

use of org.apache.sling.servlets.post.JSONResponse in project sling by apache.

the class SlingPostServletTest method testGetJsonResponse.

public void testGetJsonResponse() {
    MockSlingHttpServletRequest req = new MockSlingHttpServlet3Request(null, null, null, null, null) {

        @Override
        public String getHeader(String name) {
            return name.equals(MediaRangeList.HEADER_ACCEPT) ? "application/json" : super.getHeader(name);
        }

        public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
            return null;
        }
    };
    PostResponse result = servlet.createPostResponse(req);
    assertTrue(result instanceof JSONResponse);
}
Also used : MockSlingHttpServlet3Request(org.apache.sling.servlets.post.impl.helper.MockSlingHttpServlet3Request) MockSlingHttpServletRequest(org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest) JSONResponse(org.apache.sling.servlets.post.JSONResponse) PostResponse(org.apache.sling.servlets.post.PostResponse)

Aggregations

MockSlingHttpServletRequest (org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest)1 JSONResponse (org.apache.sling.servlets.post.JSONResponse)1 PostResponse (org.apache.sling.servlets.post.PostResponse)1 MockSlingHttpServlet3Request (org.apache.sling.servlets.post.impl.helper.MockSlingHttpServlet3Request)1