@Test public void testDisallowJSONP() throws Exception { servlet.setJSONPAllowed(false); HttpServletRequest request = createGetRequest("{\"gadgets\":[]}",null); HttpServletResponse response = createHttpResponse("Content-Disposition", "attachment;filename=rpc.txt", "application/json; charset=utf-8", "{\"GADGETS\":[]}", HttpServletResponse.SC_OK); JSONObject handlerResponse = new JSONObject("{\"GADGETS\":[]}"); expect(handler.process(isA(JSONObject.class))).andReturn(handlerResponse); replay(handler); servlet.doGet(request, response); verify(response); servlet.setJSONPAllowed(true); }
@Test public void testDisallowJSONP() throws Exception { servlet.setJSONPAllowed(false); HttpServletRequest request = createGetRequest("{\"gadgets\":[]}",null); HttpServletResponse response = createHttpResponse("Content-Disposition", "attachment;filename=rpc.txt", "application/json; charset=utf-8", "{\"GADGETS\":[]}", HttpServletResponse.SC_OK); JSONObject handlerResponse = new JSONObject("{\"GADGETS\":[]}"); expect(handler.process(isA(JSONObject.class))).andReturn(handlerResponse); replay(handler); servlet.doGet(request, response); verify(response); servlet.setJSONPAllowed(true); }
@Before public void setUp() throws Exception { servlet = new RpcServlet(); handler = createMock(JsonRpcHandler.class); servlet.setJsonRpcHandler(handler); servlet.setJSONPAllowed(true); }
@Before public void setUp() throws Exception { servlet = new RpcServlet(); handler = createMock(JsonRpcHandler.class); servlet.setJsonRpcHandler(handler); servlet.setJSONPAllowed(true); }