Search in sources :

Example 1 with JsonRendererServlet

use of org.apache.sling.servlets.get.impl.helpers.JsonRendererServlet in project sling by apache.

the class RedirectServlet method getJsonRendererServlet.

private Servlet getJsonRendererServlet() {
    if (jsonRendererServlet == null) {
        Servlet jrs = new JsonRendererServlet(jsonMaximumResults);
        try {
            jrs.init(getServletConfig());
        } catch (Exception e) {
        // don't care too much here
        }
        jsonRendererServlet = jrs;
    }
    return jsonRendererServlet;
}
Also used : JsonRendererServlet(org.apache.sling.servlets.get.impl.helpers.JsonRendererServlet) JsonRendererServlet(org.apache.sling.servlets.get.impl.helpers.JsonRendererServlet) Servlet(javax.servlet.Servlet) SlingSafeMethodsServlet(org.apache.sling.api.servlets.SlingSafeMethodsServlet) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 2 with JsonRendererServlet

use of org.apache.sling.servlets.get.impl.helpers.JsonRendererServlet in project sling by apache.

the class JsonRendererServletTest method getJSON.

private String getJSON(String path, String depth) throws Throwable {
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(path, depth, ".json", null, null);
    request.setMethod("GET");
    request.setResourceResolver(resolver);
    request.setResource(resolver.getResource(path));
    MockSlingHttpServletResponse response = new MockSlingHttpServletResponse();
    JsonRendererServlet servlet = new JsonRendererServlet(1000);
    PrivateAccessor.invoke(servlet, "doGet", new Class[] { SlingHttpServletRequest.class, SlingHttpServletResponse.class }, new Object[] { request, response });
    return response.getOutput().toString();
}
Also used : JsonRendererServlet(org.apache.sling.servlets.get.impl.helpers.JsonRendererServlet) MockSlingHttpServletRequest(org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest) MockSlingHttpServletResponse(org.apache.sling.commons.testing.sling.MockSlingHttpServletResponse)

Aggregations

JsonRendererServlet (org.apache.sling.servlets.get.impl.helpers.JsonRendererServlet)2 IOException (java.io.IOException)1 Servlet (javax.servlet.Servlet)1 ServletException (javax.servlet.ServletException)1 SlingSafeMethodsServlet (org.apache.sling.api.servlets.SlingSafeMethodsServlet)1 MockSlingHttpServletRequest (org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest)1 MockSlingHttpServletResponse (org.apache.sling.commons.testing.sling.MockSlingHttpServletResponse)1