Search in sources :

Example 1 with DataConverters

use of com.tvd12.ezyhttp.core.codec.DataConverters in project ezyhttp by youngmonkeys.

the class DataConvertersTest method addBodyConvertersTest.

@Test
public void addBodyConvertersTest() {
    // given
    DataConverters sut = new DataConverters(new ObjectMapper());
    List<?> bodyConverters = Lists.newArrayList(new JsonConverter(), new Object());
    // when
    sut.addBodyConverters(bodyConverters);
    // then
    Asserts.assertEquals(sut.getBodyDeserializer(ContentTypes.APPLICATION_JSON), bodyConverters.get(0));
    Asserts.assertEquals(sut.getBodySerializer(ContentTypes.APPLICATION_JSON), bodyConverters.get(0));
}
Also used : DataConverters(com.tvd12.ezyhttp.core.codec.DataConverters) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Example 2 with DataConverters

use of com.tvd12.ezyhttp.core.codec.DataConverters in project ezyhttp by youngmonkeys.

the class DataConvertersTest method getBodySerializerDefaultTest.

@Test
public void getBodySerializerDefaultTest() {
    // given
    DataConverters sut = new DataConverters(new ObjectMapper());
    String contentType = "unknown";
    // when
    BodySerializer actual = sut.getBodySerializer(contentType);
    // then
    Asserts.assertEquals(TextBodyConverter.class, actual.getClass());
}
Also used : DataConverters(com.tvd12.ezyhttp.core.codec.DataConverters) BodySerializer(com.tvd12.ezyhttp.core.codec.BodySerializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Example 3 with DataConverters

use of com.tvd12.ezyhttp.core.codec.DataConverters in project ezyhttp by youngmonkeys.

the class DataConvertersTest method getBodyDeserializerDefaultTest.

@Test
public void getBodyDeserializerDefaultTest() {
    // given
    DataConverters sut = new DataConverters(new ObjectMapper());
    String contentType = "unknown";
    // when
    BodyDeserializer actual = sut.getBodyDeserializer(contentType);
    // then
    Asserts.assertEquals(TextBodyConverter.class, actual.getClass());
}
Also used : BodyDeserializer(com.tvd12.ezyhttp.core.codec.BodyDeserializer) DataConverters(com.tvd12.ezyhttp.core.codec.DataConverters) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Example 4 with DataConverters

use of com.tvd12.ezyhttp.core.codec.DataConverters in project ezyhttp by youngmonkeys.

the class DataConvertersTest method getBodyDeserializerNormalTest.

@Test
public void getBodyDeserializerNormalTest() {
    // given
    DataConverters sut = new DataConverters(new ObjectMapper());
    String contentType = ContentTypes.APPLICATION_JSON;
    // when
    BodyDeserializer actual = sut.getBodyDeserializer(contentType);
    // then
    Asserts.assertEquals(JsonBodyConverter.class, actual.getClass());
}
Also used : BodyDeserializer(com.tvd12.ezyhttp.core.codec.BodyDeserializer) DataConverters(com.tvd12.ezyhttp.core.codec.DataConverters) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Example 5 with DataConverters

use of com.tvd12.ezyhttp.core.codec.DataConverters in project ezyhttp by youngmonkeys.

the class DataConvertersTest method getBodySerializerWithUTF8Test.

@Test
public void getBodySerializerWithUTF8Test() {
    // given
    DataConverters sut = new DataConverters(new ObjectMapper());
    String contentType = ContentTypes.TEXT_HTML_UTF8;
    // when
    BodySerializer actual = sut.getBodySerializer(contentType);
    // then
    Asserts.assertEquals(TextBodyConverter.class, actual.getClass());
}
Also used : DataConverters(com.tvd12.ezyhttp.core.codec.DataConverters) BodySerializer(com.tvd12.ezyhttp.core.codec.BodySerializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Aggregations

DataConverters (com.tvd12.ezyhttp.core.codec.DataConverters)13 Test (org.testng.annotations.Test)13 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 BodySerializer (com.tvd12.ezyhttp.core.codec.BodySerializer)7 RequestCookie (com.tvd12.ezyhttp.server.core.annotation.RequestCookie)4 ComponentManager (com.tvd12.ezyhttp.server.core.manager.ComponentManager)4 RequestHandlerManager (com.tvd12.ezyhttp.server.core.manager.RequestHandlerManager)4 RequestURI (com.tvd12.ezyhttp.server.core.request.RequestURI)4 BlockingServlet (com.tvd12.ezyhttp.server.core.servlet.BlockingServlet)4 ServletOutputStream (javax.servlet.ServletOutputStream)4 Cookie (javax.servlet.http.Cookie)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 ToString (lombok.ToString)4 BodyDeserializer (com.tvd12.ezyhttp.core.codec.BodyDeserializer)3 RequestInterceptor (com.tvd12.ezyhttp.server.core.interceptor.RequestInterceptor)3 RequestResponseWatcher (com.tvd12.ezyhttp.server.core.handler.RequestResponseWatcher)2 RequestURIManager (com.tvd12.ezyhttp.server.core.manager.RequestURIManager)1 RequestURIMeta (com.tvd12.ezyhttp.server.core.request.RequestURIMeta)1 HashMap (java.util.HashMap)1