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