mirror of https://github.com/grpc/grpc-java.git
parent
6e40edbc21
commit
c102dd4e4f
|
|
@ -51,6 +51,7 @@ import org.mockito.ArgumentCaptor;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
|
@ -115,4 +116,23 @@ public class ClientCallsTest {
|
|||
// Exepcted
|
||||
}
|
||||
}
|
||||
|
||||
@Test public void blockingResponseStreamFailed() throws Exception {
|
||||
Integer req = 2;
|
||||
Iterator<String> iter = ClientCalls.blockingServerStreamingCall(call, req);
|
||||
ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
|
||||
verify(call).start(listenerCaptor.capture(), any(Metadata.class));
|
||||
ClientCall.Listener<String> listener = listenerCaptor.getValue();
|
||||
Metadata trailers = new Metadata();
|
||||
listener.onClose(Status.INTERNAL, trailers);
|
||||
try {
|
||||
iter.next();
|
||||
fail("Should fail");
|
||||
} catch (Throwable e) {
|
||||
Status status = Status.fromThrowable(e);
|
||||
assertEquals(Status.INTERNAL, status);
|
||||
Metadata metadata = Status.trailersFromThrowable(e);
|
||||
assertSame(trailers, metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue