Search in sources :

Example 6 with Decompressor

use of io.grpc.Decompressor in project grpc-java by grpc.

the class ClientCallImplTest method prepareHeaders_acceptedMessageEncodingsAdded.

@Test
public void prepareHeaders_acceptedMessageEncodingsAdded() {
    Metadata m = new Metadata();
    DecompressorRegistry customRegistry = DecompressorRegistry.emptyInstance().with(new Decompressor() {

        @Override
        public String getMessageEncoding() {
            return "a";
        }

        @Override
        public InputStream decompress(InputStream is) throws IOException {
            return null;
        }
    }, true).with(new Decompressor() {

        @Override
        public String getMessageEncoding() {
            return "b";
        }

        @Override
        public InputStream decompress(InputStream is) throws IOException {
            return null;
        }
    }, true).with(new Decompressor() {

        @Override
        public String getMessageEncoding() {
            return "c";
        }

        @Override
        public InputStream decompress(InputStream is) throws IOException {
            return null;
        }
    }, // not advertised
    false);
    ClientCallImpl.prepareHeaders(m, customRegistry, Codec.Identity.NONE, false);
    Iterable<String> acceptedEncodings = ACCEPT_ENCODING_SPLITTER.split(new String(m.get(GrpcUtil.MESSAGE_ACCEPT_ENCODING_KEY), GrpcUtil.US_ASCII));
    // Order may be different, since decoder priorities have not yet been implemented.
    assertEquals(ImmutableSet.of("b", "a"), ImmutableSet.copyOf(acceptedEncodings));
}
Also used : Decompressor(io.grpc.Decompressor) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Metadata(io.grpc.Metadata) DecompressorRegistry(io.grpc.DecompressorRegistry) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

Decompressor (io.grpc.Decompressor)6 DecompressorRegistry (io.grpc.DecompressorRegistry)5 IOException (java.io.IOException)5 Metadata (io.grpc.Metadata)4 InputStream (java.io.InputStream)4 Test (org.junit.Test)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 Compressor (io.grpc.Compressor)1 CompressorRegistry (io.grpc.CompressorRegistry)1 Server (io.grpc.Server)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 NettyServerBuilder (io.grpc.netty.NettyServerBuilder)1 StreamObserver (io.grpc.stub.StreamObserver)1 DeliberateException (io.servicetalk.concurrent.internal.DeliberateException)1 GrpcStatusException (io.servicetalk.grpc.api.GrpcStatusException)1 CompatRequest (io.servicetalk.grpc.netty.CompatProto.RequestContainer.CompatRequest)1 CompatResponse (io.servicetalk.grpc.netty.CompatProto.ResponseContainer.CompatResponse)1 StreamResetException (io.vertx.core.http.StreamResetException)1 BridgeMessageDecoder (io.vertx.grpc.common.impl.BridgeMessageDecoder)1