Spring / Spring gRPC Interview Questions
How would you test streaming gRPC endpoints in a Spring Boot integration test?
The standard approach uses io.grpc:grpc-testing's GrpcCleanupRule (JUnit 4) or the equivalent extension (JUnit 5), together with InProcessServerBuilder/InProcessChannelBuilder to run a real server and stub pair without opening actual network sockets.
To assert on a streamed response, you implement a test StreamObserver that appends each received item to a thread-safe list or blocking queue, and counts down a CountDownLatch in onCompleted() (or captures the error in onError()). The test then calls latch.await(timeout, unit) with a bounded timeout before asserting on the collected sequence, so a hung stream fails the test loudly instead of blocking indefinitely.
More Related questions...