Search in sources :

Example 21 with MediaType

use of com.google.common.net.MediaType in project guava by hceylan.

the class MediaTypeTest method testCreateVideoType.

public void testCreateVideoType() {
    MediaType newType = MediaType.createVideoType("yams");
    assertEquals("video", newType.type());
    assertEquals("yams", newType.subtype());
}
Also used : MediaType(com.google.common.net.MediaType)

Example 22 with MediaType

use of com.google.common.net.MediaType in project guava by hceylan.

the class MediaTypeTest method testCreateAudioType.

public void testCreateAudioType() {
    MediaType newType = MediaType.createAudioType("yams");
    assertEquals("audio", newType.type());
    assertEquals("yams", newType.subtype());
}
Also used : MediaType(com.google.common.net.MediaType)

Example 23 with MediaType

use of com.google.common.net.MediaType in project guava by hceylan.

the class MediaTypeTest method testWithParameters_invalidAttribute.

public void testWithParameters_invalidAttribute() {
    MediaType mediaType = MediaType.parse("text/plain");
    ImmutableListMultimap<String, String> parameters = ImmutableListMultimap.of("a", "1", "@", "2", "b", "3");
    try {
        mediaType.withParameters(parameters);
        fail();
    } catch (IllegalArgumentException expected) {
    }
}
Also used : MediaType(com.google.common.net.MediaType)

Example 24 with MediaType

use of com.google.common.net.MediaType in project guava by hceylan.

the class MediaTypeTest method testWithParameter_invalidAttribute.

public void testWithParameter_invalidAttribute() {
    MediaType mediaType = MediaType.parse("text/plain");
    try {
        mediaType.withParameter("@", "2");
        fail();
    } catch (IllegalArgumentException expected) {
    }
}
Also used : MediaType(com.google.common.net.MediaType)

Example 25 with MediaType

use of com.google.common.net.MediaType in project guava by hceylan.

the class MediaTypeTest method testGetCharset_tooMany.

public void testGetCharset_tooMany() {
    MediaType mediaType = MediaType.parse("text/plain; charset=utf-8; charset=utf-16");
    try {
        mediaType.charset();
        fail();
    } catch (IllegalStateException expected) {
    }
}
Also used : MediaType(com.google.common.net.MediaType)

Aggregations

MediaType (com.google.common.net.MediaType)29 HttpEntity (org.apache.http.HttpEntity)6 IOException (java.io.IOException)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Charset (java.nio.charset.Charset)3 HttpResponse (org.apache.http.HttpResponse)3 HttpUriBuilder (io.airlift.http.client.HttpUriBuilder)2 StringResponse (io.airlift.http.client.StringResponseHandler.StringResponse)2 BufferedReader (java.io.BufferedReader)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 Nullable (javax.annotation.Nullable)2 Serializer (net.morimekta.providence.serializer.Serializer)2 Schema (org.apache.avro.Schema)2 DatumReader (org.apache.avro.io.DatumReader)2 SpecificDatumReader (org.apache.avro.specific.SpecificDatumReader)2 PushbackReader (org.spf4j.io.PushbackReader)2 ByteArrayContent (com.google.api.client.http.ByteArrayContent)1 GenericUrl (com.google.api.client.http.GenericUrl)1 HttpRequest (com.google.api.client.http.HttpRequest)1