### Question:
ContentTypes { public static void checkContentTypes(Set<String> allowedContentTypes, String contentType) throws InvalidContentTypeException { if (Strings.isNullOrEmpty(contentType)) { throw new InvalidContentTypeException( "No Content-Type specified. One of " + Joiner.on(", ").join(allowedContentTypes) + " is required"); } contentType = ContentTypes.extractMimePart(contentType); if (ContentTypes.FORBIDDEN_CONTENT_TYPES.contains(contentType)) { throw new InvalidContentTypeException( "Cannot use disallowed Content-Type " + contentType); } if (allowedContentTypes.contains(contentType)) { return; } throw new InvalidContentTypeException( "Unsupported Content-Type " + contentType + ". One of " + Joiner.on(", ").join(allowedContentTypes) + " is required"); } private  ContentTypes(); static String extractMimePart(String contentType); static void checkContentTypes(Set<String> allowedContentTypes,
      String contentType); static final Set<String> ALLOWED_JSON_CONTENT_TYPES; static final Set<String> ALLOWED_XML_CONTENT_TYPES; static final Set<String> ALLOWED_ATOM_CONTENT_TYPES; static final Set<String> FORBIDDEN_CONTENT_TYPES; static final String MULTIPART_FORM_CONTENT_TYPE; static final Set<String> ALLOWED_MULTIPART_CONTENT_TYPES; static final String OUTPUT_JSON_CONTENT_TYPE; static final String OUTPUT_XML_CONTENT_TYPE; static final String OUTPUT_ATOM_CONTENT_TYPE; }### Answer:
@Test public void testAllowJson() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, ContentTypes.OUTPUT_JSON_CONTENT_TYPE); }
@Test public void testAllowJsonRpc() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES, "application/json-rpc"); }
@Test public void testAllowAtom() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_ATOM_CONTENT_TYPES, ContentTypes.OUTPUT_ATOM_CONTENT_TYPE); }
@Test public void testAllowXml() throws Exception { ContentTypes.checkContentTypes(ContentTypes.ALLOWED_XML_CONTENT_TYPES, ContentTypes.OUTPUT_XML_CONTENT_TYPE); }
@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"); }