use of cn.taketoday.http.codec.json.Jackson2JsonEncoder in project today-infrastructure by TAKETODAY.
the class CodecConfigurerTests method cloneCustomCodecs.
@Test
void cloneCustomCodecs() {
this.configurer.registerDefaults(false);
assertThat(this.configurer.getReaders()).isEmpty();
assertThat(this.configurer.getWriters()).isEmpty();
this.configurer.customCodecs().register(new Jackson2JsonEncoder());
this.configurer.customCodecs().register(new Jackson2JsonDecoder());
this.configurer.customCodecs().register(new ServerSentEventHttpMessageReader());
this.configurer.customCodecs().register(new ServerSentEventHttpMessageWriter());
assertThat(this.configurer.getReaders()).hasSize(2);
assertThat(this.configurer.getWriters()).hasSize(2);
CodecConfigurer clone = this.configurer.clone();
assertThat(this.configurer.getReaders()).hasSize(2);
assertThat(this.configurer.getWriters()).hasSize(2);
assertThat(clone.getReaders()).hasSize(2);
assertThat(clone.getWriters()).hasSize(2);
}
use of cn.taketoday.http.codec.json.Jackson2JsonEncoder in project today-infrastructure by TAKETODAY.
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();
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);
assertDecoderInstance(jacksonDecoder);
assertDecoderInstance(smileDecoder);
assertDecoderInstance(protobufDecoder);
assertEncoderInstance(jacksonEncoder);
assertEncoderInstance(smileEncoder);
assertEncoderInstance(protobufEncoder);
}
use of cn.taketoday.http.codec.json.Jackson2JsonEncoder in project today-infrastructure by TAKETODAY.
the class CodecConfigurerTests method cloneEmptyCustomCodecs.
@Test
void cloneEmptyCustomCodecs() {
this.configurer.registerDefaults(false);
assertThat(this.configurer.getReaders()).isEmpty();
assertThat(this.configurer.getWriters()).isEmpty();
CodecConfigurer clone = this.configurer.clone();
clone.customCodecs().register(new Jackson2JsonEncoder());
clone.customCodecs().register(new Jackson2JsonDecoder());
clone.customCodecs().register(new ServerSentEventHttpMessageReader());
clone.customCodecs().register(new ServerSentEventHttpMessageWriter());
assertThat(this.configurer.getReaders()).isEmpty();
assertThat(this.configurer.getWriters()).isEmpty();
assertThat(clone.getReaders()).hasSize(2);
assertThat(clone.getWriters()).hasSize(2);
}
Aggregations