Search in sources :

Example 6 with Metadata

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project grpc-java by grpc.

the class AbstractClientStream2Test method inboundHeadersReceived_acceptsGzipEncoding.

@Test
public void inboundHeadersReceived_acceptsGzipEncoding() {
    AbstractClientStream2 stream = new BaseAbstractClientStream(allocator, statsTraceCtx);
    stream.start(mockListener);
    Metadata headers = new Metadata();
    headers.put(GrpcUtil.MESSAGE_ENCODING_KEY, new Codec.Gzip().getMessageEncoding());
    stream.transportState().inboundHeadersReceived(headers);
    verify(mockListener).headersRead(headers);
}
Also used : Metadata(io.grpc.Metadata) Test(org.junit.Test)

Example 7 with Metadata

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project grpc-java by grpc.

the class AbstractClientStream2Test method inboundHeadersReceived_acceptsIdentityEncoding.

@Test
public void inboundHeadersReceived_acceptsIdentityEncoding() {
    AbstractClientStream2 stream = new BaseAbstractClientStream(allocator, statsTraceCtx);
    stream.start(mockListener);
    Metadata headers = new Metadata();
    headers.put(GrpcUtil.MESSAGE_ENCODING_KEY, Codec.Identity.NONE.getMessageEncoding());
    stream.transportState().inboundHeadersReceived(headers);
    verify(mockListener).headersRead(headers);
}
Also used : Metadata(io.grpc.Metadata) Test(org.junit.Test)

Example 8 with Metadata

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project grpc-java by grpc.

the class AbstractClientStream2Test method inboundHeadersReceived_failsIfStatusReported.

@Test
public void inboundHeadersReceived_failsIfStatusReported() {
    AbstractClientStream2 stream = new BaseAbstractClientStream(allocator, statsTraceCtx);
    stream.start(mockListener);
    stream.transportState().transportReportStatus(Status.CANCELLED, false, new Metadata());
    TransportState state = stream.transportState();
    thrown.expect(IllegalStateException.class);
    state.inboundHeadersReceived(new Metadata());
}
Also used : Metadata(io.grpc.Metadata) TransportState(io.grpc.internal.AbstractClientStream2.TransportState) Test(org.junit.Test)

Example 9 with Metadata

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project grpc-java by grpc.

the class AbstractClientStreamTest method inboundHeadersReceived_acceptsIdentityEncoding.

@Test
public void inboundHeadersReceived_acceptsIdentityEncoding() {
    AbstractClientStream stream = new BaseAbstractClientStream(allocator);
    stream.start(mockListener);
    Metadata headers = new Metadata();
    headers.put(GrpcUtil.MESSAGE_ENCODING_KEY, Codec.Identity.NONE.getMessageEncoding());
    stream.inboundHeadersReceived(headers);
    verify(mockListener).headersRead(headers);
}
Also used : Metadata(io.grpc.Metadata) Test(org.junit.Test)

Example 10 with Metadata

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project grpc-java by grpc.

the class AbstractClientStreamTest method inboundHeadersReceived_failsOnPhaseStatus.

@Test
public void inboundHeadersReceived_failsOnPhaseStatus() {
    AbstractClientStream stream = new BaseAbstractClientStream(allocator);
    stream.start(mockListener);
    Metadata headers = new Metadata();
    stream.inboundPhase(Phase.STATUS);
    thrown.expect(IllegalStateException.class);
    stream.inboundHeadersReceived(headers);
}
Also used : Metadata(io.grpc.Metadata) Test(org.junit.Test)

Aggregations

Metadata (io.grpc.Metadata)701 Test (org.junit.Test)559 Status (io.grpc.Status)190 CallOptions (io.grpc.CallOptions)56 ClientStreamTracer (io.grpc.ClientStreamTracer)51 ServerCall (io.grpc.ServerCall)48 PickSubchannelArgs (io.grpc.LoadBalancer.PickSubchannelArgs)44 InOrder (org.mockito.InOrder)41 Subchannel (io.grpc.LoadBalancer.Subchannel)40 ByteArrayInputStream (java.io.ByteArrayInputStream)40 InputStream (java.io.InputStream)38 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)33 IOException (java.io.IOException)32 AtomicReference (java.util.concurrent.atomic.AtomicReference)32 Context (io.grpc.Context)31 MockClientTransportInfo (io.grpc.internal.TestUtils.MockClientTransportInfo)31 InternalMetadata (io.grpc.InternalMetadata)30 MethodDescriptor (io.grpc.MethodDescriptor)30 EquivalentAddressGroup (io.grpc.EquivalentAddressGroup)29 ManagedChannel (io.grpc.ManagedChannel)27