Search in sources :

Example 1 with Jackson2SmileDecoder

use of cn.taketoday.http.codec.json.Jackson2SmileDecoder in project today-infrastructure by TAKETODAY.

the class BaseDefaultCodecs method initObjectReaders.

/**
 * Reset and initialize object readers.
 */
protected void initObjectReaders() {
    this.objectReaders.clear();
    if (!this.registerDefaults) {
        return;
    }
    if (jackson2Present) {
        addCodec(this.objectReaders, new DecoderHttpMessageReader<>(getJackson2JsonDecoder()));
    }
    if (jackson2SmilePresent) {
        addCodec(this.objectReaders, new DecoderHttpMessageReader<>(this.jackson2SmileDecoder != null ? (Jackson2SmileDecoder) this.jackson2SmileDecoder : new Jackson2SmileDecoder()));
    }
    // if (jaxb2Present && !shouldIgnoreXml) {
    // addCodec(this.objectReaders, new DecoderHttpMessageReader<>(this.jaxb2Decoder != null ?
    // (Jaxb2XmlDecoder) this.jaxb2Decoder : new Jaxb2XmlDecoder()));
    // }
    // client vs server..
    extendObjectReaders(this.objectReaders);
}
Also used : Jackson2SmileDecoder(cn.taketoday.http.codec.json.Jackson2SmileDecoder)

Example 2 with Jackson2SmileDecoder

use of cn.taketoday.http.codec.json.Jackson2SmileDecoder in project today-infrastructure by TAKETODAY.

the class ClientCodecConfigurerTests method maxInMemorySize.

@Test
public void maxInMemorySize() {
    int size = 99;
    this.configurer.defaultCodecs().maxInMemorySize(size);
    List<HttpMessageReader<?>> readers = this.configurer.getReaders();
    assertThat(readers.size()).isEqualTo(12);
    assertThat(((ByteArrayDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ByteBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((DataBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((NettyByteBufDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ResourceDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ProtobufDecoder) getNextDecoder(readers)).getMaxMessageSize()).isEqualTo(size);
    assertThat(((FormHttpMessageReader) nextReader(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2JsonDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2SmileDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    ServerSentEventHttpMessageReader reader = (ServerSentEventHttpMessageReader) nextReader(readers);
    assertThat(reader.getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2JsonDecoder) reader.getDecoder()).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
}
Also used : Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) ProtobufDecoder(cn.taketoday.http.codec.protobuf.ProtobufDecoder) StringDecoder(cn.taketoday.core.codec.StringDecoder) ResourceDecoder(cn.taketoday.core.codec.ResourceDecoder) ByteBufferDecoder(cn.taketoday.core.codec.ByteBufferDecoder) 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) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) NettyByteBufDecoder(cn.taketoday.core.codec.NettyByteBufDecoder) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) DataBufferDecoder(cn.taketoday.core.codec.DataBufferDecoder) ByteArrayDecoder(cn.taketoday.core.codec.ByteArrayDecoder) Jackson2SmileDecoder(cn.taketoday.http.codec.json.Jackson2SmileDecoder) Test(org.junit.jupiter.api.Test)

Example 3 with Jackson2SmileDecoder

use of cn.taketoday.http.codec.json.Jackson2SmileDecoder in project today-framework by TAKETODAY.

the class BaseDefaultCodecs method initObjectReaders.

/**
 * Reset and initialize object readers.
 */
protected void initObjectReaders() {
    this.objectReaders.clear();
    if (!this.registerDefaults) {
        return;
    }
    if (jackson2Present) {
        addCodec(this.objectReaders, new DecoderHttpMessageReader<>(getJackson2JsonDecoder()));
    }
    if (jackson2SmilePresent) {
        addCodec(this.objectReaders, new DecoderHttpMessageReader<>(this.jackson2SmileDecoder != null ? (Jackson2SmileDecoder) this.jackson2SmileDecoder : new Jackson2SmileDecoder()));
    }
    // if (jaxb2Present && !shouldIgnoreXml) {
    // addCodec(this.objectReaders, new DecoderHttpMessageReader<>(this.jaxb2Decoder != null ?
    // (Jaxb2XmlDecoder) this.jaxb2Decoder : new Jaxb2XmlDecoder()));
    // }
    // client vs server..
    extendObjectReaders(this.objectReaders);
}
Also used : Jackson2SmileDecoder(cn.taketoday.http.codec.json.Jackson2SmileDecoder)

Example 4 with Jackson2SmileDecoder

use of cn.taketoday.http.codec.json.Jackson2SmileDecoder in project today-framework by TAKETODAY.

the class ClientCodecConfigurerTests method maxInMemorySize.

@Test
public void maxInMemorySize() {
    int size = 99;
    this.configurer.defaultCodecs().maxInMemorySize(size);
    List<HttpMessageReader<?>> readers = this.configurer.getReaders();
    assertThat(readers.size()).isEqualTo(12);
    assertThat(((ByteArrayDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ByteBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((DataBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((NettyByteBufDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ResourceDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ProtobufDecoder) getNextDecoder(readers)).getMaxMessageSize()).isEqualTo(size);
    assertThat(((FormHttpMessageReader) nextReader(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2JsonDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2SmileDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    ServerSentEventHttpMessageReader reader = (ServerSentEventHttpMessageReader) nextReader(readers);
    assertThat(reader.getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2JsonDecoder) reader.getDecoder()).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
}
Also used : Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) ProtobufDecoder(cn.taketoday.http.codec.protobuf.ProtobufDecoder) StringDecoder(cn.taketoday.core.codec.StringDecoder) ResourceDecoder(cn.taketoday.core.codec.ResourceDecoder) ByteBufferDecoder(cn.taketoday.core.codec.ByteBufferDecoder) 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) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) NettyByteBufDecoder(cn.taketoday.core.codec.NettyByteBufDecoder) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) DataBufferDecoder(cn.taketoday.core.codec.DataBufferDecoder) ByteArrayDecoder(cn.taketoday.core.codec.ByteArrayDecoder) Jackson2SmileDecoder(cn.taketoday.http.codec.json.Jackson2SmileDecoder) Test(org.junit.jupiter.api.Test)

Example 5 with Jackson2SmileDecoder

use of cn.taketoday.http.codec.json.Jackson2SmileDecoder in project today-framework 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);
}
Also used : ProtobufEncoder(cn.taketoday.http.codec.protobuf.ProtobufEncoder) Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) Jackson2SmileEncoder(cn.taketoday.http.codec.json.Jackson2SmileEncoder) ProtobufDecoder(cn.taketoday.http.codec.protobuf.ProtobufDecoder) Jackson2JsonEncoder(cn.taketoday.http.codec.json.Jackson2JsonEncoder) Jackson2SmileDecoder(cn.taketoday.http.codec.json.Jackson2SmileDecoder) Test(org.junit.jupiter.api.Test)

Aggregations

Jackson2SmileDecoder (cn.taketoday.http.codec.json.Jackson2SmileDecoder)8 Jackson2JsonDecoder (cn.taketoday.http.codec.json.Jackson2JsonDecoder)6 ProtobufDecoder (cn.taketoday.http.codec.protobuf.ProtobufDecoder)6 Test (org.junit.jupiter.api.Test)6 ByteArrayDecoder (cn.taketoday.core.codec.ByteArrayDecoder)4 ByteBufferDecoder (cn.taketoday.core.codec.ByteBufferDecoder)4 DataBufferDecoder (cn.taketoday.core.codec.DataBufferDecoder)4 NettyByteBufDecoder (cn.taketoday.core.codec.NettyByteBufDecoder)4 ResourceDecoder (cn.taketoday.core.codec.ResourceDecoder)4 StringDecoder (cn.taketoday.core.codec.StringDecoder)4 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)2 Jackson2JsonEncoder (cn.taketoday.http.codec.json.Jackson2JsonEncoder)2 Jackson2SmileEncoder (cn.taketoday.http.codec.json.Jackson2SmileEncoder)2 DefaultPartHttpMessageReader (cn.taketoday.http.codec.multipart.DefaultPartHttpMessageReader)2 MultipartHttpMessageReader (cn.taketoday.http.codec.multipart.MultipartHttpMessageReader)2 PartEventHttpMessageReader (cn.taketoday.http.codec.multipart.PartEventHttpMessageReader)2