Search in sources :

Example 1 with MultipartHttpMessageWriter

use of cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter in project today-infrastructure by TAKETODAY.

the class ClientCodecConfigurerTests method jackson2CodecCustomization.

@Test
public void jackson2CodecCustomization() {
    Jackson2JsonDecoder decoder = new Jackson2JsonDecoder();
    Jackson2JsonEncoder encoder = new Jackson2JsonEncoder();
    this.configurer.defaultCodecs().jackson2JsonDecoder(decoder);
    this.configurer.defaultCodecs().jackson2JsonEncoder(encoder);
    List<HttpMessageReader<?>> readers = this.configurer.getReaders();
    Jackson2JsonDecoder actualDecoder = findCodec(readers, Jackson2JsonDecoder.class);
    assertThat(actualDecoder).isSameAs(decoder);
    assertThat(findCodec(readers, ServerSentEventHttpMessageReader.class).getDecoder()).isSameAs(decoder);
    List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
    Jackson2JsonEncoder actualEncoder = findCodec(writers, Jackson2JsonEncoder.class);
    assertThat(actualEncoder).isSameAs(encoder);
    MultipartHttpMessageWriter multipartWriter = findCodec(writers, MultipartHttpMessageWriter.class);
    actualEncoder = findCodec(multipartWriter.getPartWriters(), Jackson2JsonEncoder.class);
    assertThat(actualEncoder).isSameAs(encoder);
}
Also used : ResourceHttpMessageReader(cn.taketoday.http.codec.ResourceHttpMessageReader) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) DecoderHttpMessageReader(cn.taketoday.http.codec.DecoderHttpMessageReader) HttpMessageReader(cn.taketoday.http.codec.HttpMessageReader) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) Jackson2JsonEncoder(cn.taketoday.http.codec.json.Jackson2JsonEncoder) Test(org.junit.jupiter.api.Test)

Example 2 with MultipartHttpMessageWriter

use of cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter in project today-infrastructure by TAKETODAY.

the class ClientCodecConfigurerTests method objectMapperCustomization.

@Test
public void objectMapperCustomization() {
    ObjectMapper objectMapper = new ObjectMapper();
    this.configurer.defaultCodecs().configureDefaultCodec(codec -> {
        if (codec instanceof Jackson2CodecSupport) {
            ((Jackson2CodecSupport) codec).setObjectMapper(objectMapper);
        }
    });
    List<HttpMessageReader<?>> readers = this.configurer.getReaders();
    Jackson2JsonDecoder actualDecoder = findCodec(readers, Jackson2JsonDecoder.class);
    assertThat(actualDecoder.getObjectMapper()).isSameAs(objectMapper);
    List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
    Jackson2JsonEncoder actualEncoder = findCodec(writers, Jackson2JsonEncoder.class);
    assertThat(actualEncoder.getObjectMapper()).isSameAs(objectMapper);
    MultipartHttpMessageWriter multipartWriter = findCodec(writers, MultipartHttpMessageWriter.class);
    actualEncoder = findCodec(multipartWriter.getPartWriters(), Jackson2JsonEncoder.class);
    assertThat(actualEncoder.getObjectMapper()).isSameAs(objectMapper);
}
Also used : ResourceHttpMessageReader(cn.taketoday.http.codec.ResourceHttpMessageReader) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) DecoderHttpMessageReader(cn.taketoday.http.codec.DecoderHttpMessageReader) HttpMessageReader(cn.taketoday.http.codec.HttpMessageReader) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Jackson2CodecSupport(cn.taketoday.http.codec.json.Jackson2CodecSupport) Jackson2JsonEncoder(cn.taketoday.http.codec.json.Jackson2JsonEncoder) Test(org.junit.jupiter.api.Test)

Example 3 with MultipartHttpMessageWriter

use of cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter in project today-infrastructure by TAKETODAY.

the class ClientCodecConfigurerTests method enableLoggingRequestDetails.

@Test
public void enableLoggingRequestDetails() {
    this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
    List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
    MultipartHttpMessageWriter multipartWriter = findCodec(writers, MultipartHttpMessageWriter.class);
    assertThat(multipartWriter.isEnableLoggingRequestDetails()).isTrue();
    FormHttpMessageWriter formWriter = (FormHttpMessageWriter) multipartWriter.getFormWriter();
    assertThat(formWriter).isNotNull();
    assertThat(formWriter.isEnableLoggingRequestDetails()).isTrue();
}
Also used : MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) Test(org.junit.jupiter.api.Test)

Example 4 with MultipartHttpMessageWriter

use of cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter in project today-framework by TAKETODAY.

the class ClientCodecConfigurerTests method enableLoggingRequestDetails.

@Test
public void enableLoggingRequestDetails() {
    this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
    List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
    MultipartHttpMessageWriter multipartWriter = findCodec(writers, MultipartHttpMessageWriter.class);
    assertThat(multipartWriter.isEnableLoggingRequestDetails()).isTrue();
    FormHttpMessageWriter formWriter = (FormHttpMessageWriter) multipartWriter.getFormWriter();
    assertThat(formWriter).isNotNull();
    assertThat(formWriter.isEnableLoggingRequestDetails()).isTrue();
}
Also used : MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) Test(org.junit.jupiter.api.Test)

Example 5 with MultipartHttpMessageWriter

use of cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter in project today-framework by TAKETODAY.

the class ClientCodecConfigurerTests method jackson2CodecCustomization.

@Test
public void jackson2CodecCustomization() {
    Jackson2JsonDecoder decoder = new Jackson2JsonDecoder();
    Jackson2JsonEncoder encoder = new Jackson2JsonEncoder();
    this.configurer.defaultCodecs().jackson2JsonDecoder(decoder);
    this.configurer.defaultCodecs().jackson2JsonEncoder(encoder);
    List<HttpMessageReader<?>> readers = this.configurer.getReaders();
    Jackson2JsonDecoder actualDecoder = findCodec(readers, Jackson2JsonDecoder.class);
    assertThat(actualDecoder).isSameAs(decoder);
    assertThat(findCodec(readers, ServerSentEventHttpMessageReader.class).getDecoder()).isSameAs(decoder);
    List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
    Jackson2JsonEncoder actualEncoder = findCodec(writers, Jackson2JsonEncoder.class);
    assertThat(actualEncoder).isSameAs(encoder);
    MultipartHttpMessageWriter multipartWriter = findCodec(writers, MultipartHttpMessageWriter.class);
    actualEncoder = findCodec(multipartWriter.getPartWriters(), Jackson2JsonEncoder.class);
    assertThat(actualEncoder).isSameAs(encoder);
}
Also used : ResourceHttpMessageReader(cn.taketoday.http.codec.ResourceHttpMessageReader) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) DecoderHttpMessageReader(cn.taketoday.http.codec.DecoderHttpMessageReader) HttpMessageReader(cn.taketoday.http.codec.HttpMessageReader) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) Jackson2JsonEncoder(cn.taketoday.http.codec.json.Jackson2JsonEncoder) Test(org.junit.jupiter.api.Test)

Aggregations

MultipartHttpMessageWriter (cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter)12 FormHttpMessageWriter (cn.taketoday.http.codec.FormHttpMessageWriter)10 EncoderHttpMessageWriter (cn.taketoday.http.codec.EncoderHttpMessageWriter)8 HttpMessageWriter (cn.taketoday.http.codec.HttpMessageWriter)8 ResourceHttpMessageWriter (cn.taketoday.http.codec.ResourceHttpMessageWriter)8 PartEventHttpMessageWriter (cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter)8 Test (org.junit.jupiter.api.Test)8 Jackson2JsonEncoder (cn.taketoday.http.codec.json.Jackson2JsonEncoder)6 ProtobufHttpMessageWriter (cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter)6 DecoderHttpMessageReader (cn.taketoday.http.codec.DecoderHttpMessageReader)4 FormHttpMessageReader (cn.taketoday.http.codec.FormHttpMessageReader)4 HttpMessageReader (cn.taketoday.http.codec.HttpMessageReader)4 ResourceHttpMessageReader (cn.taketoday.http.codec.ResourceHttpMessageReader)4 ServerSentEventHttpMessageReader (cn.taketoday.http.codec.ServerSentEventHttpMessageReader)4 Jackson2JsonDecoder (cn.taketoday.http.codec.json.Jackson2JsonDecoder)4 LinkedMultiValueMap (cn.taketoday.core.LinkedMultiValueMap)2 MultiValueMap (cn.taketoday.core.MultiValueMap)2 ByteBufferEncoder (cn.taketoday.core.codec.ByteBufferEncoder)2 MultipartBodyBuilder (cn.taketoday.http.client.MultipartBodyBuilder)2 ServerSentEventHttpMessageWriter (cn.taketoday.http.codec.ServerSentEventHttpMessageWriter)2