Search in sources :

Example 16 with ContentType

use of com.linkedin.restli.common.ContentType in project rest.li by linkedin.

the class TestContentType method testProtobufContentType.

@Test
public void testProtobufContentType() throws MimeTypeParseException {
    ContentType contentType = ContentType.getContentType("application/x-protobuf").get();
    Assert.assertEquals(contentType, ContentType.PROTOBUF);
    ContentType contentTypeWithParameter = ContentType.getContentType("application/x-protobuf; charset=utf-8").get();
    Assert.assertEquals(contentTypeWithParameter, ContentType.PROTOBUF);
}
Also used : ContentType(com.linkedin.restli.common.ContentType) Test(org.testng.annotations.Test)

Example 17 with ContentType

use of com.linkedin.restli.common.ContentType in project rest.li by linkedin.

the class TestContentType method testPSONContentType.

@Test
public void testPSONContentType() throws MimeTypeParseException {
    ContentType contentType = ContentType.getContentType("application/x-pson").get();
    Assert.assertEquals(contentType, ContentType.PSON);
    ContentType contentTypeWithParameter = ContentType.getContentType("application/x-pson; charset=utf-8").get();
    Assert.assertEquals(contentTypeWithParameter, ContentType.PSON);
}
Also used : ContentType(com.linkedin.restli.common.ContentType) Test(org.testng.annotations.Test)

Example 18 with ContentType

use of com.linkedin.restli.common.ContentType in project rest.li by linkedin.

the class TestContentType method testGetResponseProtobuf2ContentTypeOverriddenSymbolTable.

@Test
public void testGetResponseProtobuf2ContentTypeOverriddenSymbolTable() throws MimeTypeParseException {
    ContentType contentType = ContentType.getResponseContentType("application/x-protobuf2; symbol-table=\"OverrideResponse\"", TEST_URI, Collections.emptyMap()).get();
    Assert.assertEquals("application/x-protobuf2; symbol-table=\"OverrideResponse\"", contentType.getHeaderKey());
}
Also used : ContentType(com.linkedin.restli.common.ContentType) Test(org.testng.annotations.Test)

Example 19 with ContentType

use of com.linkedin.restli.common.ContentType in project rest.li by linkedin.

the class TestContentType method testGetResponseNullContentType.

@Test
public void testGetResponseNullContentType() throws MimeTypeParseException {
    ContentType contentType = ContentType.getResponseContentType(null, TEST_URI, Collections.emptyMap()).get();
    Assert.assertEquals(ContentType.JSON, contentType);
}
Also used : ContentType(com.linkedin.restli.common.ContentType) Test(org.testng.annotations.Test)

Example 20 with ContentType

use of com.linkedin.restli.common.ContentType in project rest.li by linkedin.

the class TestMultiplexedRequestHandlerImpl method testGetContentTypeWithParameters.

@Test(dataProvider = "multiplexerConfigurations")
public void testGetContentTypeWithParameters(MultiplexerRunMode multiplexerRunMode) throws Exception {
    createMultiplexer(null, multiplexerRunMode);
    RestRequest request = muxRequestBuilder().setHeader(RestConstants.HEADER_CONTENT_TYPE, "application/json; charset=utf-8").build();
    ContentType contentType = ContentType.getContentType(request.getHeader(RestConstants.HEADER_CONTENT_TYPE)).get();
    assertEquals(contentType, ContentType.JSON);
}
Also used : RestRequest(com.linkedin.r2.message.rest.RestRequest) ContentType(com.linkedin.restli.common.ContentType) Test(org.testng.annotations.Test)

Aggregations

ContentType (com.linkedin.restli.common.ContentType)21 Test (org.testng.annotations.Test)14 ByteString (com.linkedin.data.ByteString)4 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)4 MimeTypeParseException (javax.activation.MimeTypeParseException)3 RestRequest (com.linkedin.r2.message.rest.RestRequest)2 RestResponse (com.linkedin.r2.message.rest.RestResponse)2 MultiplexerUriBuilder (com.linkedin.restli.client.uribuilders.MultiplexerUriBuilder)2 IOException (java.io.IOException)2 DataMap (com.linkedin.data.DataMap)1 StreamDataCodec (com.linkedin.data.codec.entitystream.StreamDataCodec)1 DefaultSymbolTableProvider (com.linkedin.data.codec.symbol.DefaultSymbolTableProvider)1 SymbolTable (com.linkedin.data.codec.symbol.SymbolTable)1 SymbolTableProvider (com.linkedin.data.codec.symbol.SymbolTableProvider)1 MultiPartMIMEWriter (com.linkedin.multipart.MultiPartMIMEWriter)1 MessageHeadersBuilder (com.linkedin.r2.message.MessageHeadersBuilder)1 RequestContext (com.linkedin.r2.message.RequestContext)1 RestResponseBuilder (com.linkedin.r2.message.rest.RestResponseBuilder)1 StreamRequestBuilder (com.linkedin.r2.message.stream.StreamRequestBuilder)1 ByteStringWriter (com.linkedin.r2.message.stream.entitystream.ByteStringWriter)1