Search in sources :

Example 16 with HttpOutputMessage

use of org.springframework.http.HttpOutputMessage in project geode by apache.

the class SerializableObjectHttpMessageConverterJUnitTest method testSetContentLength.

@Test
public void testSetContentLength() {
    final byte[] bytes = { (byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE };
    final HttpHeaders headers = new HttpHeaders();
    final HttpOutputMessage mockOutputMessage = mockContext.mock(HttpOutputMessage.class, "HttpOutputMessage");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockOutputMessage).getHeaders();
            will(returnValue(headers));
        }
    });
    final SerializableObjectHttpMessageConverter converter = new SerializableObjectHttpMessageConverter();
    converter.setContentLength(mockOutputMessage, bytes);
    assertEquals(bytes.length, headers.getContentLength());
}
Also used : Expectations(org.jmock.Expectations) HttpHeaders(org.springframework.http.HttpHeaders) HttpOutputMessage(org.springframework.http.HttpOutputMessage) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Aggregations

HttpOutputMessage (org.springframework.http.HttpOutputMessage)16 HttpHeaders (org.springframework.http.HttpHeaders)14 HttpInputMessage (org.springframework.http.HttpInputMessage)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Test (org.junit.Test)6 FastJsonConfig (com.alibaba.fastjson.support.config.FastJsonConfig)4 Method (java.lang.reflect.Method)4 MediaType (org.springframework.http.MediaType)4 IOException (java.io.IOException)3 StreamingHttpOutputMessage (org.springframework.http.StreamingHttpOutputMessage)3 FastJsonHttpMessageConverter (com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter)2 FastJsonpHttpMessageConverter4 (com.alibaba.fastjson.support.spring.FastJsonpHttpMessageConverter4)2 OutputStream (java.io.OutputStream)2 UnitTest (org.apache.geode.test.junit.categories.UnitTest)2 Expectations (org.jmock.Expectations)2 ResponseEntity (org.springframework.http.ResponseEntity)2 ServletServerHttpResponse (org.springframework.http.server.ServletServerHttpResponse)2 FastJsonHttpMessageConverter4 (com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4)1 MappingFastJsonValue (com.alibaba.fastjson.support.spring.MappingFastJsonValue)1