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
public class TestClientStreamTracer extends io.grpc.ClientStreamTracer implements TestStreamTracer
AClientStreamTracer
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
Fields Modifier and Type Field Description private TestStreamTracer.TestBaseStreamTracer
delegate
protected java.util.concurrent.atomic.AtomicReference<java.lang.Throwable>
inboundHeadersCalled
protected java.util.concurrent.atomic.AtomicReference<io.grpc.Metadata>
inboundTrailers
protected java.util.concurrent.atomic.AtomicReference<java.lang.Throwable>
outboundHeadersCalled
protected java.util.concurrent.CountDownLatch
outboundHeadersLatch
-
Constructor Summary
Constructors Constructor Description TestClientStreamTracer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
await()
Waits for the stream to be done.boolean
await(long timeout, java.util.concurrent.TimeUnit timeUnit)
Waits for the stream to be done.boolean
awaitOutboundHeaders(int timeout, java.util.concurrent.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
getInboundHeaders()
Returns ifClientStreamTracer.inboundHeaders()
has been called.io.grpc.Metadata
getInboundTrailers()
Returns the inbound trailers ifClientStreamTracer.inboundTrailers(io.grpc.Metadata)
has been called, ornull
.long
getInboundUncompressedSize()
Returns to sum of all sizes passed toStreamTracer.inboundUncompressedSize(long)
.long
getInboundWireSize()
Returns to sum of all sizes passed toStreamTracer.inboundWireSize(long)
.boolean
getOutboundHeaders()
Returns ifClientStreamTracer.outboundHeaders()
has been called.long
getOutboundUncompressedSize()
Returns to sum of al sizes passed toStreamTracer.outboundUncompressedSize(long)
.long
getOutboundWireSize()
Returns to sum of all sizes passed toStreamTracer.outboundWireSize(long)
.io.grpc.Status
getStatus()
Returns the status passed toStreamTracer.streamClosed(io.grpc.Status)
.void
inboundHeaders()
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)
java.lang.String
nextInboundEvent()
Returns the next captured outbound message event.java.lang.String
nextOutboundEvent()
Returns the next captured outbound message event.void
outboundHeaders()
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)
-
-
-
Field Detail
-
delegate
private final TestStreamTracer.TestBaseStreamTracer delegate
-
outboundHeadersLatch
protected final java.util.concurrent.CountDownLatch outboundHeadersLatch
-
outboundHeadersCalled
protected final java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> outboundHeadersCalled
-
inboundHeadersCalled
protected final java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> inboundHeadersCalled
-
inboundTrailers
protected final java.util.concurrent.atomic.AtomicReference<io.grpc.Metadata> inboundTrailers
-
-
Method Detail
-
await
public void await() throws java.lang.InterruptedException
Description copied from interface:TestStreamTracer
Waits for the stream to be done.- Specified by:
await
in interfaceTestStreamTracer
- Throws:
java.lang.InterruptedException
-
await
public boolean await(long timeout, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException
Description copied from interface:TestStreamTracer
Waits for the stream to be done.- Specified by:
await
in interfaceTestStreamTracer
- Throws:
java.lang.InterruptedException
-
getInboundHeaders
public boolean getInboundHeaders()
Returns ifClientStreamTracer.inboundHeaders()
has been called.
-
getInboundTrailers
@Nullable public io.grpc.Metadata 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
public boolean awaitOutboundHeaders(int timeout, java.util.concurrent.TimeUnit unit) throws java.lang.Exception
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:
java.lang.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
public java.lang.String nextOutboundEvent()
Description copied from interface:TestStreamTracer
Returns the next captured outbound message event.- Specified by:
nextOutboundEvent
in interfaceTestStreamTracer
-
nextInboundEvent
public java.lang.String 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
-
-