Search in sources :

Example 41 with MediaType

use of javax.ws.rs.core.MediaType in project jersey by jersey.

the class UriConnegLanguageMediaTypeTest method configure.

@Override
protected Application configure() {
    Map<String, MediaType> mediaTypes = new HashMap<>();
    mediaTypes.put("foo", MediaType.valueOf("application/foo"));
    mediaTypes.put("bar", MediaType.valueOf("application/bar"));
    Map<String, String> languages = new HashMap<>();
    languages.put("english", "en");
    languages.put("french", "fr");
    ResourceConfig rc = new ResourceConfig(LanguageVariantResource.class);
    rc.property(ServerProperties.LANGUAGE_MAPPINGS, languages);
    rc.property(ServerProperties.MEDIA_TYPE_MAPPINGS, mediaTypes);
    return rc;
}
Also used : HashMap(java.util.HashMap) MediaType(javax.ws.rs.core.MediaType) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 42 with MediaType

use of javax.ws.rs.core.MediaType in project jersey by jersey.

the class LoopBackConnectorTest method testEntityMediaType.

@Test
public void testEntityMediaType() throws Exception {
    final Response response = client.target("baz").request().post(Entity.entity("foo", "foo/bar"));
    assertThat("Invalid entity received", response.readEntity(String.class), is("foo"));
    assertThat("Invalid content-type received", response.getMediaType(), is(new MediaType("foo", "bar")));
}
Also used : Response(javax.ws.rs.core.Response) MediaType(javax.ws.rs.core.MediaType) Test(org.junit.Test)

Example 43 with MediaType

use of javax.ws.rs.core.MediaType in project jersey by jersey.

the class ConsumeProduceTest method testProducesStrings.

@Test
public void testProducesStrings() {
    final Produces p = ProducesStringsClass.class.getAnnotation(Produces.class);
    final List<MediaType> l = MediaTypes.createFrom(p);
    checkMediaTypes(l);
}
Also used : Produces(javax.ws.rs.Produces) MediaType(javax.ws.rs.core.MediaType) Test(org.junit.Test)

Example 44 with MediaType

use of javax.ws.rs.core.MediaType in project jersey by jersey.

the class ConsumeProduceTest method testConsumesString.

@Test
public void testConsumesString() {
    final Consumes c = ConsumesStringClass.class.getAnnotation(Consumes.class);
    final List<MediaType> l = MediaTypes.createFrom(c);
    checkMediaTypes(l);
}
Also used : Consumes(javax.ws.rs.Consumes) MediaType(javax.ws.rs.core.MediaType) Test(org.junit.Test)

Example 45 with MediaType

use of javax.ws.rs.core.MediaType in project jersey by jersey.

the class ConsumeProduceTest method testProduces.

@Test
public void testProduces() {
    final Produces p = ProducesClass.class.getAnnotation(Produces.class);
    final List<MediaType> l = MediaTypes.createFrom(p);
    checkMediaTypes(l);
}
Also used : Produces(javax.ws.rs.Produces) MediaType(javax.ws.rs.core.MediaType) Test(org.junit.Test)

Aggregations

MediaType (javax.ws.rs.core.MediaType)228 Test (org.junit.Test)112 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)29 Path (javax.ws.rs.Path)25 Produces (javax.ws.rs.Produces)24 WebApplicationException (javax.ws.rs.WebApplicationException)24 ByteArrayInputStream (java.io.ByteArrayInputStream)20 HashSet (java.util.HashSet)20 MediaTypeUtil.getAcceptableMediaType (org.apache.stanbol.commons.web.base.utils.MediaTypeUtil.getAcceptableMediaType)20 IOException (java.io.IOException)18 AcceptableMediaType (org.glassfish.jersey.message.internal.AcceptableMediaType)18 InputStream (java.io.InputStream)16 GET (javax.ws.rs.GET)16 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)16 EntityhubLDPath (org.apache.stanbol.entityhub.ldpath.EntityhubLDPath)15 ArrayList (java.util.ArrayList)14 Consumes (javax.ws.rs.Consumes)14 HashMap (java.util.HashMap)13 Viewable (org.apache.stanbol.commons.web.viewable.Viewable)12 MultiPart (org.glassfish.jersey.media.multipart.MultiPart)12