use of org.springframework.http.codec.json.Jackson2SmileEncoder in project spring-framework by spring-projects.
the class ClientCodecConfigurerTests method clonedConfigurer.
@Test
public void clonedConfigurer() {
ClientCodecConfigurer clone = this.configurer.clone();
Jackson2JsonDecoder jackson2Decoder = new Jackson2JsonDecoder();
clone.defaultCodecs().serverSentEventDecoder(jackson2Decoder);
clone.defaultCodecs().multipartCodecs().encoder(new Jackson2SmileEncoder());
clone.defaultCodecs().multipartCodecs().writer(new ResourceHttpMessageWriter());
// Clone has the customizations
Decoder<?> sseDecoder = findCodec(clone.getReaders(), ServerSentEventHttpMessageReader.class).getDecoder();
List<HttpMessageWriter<?>> writers = findCodec(clone.getWriters(), MultipartHttpMessageWriter.class).getPartWriters();
assertThat(sseDecoder).isSameAs(jackson2Decoder);
assertThat(writers).hasSize(2);
// Original does not have the customizations
sseDecoder = findCodec(this.configurer.getReaders(), ServerSentEventHttpMessageReader.class).getDecoder();
writers = findCodec(this.configurer.getWriters(), MultipartHttpMessageWriter.class).getPartWriters();
assertThat(sseDecoder).isNotSameAs(jackson2Decoder);
assertThat(writers).hasSize(12);
}
use of org.springframework.http.codec.json.Jackson2SmileEncoder in project spring-framework by spring-projects.
the class CodecConfigurerTests method encoderDecoderOverrides.
@Test
void encoderDecoderOverrides() {
Jackson2JsonDecoder jacksonDecoder = new Jackson2JsonDecoder();
Jackson2JsonEncoder jacksonEncoder = new Jackson2JsonEncoder();
Jackson2SmileDecoder smileDecoder = new Jackson2SmileDecoder();
Jackson2SmileEncoder smileEncoder = new Jackson2SmileEncoder();
ProtobufDecoder protobufDecoder = new ProtobufDecoder(ExtensionRegistry.newInstance());
ProtobufEncoder protobufEncoder = new ProtobufEncoder();
Jaxb2XmlEncoder jaxb2Encoder = new Jaxb2XmlEncoder();
Jaxb2XmlDecoder jaxb2Decoder = new Jaxb2XmlDecoder();
this.configurer.defaultCodecs().jackson2JsonDecoder(jacksonDecoder);
this.configurer.defaultCodecs().jackson2JsonEncoder(jacksonEncoder);
this.configurer.defaultCodecs().jackson2SmileDecoder(smileDecoder);
this.configurer.defaultCodecs().jackson2SmileEncoder(smileEncoder);
this.configurer.defaultCodecs().protobufDecoder(protobufDecoder);
this.configurer.defaultCodecs().protobufEncoder(protobufEncoder);
this.configurer.defaultCodecs().jaxb2Decoder(jaxb2Decoder);
this.configurer.defaultCodecs().jaxb2Encoder(jaxb2Encoder);
assertDecoderInstance(jacksonDecoder);
assertDecoderInstance(smileDecoder);
assertDecoderInstance(protobufDecoder);
assertDecoderInstance(jaxb2Decoder);
assertEncoderInstance(jacksonEncoder);
assertEncoderInstance(smileEncoder);
assertEncoderInstance(protobufEncoder);
assertEncoderInstance(jaxb2Encoder);
}
Aggregations