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);
}
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);
}
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();
}
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();
}
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);
}
Aggregations