@Test(expected=ContentTypes.InvalidContentTypeException.class) public void testStrictDisallowUnknown() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, "text/plain"); }
@Test public void testAllowJsonRpc() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, "application/json-rpc"); }
@Test public void testAllowJsonRpc() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, "application/json-rpc"); }
@Test(expected=ContentTypes.InvalidContentTypeException.class) public void testForbidden() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, "application/x-www-form-urlencoded"); }
@Override protected void doPut(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException { try { ContentTypes.checkContentTypes(ALLOWED_CONTENT_TYPES, servletRequest.getContentType()); executeRequest(servletRequest, servletResponse); } catch (ContentTypes.InvalidContentTypeException icte) { sendError(servletResponse, new ResponseItem(HttpServletResponse.SC_BAD_REQUEST, icte.getMessage())); } }
@Override protected void doPut(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException { try { ContentTypes.checkContentTypes(ALLOWED_CONTENT_TYPES, servletRequest.getContentType()); executeRequest(servletRequest, servletResponse); } catch (ContentTypes.InvalidContentTypeException icte) { sendError(servletResponse, new ResponseItem(HttpServletResponse.SC_BAD_REQUEST, icte.getMessage())); } }
@Test public void testAllowJsonRpc() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, "application/json-rpc"); }
@Test public void testAllowMultipart() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_MULTIPART_CONTENT_TYPES, ContentTypes.MULTIPART_FORM_CONTENT_TYPE); }
@Test public void testAllowJson() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, ContentTypes.OUTPUT_JSON_CONTENT_TYPE); }
@Test public void testAllowXml() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_XML_CONTENT_TYPES, ContentTypes.OUTPUT_XML_CONTENT_TYPE); }
@Override protected void doPost(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException { try { ContentTypes.checkContentTypes(ALLOWED_CONTENT_TYPES, servletRequest.getContentType()); executeRequest(servletRequest, servletResponse); } catch (ContentTypes.InvalidContentTypeException icte) { sendError(servletResponse, new ResponseItem(HttpServletResponse.SC_BAD_REQUEST, icte.getMessage())); } }
@Test public void testAllowJson() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, ContentTypes.OUTPUT_JSON_CONTENT_TYPE); }
@Test(expected=ContentTypes.InvalidContentTypeException.class) public void testForbidden() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, "application/x-www-form-urlencoded"); }
@Test public void testAllowXml() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_XML_CONTENT_TYPES, ContentTypes.OUTPUT_XML_CONTENT_TYPE); }
@Override protected void doPost(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException { try { ContentTypes.checkContentTypes(ALLOWED_CONTENT_TYPES, servletRequest.getContentType()); executeRequest(servletRequest, servletResponse); } catch (ContentTypes.InvalidContentTypeException icte) { sendError(servletResponse, new ResponseItem(HttpServletResponse.SC_BAD_REQUEST, icte.getMessage())); } }
@Override protected void doPost(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException { try { ContentTypes.checkContentTypes(ALLOWED_CONTENT_TYPES, servletRequest.getContentType()); executeRequest(servletRequest, servletResponse); } catch (ContentTypes.InvalidContentTypeException icte) { sendError(servletResponse, new ResponseItem(HttpServletResponse.SC_BAD_REQUEST, icte.getMessage())); } }
@Test public void testAllowMultipart() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_MULTIPART_CONTENT_TYPES, ContentTypes.MULTIPART_FORM_CONTENT_TYPE); }
@Test(expected=ContentTypes.InvalidContentTypeException.class) public void testForbidden() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, "application/x-www-form-urlencoded"); }
@Test(expected=ContentTypes.InvalidContentTypeException.class) public void testStrictDisallowUnknown() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, "text/plain"); }
@Test public void testAllowJsonRpc() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, "application/json-rpc"); }