Search in sources :

Example 1 with NodeTypesJSONServlet

use of org.apache.sling.jcr.js.nodetypes.NodeTypesJSONServlet in project sling by apache.

the class MockNodeTypeGenerator method assertEqualsWithServletResult.

public void assertEqualsWithServletResult(String filename) throws JSONException, ServletException, IOException {
    NodeTypesJSONServlet generationServlet = new NodeTypesJSONServlet();
    generationServlet.service(request, response);
    verify(response, never()).sendError(anyInt());
    String resultingJSON = new String(outStream.toByteArray(), "utf-8");
    String expectedNTJSON = getExpectedNTJSON(filename);
    JSONObject actualJsonObjectFromServlet = new JSONObject(new JSONTokener(resultingJSON));
    JSONAssert.assertEquals("Actual JSON: " + resultingJSON + "\nExpected JSON: " + expectedNTJSON, new JSONObject(new JSONTokener(expectedNTJSON)), actualJsonObjectFromServlet);
}
Also used : JSONTokener(org.apache.sling.commons.json.JSONTokener) JSONObject(org.apache.sling.commons.json.JSONObject) NodeTypesJSONServlet(org.apache.sling.jcr.js.nodetypes.NodeTypesJSONServlet)

Aggregations

JSONObject (org.apache.sling.commons.json.JSONObject)1 JSONTokener (org.apache.sling.commons.json.JSONTokener)1 NodeTypesJSONServlet (org.apache.sling.jcr.js.nodetypes.NodeTypesJSONServlet)1