Class TestClientStreamTracer

  • All Implemented Interfaces:
    TestStreamTracer

    public class TestClientStreamTracer
    extends io.grpc.ClientStreamTracer
    implements 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
    • 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 if ClientStreamTracer.inboundHeaders() has been called.
      io.grpc.Metadata getInboundTrailers()
      Returns the inbound trailers if ClientStreamTracer.inboundTrailers(io.grpc.Metadata) has been called, or null.
      long getInboundUncompressedSize()
      Returns to sum of all sizes passed to StreamTracer.inboundUncompressedSize(long).
      long getInboundWireSize()
      Returns to sum of all sizes passed to StreamTracer.inboundWireSize(long).
      boolean getOutboundHeaders()
      Returns if ClientStreamTracer.outboundHeaders() has been called.
      long getOutboundUncompressedSize()
      Returns to sum of al sizes passed to StreamTracer.outboundUncompressedSize(long).
      long getOutboundWireSize()
      Returns to sum of all sizes passed to StreamTracer.outboundWireSize(long).
      io.grpc.Status getStatus()
      Returns the status passed to StreamTracer.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)  
      • Methods inherited from class io.grpc.ClientStreamTracer

        addOptionalLabel, createPendingStream, inboundHeaders, streamCreated
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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
    • Constructor Detail

      • TestClientStreamTracer

        public TestClientStreamTracer()
    • 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 interface TestStreamTracer
        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 interface TestStreamTracer
        Throws:
        java.lang.InterruptedException
      • getInboundHeaders

        public boolean getInboundHeaders()
        Returns if ClientStreamTracer.inboundHeaders() has been called.
      • getInboundTrailers

        @Nullable
        public io.grpc.Metadata getInboundTrailers()
        Returns the inbound trailers if ClientStreamTracer.inboundTrailers(io.grpc.Metadata) has been called, or null.
      • getOutboundHeaders

        public boolean getOutboundHeaders()
        Returns if ClientStreamTracer.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 to StreamTracer.streamClosed(io.grpc.Status).
        Specified by:
        getStatus in interface TestStreamTracer
      • outboundWireSize

        public void outboundWireSize​(long bytes)
        Overrides:
        outboundWireSize in class io.grpc.StreamTracer
      • inboundWireSize

        public void inboundWireSize​(long bytes)
        Overrides:
        inboundWireSize in class io.grpc.StreamTracer
      • outboundUncompressedSize

        public void outboundUncompressedSize​(long bytes)
        Overrides:
        outboundUncompressedSize in class io.grpc.StreamTracer
      • inboundUncompressedSize

        public void inboundUncompressedSize​(long bytes)
        Overrides:
        inboundUncompressedSize in class io.grpc.StreamTracer
      • streamClosed

        public void streamClosed​(io.grpc.Status status)
        Overrides:
        streamClosed in class io.grpc.StreamTracer
      • inboundMessage

        public void inboundMessage​(int seqNo)
        Overrides:
        inboundMessage in class io.grpc.StreamTracer
      • outboundMessage

        public void outboundMessage​(int seqNo)
        Overrides:
        outboundMessage in class io.grpc.StreamTracer
      • outboundMessageSent

        public void outboundMessageSent​(int seqNo,
                                        long optionalWireSize,
                                        long optionalUncompressedSize)
        Overrides:
        outboundMessageSent in class io.grpc.StreamTracer
      • inboundMessageRead

        public void inboundMessageRead​(int seqNo,
                                       long optionalWireSize,
                                       long optionalUncompressedSize)
        Overrides:
        inboundMessageRead in class io.grpc.StreamTracer
      • outboundHeaders

        public void outboundHeaders()
        Overrides:
        outboundHeaders in class io.grpc.ClientStreamTracer
      • inboundHeaders

        public void inboundHeaders()
        Overrides:
        inboundHeaders in class io.grpc.ClientStreamTracer
      • inboundTrailers

        public void inboundTrailers​(io.grpc.Metadata trailers)
        Overrides:
        inboundTrailers in class io.grpc.ClientStreamTracer