Java Code Examples for io.grpc.internal.ServerStream#flush()
The following examples show how to use
io.grpc.internal.ServerStream#flush() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractTransportTest.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Test public void transportTracer_server_send_msg() throws Exception { server.start(serverListener); client = newClientTransport(server); startTransport(client, mockClientTransportListener); ClientStream clientStream = client.newStream(methodDescriptor, new Metadata(), callOptions); ClientStreamListenerBase clientStreamListener = new ClientStreamListenerBase(); clientStream.start(clientStreamListener); MockServerTransportListener serverTransportListener = serverListener.takeListenerOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS); StreamCreation serverStreamCreation = serverTransportListener.takeStreamOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS); ServerStream serverStream = serverStreamCreation.stream; if (!haveTransportTracer()) { return; } TransportStats serverBefore = getTransportStats(serverTransportListener.transport); assertEquals(0, serverBefore.messagesSent); assertEquals(0, serverBefore.lastMessageSentTimeNanos); TransportStats clientBefore = getTransportStats(client); assertEquals(0, clientBefore.messagesReceived); assertEquals(0, clientBefore.lastMessageReceivedTimeNanos); clientStream.request(1); serverStream.writeHeaders(new Metadata()); serverStream.writeMessage(methodDescriptor.streamResponse("response")); serverStream.flush(); verifyMessageCountAndClose(clientStreamListener.messageQueue, 1); TransportStats serverAfter = getTransportStats(serverTransportListener.transport); assertEquals(1, serverAfter.messagesSent); assertEquals(fakeCurrentTimeNanos(), serverAfter.lastMessageSentTimeNanos); TransportStats clientAfter = getTransportStats(client); assertEquals(1, clientAfter.messagesReceived); assertEquals(fakeCurrentTimeNanos(), clientAfter.lastMessageReceivedTimeNanos); serverStream.close(Status.OK, new Metadata()); }