Package io.grpc.internal.testing
Class TestClientStreamTracer
java.lang.Object
io.grpc.StreamTracer
io.grpc.ClientStreamTracer
io.grpc.internal.testing.TestClientStreamTracer
- All Implemented Interfaces:
TestStreamTracer
A
ClientStreamTracer
suitable for testing.-
Nested Class Summary
Nested classes/interfaces inherited from class io.grpc.ClientStreamTracer
io.grpc.ClientStreamTracer.Factory, io.grpc.ClientStreamTracer.StreamInfo
Nested classes/interfaces inherited from interface io.grpc.internal.testing.TestStreamTracer
TestStreamTracer.TestBaseStreamTracer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TestStreamTracer.TestBaseStreamTracer
protected final AtomicReference
<Throwable> protected final AtomicReference
<io.grpc.Metadata> protected final AtomicReference
<Throwable> protected final CountDownLatch
Fields inherited from class io.grpc.ClientStreamTracer
NAME_RESOLUTION_DELAYED
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
await()
Waits for the stream to be done.boolean
Waits for the stream to be done.boolean
awaitOutboundHeaders
(int timeout, TimeUnit unit) Allow tests to await the outbound header event, which depending on the test case may be necessary (e.g., if we test for a Netty client's outbound headers upon receiving the start of stream on the server side, the tracer won't know that headers were sent until a channel future executes).boolean
Returns ifClientStreamTracer.inboundHeaders()
has been called.io.grpc.Metadata
Returns the inbound trailers ifClientStreamTracer.inboundTrailers(io.grpc.Metadata)
has been called, ornull
.long
Returns to sum of all sizes passed toStreamTracer.inboundUncompressedSize(long)
.long
Returns to sum of all sizes passed toStreamTracer.inboundWireSize(long)
.boolean
Returns ifClientStreamTracer.outboundHeaders()
has been called.long
Returns to sum of al sizes passed toStreamTracer.outboundUncompressedSize(long)
.long
Returns to sum of all sizes passed toStreamTracer.outboundWireSize(long)
.io.grpc.Status
Returns the status passed toStreamTracer.streamClosed(io.grpc.Status)
.void
void
inboundMessage
(int seqNo) void
inboundMessageRead
(int seqNo, long optionalWireSize, long optionalUncompressedSize) void
inboundTrailers
(io.grpc.Metadata trailers) void
inboundUncompressedSize
(long bytes) void
inboundWireSize
(long bytes) Returns the next captured outbound message event.Returns the next captured outbound message event.void
void
outboundMessage
(int seqNo) void
outboundMessageSent
(int seqNo, long optionalWireSize, long optionalUncompressedSize) void
outboundUncompressedSize
(long bytes) void
outboundWireSize
(long bytes) void
setFailDuplicateCallbacks
(boolean fail) Sets whether to fail on unexpected duplicate calls to callback methods.void
streamClosed
(io.grpc.Status status) Methods inherited from class io.grpc.ClientStreamTracer
addOptionalLabel, createPendingStream, inboundHeaders, streamCreated
-
Field Details
-
delegate
-
outboundHeadersLatch
-
outboundHeadersCalled
-
inboundHeadersCalled
-
inboundTrailers
-
-
Constructor Details
-
TestClientStreamTracer
public TestClientStreamTracer()
-
-
Method Details
-
await
Description copied from interface:TestStreamTracer
Waits for the stream to be done.- Specified by:
await
in interfaceTestStreamTracer
- Throws:
InterruptedException
-
await
Description copied from interface:TestStreamTracer
Waits for the stream to be done.- Specified by:
await
in interfaceTestStreamTracer
- Throws:
InterruptedException
-
getInboundHeaders
public boolean getInboundHeaders()Returns ifClientStreamTracer.inboundHeaders()
has been called. -
getInboundTrailers
Returns the inbound trailers ifClientStreamTracer.inboundTrailers(io.grpc.Metadata)
has been called, ornull
. -
getOutboundHeaders
public boolean getOutboundHeaders()Returns ifClientStreamTracer.outboundHeaders()
has been called. -
awaitOutboundHeaders
Allow tests to await the outbound header event, which depending on the test case may be necessary (e.g., if we test for a Netty client's outbound headers upon receiving the start of stream on the server side, the tracer won't know that headers were sent until a channel future executes).- Throws:
Exception
-
getStatus
public io.grpc.Status getStatus()Description copied from interface:TestStreamTracer
Returns the status passed toStreamTracer.streamClosed(io.grpc.Status)
.- Specified by:
getStatus
in interfaceTestStreamTracer
-
getInboundWireSize
public long getInboundWireSize()Description copied from interface:TestStreamTracer
Returns to sum of all sizes passed toStreamTracer.inboundWireSize(long)
.- Specified by:
getInboundWireSize
in interfaceTestStreamTracer
-
getInboundUncompressedSize
public long getInboundUncompressedSize()Description copied from interface:TestStreamTracer
Returns to sum of all sizes passed toStreamTracer.inboundUncompressedSize(long)
.- Specified by:
getInboundUncompressedSize
in interfaceTestStreamTracer
-
getOutboundWireSize
public long getOutboundWireSize()Description copied from interface:TestStreamTracer
Returns to sum of all sizes passed toStreamTracer.outboundWireSize(long)
.- Specified by:
getOutboundWireSize
in interfaceTestStreamTracer
-
getOutboundUncompressedSize
public long getOutboundUncompressedSize()Description copied from interface:TestStreamTracer
Returns to sum of al sizes passed toStreamTracer.outboundUncompressedSize(long)
.- Specified by:
getOutboundUncompressedSize
in interfaceTestStreamTracer
-
setFailDuplicateCallbacks
public void setFailDuplicateCallbacks(boolean fail) Description copied from interface:TestStreamTracer
Sets whether to fail on unexpected duplicate calls to callback methods.- Specified by:
setFailDuplicateCallbacks
in interfaceTestStreamTracer
-
nextOutboundEvent
Description copied from interface:TestStreamTracer
Returns the next captured outbound message event.- Specified by:
nextOutboundEvent
in interfaceTestStreamTracer
-
nextInboundEvent
Description copied from interface:TestStreamTracer
Returns the next captured outbound message event.- Specified by:
nextInboundEvent
in interfaceTestStreamTracer
-
outboundWireSize
public void outboundWireSize(long bytes) - Overrides:
outboundWireSize
in classio.grpc.StreamTracer
-
inboundWireSize
public void inboundWireSize(long bytes) - Overrides:
inboundWireSize
in classio.grpc.StreamTracer
-
outboundUncompressedSize
public void outboundUncompressedSize(long bytes) - Overrides:
outboundUncompressedSize
in classio.grpc.StreamTracer
-
inboundUncompressedSize
public void inboundUncompressedSize(long bytes) - Overrides:
inboundUncompressedSize
in classio.grpc.StreamTracer
-
streamClosed
public void streamClosed(io.grpc.Status status) - Overrides:
streamClosed
in classio.grpc.StreamTracer
-
inboundMessage
public void inboundMessage(int seqNo) - Overrides:
inboundMessage
in classio.grpc.StreamTracer
-
outboundMessage
public void outboundMessage(int seqNo) - Overrides:
outboundMessage
in classio.grpc.StreamTracer
-
outboundMessageSent
public void outboundMessageSent(int seqNo, long optionalWireSize, long optionalUncompressedSize) - Overrides:
outboundMessageSent
in classio.grpc.StreamTracer
-
inboundMessageRead
public void inboundMessageRead(int seqNo, long optionalWireSize, long optionalUncompressedSize) - Overrides:
inboundMessageRead
in classio.grpc.StreamTracer
-
outboundHeaders
public void outboundHeaders()- Overrides:
outboundHeaders
in classio.grpc.ClientStreamTracer
-
inboundHeaders
public void inboundHeaders()- Overrides:
inboundHeaders
in classio.grpc.ClientStreamTracer
-
inboundTrailers
public void inboundTrailers(io.grpc.Metadata trailers) - Overrides:
inboundTrailers
in classio.grpc.ClientStreamTracer
-