Search in sources :

Example 31 with Metadata

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

the class AbstractTransportTest method authorityPropagation.

@Test
@SuppressWarnings("deprecation")
public void authorityPropagation() throws Exception {
    server.start(serverListener);
    client = newClientTransport(server);
    runIfNotNull(client.start(mockClientTransportListener));
    MockServerTransportListener serverTransportListener = serverListener.takeListenerOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS);
    Metadata clientHeaders = new Metadata();
    ClientStream clientStream = client.newStream(methodDescriptor, clientHeaders);
    clientStream.start(mockClientStreamListener);
    StreamCreation serverStreamCreation = serverTransportListener.takeStreamOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS);
    ServerStream serverStream = serverStreamCreation.stream;
    assertEquals(testAuthority(server), serverStream.getAuthority());
}
Also used : Metadata(io.grpc.Metadata) ServerStream(io.grpc.internal.ServerStream) ClientStream(io.grpc.internal.ClientStream) Test(org.junit.Test)

Example 32 with Metadata

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

the class ServerCallsTest method disablingInboundAutoFlowControlForUnaryHasNoEffect.

@Test
public void disablingInboundAutoFlowControlForUnaryHasNoEffect() throws Exception {
    ServerCallHandler<Integer, Integer> callHandler = ServerCalls.asyncUnaryCall(new ServerCalls.UnaryMethod<Integer, Integer>() {

        @Override
        public void invoke(Integer req, StreamObserver<Integer> responseObserver) {
            ServerCallStreamObserver<Integer> serverCallObserver = (ServerCallStreamObserver<Integer>) responseObserver;
            serverCallObserver.disableAutoInboundFlowControl();
        }
    });
    callHandler.startCall(serverCall, new Metadata());
    // Auto inbound flow-control always requests 2 messages for unary to detect a violation
    // of the unary semantic.
    assertThat(serverCall.requestCalls).containsExactly(2);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Metadata(io.grpc.Metadata) Test(org.junit.Test)

Example 33 with Metadata

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project sonarlint-core by SonarSource.

the class StandaloneDaemonTest method shutdown.

@After
public void shutdown() throws Exception {
    ClientCall<Void, Void> call = channel.newCall(StandaloneSonarLintGrpc.METHOD_SHUTDOWN, CallOptions.DEFAULT);
    call.start(new Listener<Void>() {
    }, new Metadata());
    call.sendMessage(Void.newBuilder().build());
    call.halfClose();
    call.request(1);
    channel.shutdownNow();
    channel.awaitTermination(2, TimeUnit.SECONDS);
}
Also used : Metadata(io.grpc.Metadata) Void(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Void) After(org.junit.After)

Example 34 with Metadata

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project sonarlint-core by SonarSource.

the class StandaloneDaemonTest method getLogs.

private ClientCall<Void, LogEvent> getLogs(LogCollector collector, Channel channel) {
    ClientCall<Void, LogEvent> call = channel.newCall(StandaloneSonarLintGrpc.METHOD_STREAM_LOGS, CallOptions.DEFAULT);
    call.start(collector, new Metadata());
    call.sendMessage(Void.newBuilder().build());
    call.halfClose();
    call.request(Integer.MAX_VALUE);
    return call;
}
Also used : LogEvent(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.LogEvent) Metadata(io.grpc.Metadata) Void(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Void)

Example 35 with Metadata

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project sonarlint-core by SonarSource.

the class ExceptionInterceptorTest method testInterceptor.

@Test
public void testInterceptor() {
    ExceptionInterceptor interceptor = new ExceptionInterceptor();
    ServerCall<Void, Void> call = mock(ServerCall.class);
    Metadata headers = new Metadata();
    ServerCallHandler<Void, Void> next = mock(ServerCallHandler.class);
    interceptor.interceptCall(call, headers, next);
    verify(next).startCall(isA(TransformStatusServerCall.class), eq(headers));
}
Also used : TransformStatusServerCall(org.sonarlint.daemon.interceptors.ExceptionInterceptor.TransformStatusServerCall) 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