use of com.google.common.net.MediaType in project guava by hceylan.
the class MediaTypeTest method testGetCharset_illegalCharset.
public void testGetCharset_illegalCharset() {
MediaType mediaType = MediaType.parse("text/plain; charset=\"!@#$%^&*()\"");
try {
mediaType.charset();
fail();
} catch (IllegalCharsetNameException expected) {
}
}
use of com.google.common.net.MediaType in project ddf by codice.
the class VideoThumbnailPlugin method isVideo.
private boolean isVideo(final ContentItem contentItem) {
final MimeType createdMimeType = contentItem.getMimeType();
final MediaType createdMediaType = MediaType.create(createdMimeType.getPrimaryType(), createdMimeType.getSubType());
return createdMediaType.is(MediaType.ANY_VIDEO_TYPE);
}
use of com.google.common.net.MediaType in project moco by dreamhead.
the class FileContentType method getContentType.
public MediaType getContentType() {
Optional<MediaType> optionalType = toContentType(Files.getFileExtension(filename));
Optional<Charset> targetCharset = toCharset(optionalType);
MediaType type = optionalType.or(DEFAULT_CONTENT_TYPE_WITH_CHARSET);
if (targetCharset.isPresent() && !type.charset().equals(targetCharset)) {
return type.withCharset(targetCharset.get());
}
return type;
}
use of com.google.common.net.MediaType in project moco by dreamhead.
the class MocoRestTest method checkJsonResponse.
private HttpEntity checkJsonResponse(final HttpResponse response) {
assertThat(response.getStatusLine().getStatusCode(), is(200));
HttpEntity entity = response.getEntity();
MediaType mediaType = MediaType.parse(entity.getContentType().getValue());
assertThat(mediaType.type(), is("application"));
assertThat(mediaType.subtype(), is("json"));
return entity;
}
use of com.google.common.net.MediaType in project moco by dreamhead.
the class MocoRestStandaloneTest method asPlain.
private Plain asPlain(org.apache.http.HttpResponse response) throws IOException {
assertThat(response.getStatusLine().getStatusCode(), is(200));
HttpEntity entity = response.getEntity();
MediaType mediaType = MediaType.parse(entity.getContentType().getValue());
assertThat(mediaType.type(), is("application"));
assertThat(mediaType.subtype(), is("json"));
return Jsons.toObject(entity.getContent(), Plain.class);
}
Aggregations