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
AClientStreamTracersuitable 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.TestBaseStreamTracerdelegateprotected java.util.concurrent.atomic.AtomicReference<java.lang.Throwable>inboundHeadersCalledprotected java.util.concurrent.atomic.AtomicReference<io.grpc.Metadata>inboundTrailersprotected java.util.concurrent.atomic.AtomicReference<java.lang.Throwable>outboundHeadersCalledprotected java.util.concurrent.CountDownLatchoutboundHeadersLatch
-
Constructor Summary
Constructors Constructor Description TestClientStreamTracer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawait()Waits for the stream to be done.booleanawait(long timeout, java.util.concurrent.TimeUnit timeUnit)Waits for the stream to be done.booleanawaitOutboundHeaders(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).booleangetInboundHeaders()Returns ifClientStreamTracer.inboundHeaders()has been called.io.grpc.MetadatagetInboundTrailers()Returns the inbound trailers ifClientStreamTracer.inboundTrailers(io.grpc.Metadata)has been called, ornull.longgetInboundUncompressedSize()Returns to sum of all sizes passed toStreamTracer.inboundUncompressedSize(long).longgetInboundWireSize()Returns to sum of all sizes passed toStreamTracer.inboundWireSize(long).booleangetOutboundHeaders()Returns ifClientStreamTracer.outboundHeaders()has been called.longgetOutboundUncompressedSize()Returns to sum of al sizes passed toStreamTracer.outboundUncompressedSize(long).longgetOutboundWireSize()Returns to sum of all sizes passed toStreamTracer.outboundWireSize(long).io.grpc.StatusgetStatus()Returns the status passed toStreamTracer.streamClosed(io.grpc.Status).voidinboundHeaders()voidinboundMessage(int seqNo)voidinboundMessageRead(int seqNo, long optionalWireSize, long optionalUncompressedSize)voidinboundTrailers(io.grpc.Metadata trailers)voidinboundUncompressedSize(long bytes)voidinboundWireSize(long bytes)java.lang.StringnextInboundEvent()Returns the next captured outbound message event.java.lang.StringnextOutboundEvent()Returns the next captured outbound message event.voidoutboundHeaders()voidoutboundMessage(int seqNo)voidoutboundMessageSent(int seqNo, long optionalWireSize, long optionalUncompressedSize)voidoutboundUncompressedSize(long bytes)voidoutboundWireSize(long bytes)voidsetFailDuplicateCallbacks(boolean fail)Sets whether to fail on unexpected duplicate calls to callback methods.voidstreamClosed(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.InterruptedExceptionDescription copied from interface:TestStreamTracerWaits for the stream to be done.- Specified by:
awaitin interfaceTestStreamTracer- Throws:
java.lang.InterruptedException
-
await
public boolean await(long timeout, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedExceptionDescription copied from interface:TestStreamTracerWaits for the stream to be done.- Specified by:
awaitin 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.ExceptionAllow 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:TestStreamTracerReturns the status passed toStreamTracer.streamClosed(io.grpc.Status).- Specified by:
getStatusin interfaceTestStreamTracer
-
getInboundWireSize
public long getInboundWireSize()
Description copied from interface:TestStreamTracerReturns to sum of all sizes passed toStreamTracer.inboundWireSize(long).- Specified by:
getInboundWireSizein interfaceTestStreamTracer
-
getInboundUncompressedSize
public long getInboundUncompressedSize()
Description copied from interface:TestStreamTracerReturns to sum of all sizes passed toStreamTracer.inboundUncompressedSize(long).- Specified by:
getInboundUncompressedSizein interfaceTestStreamTracer
-
getOutboundWireSize
public long getOutboundWireSize()
Description copied from interface:TestStreamTracerReturns to sum of all sizes passed toStreamTracer.outboundWireSize(long).- Specified by:
getOutboundWireSizein interfaceTestStreamTracer
-
getOutboundUncompressedSize
public long getOutboundUncompressedSize()
Description copied from interface:TestStreamTracerReturns to sum of al sizes passed toStreamTracer.outboundUncompressedSize(long).- Specified by:
getOutboundUncompressedSizein interfaceTestStreamTracer
-
setFailDuplicateCallbacks
public void setFailDuplicateCallbacks(boolean fail)
Description copied from interface:TestStreamTracerSets whether to fail on unexpected duplicate calls to callback methods.- Specified by:
setFailDuplicateCallbacksin interfaceTestStreamTracer
-
nextOutboundEvent
public java.lang.String nextOutboundEvent()
Description copied from interface:TestStreamTracerReturns the next captured outbound message event.- Specified by:
nextOutboundEventin interfaceTestStreamTracer
-
nextInboundEvent
public java.lang.String nextInboundEvent()
Description copied from interface:TestStreamTracerReturns the next captured outbound message event.- Specified by:
nextInboundEventin interfaceTestStreamTracer
-
outboundWireSize
public void outboundWireSize(long bytes)
- Overrides:
outboundWireSizein classio.grpc.StreamTracer
-
inboundWireSize
public void inboundWireSize(long bytes)
- Overrides:
inboundWireSizein classio.grpc.StreamTracer
-
outboundUncompressedSize
public void outboundUncompressedSize(long bytes)
- Overrides:
outboundUncompressedSizein classio.grpc.StreamTracer
-
inboundUncompressedSize
public void inboundUncompressedSize(long bytes)
- Overrides:
inboundUncompressedSizein classio.grpc.StreamTracer
-
streamClosed
public void streamClosed(io.grpc.Status status)
- Overrides:
streamClosedin classio.grpc.StreamTracer
-
inboundMessage
public void inboundMessage(int seqNo)
- Overrides:
inboundMessagein classio.grpc.StreamTracer
-
outboundMessage
public void outboundMessage(int seqNo)
- Overrides:
outboundMessagein classio.grpc.StreamTracer
-
outboundMessageSent
public void outboundMessageSent(int seqNo, long optionalWireSize, long optionalUncompressedSize)- Overrides:
outboundMessageSentin classio.grpc.StreamTracer
-
inboundMessageRead
public void inboundMessageRead(int seqNo, long optionalWireSize, long optionalUncompressedSize)- Overrides:
inboundMessageReadin classio.grpc.StreamTracer
-
outboundHeaders
public void outboundHeaders()
- Overrides:
outboundHeadersin classio.grpc.ClientStreamTracer
-
inboundHeaders
public void inboundHeaders()
- Overrides:
inboundHeadersin classio.grpc.ClientStreamTracer
-
inboundTrailers
public void inboundTrailers(io.grpc.Metadata trailers)
- Overrides:
inboundTrailersin classio.grpc.ClientStreamTracer
-
-