public void deadlineExceeded() { // warm up the channel and JVM blockingStub.emptyCall(new EmptyProtos.Empty()); TestServiceGrpc.TestServiceBlockingStub stub = TestServiceGrpc.newBlockingStub(channel).withDeadlineAfter(10, TimeUnit.MILLISECONDS); StreamingOutputCallRequest request = new StreamingOutputCallRequest(); request.responseParameters = new ResponseParameters[1]; request.responseParameters[0] = new ResponseParameters(); request.responseParameters[0].intervalUs = 20000; try { stub.streamingOutputCall(request).next(); fail("Expected deadline to be exceeded"); } catch (StatusRuntimeException ex) { assertCodeEquals(io.grpc.Status.DEADLINE_EXCEEDED, ex.getStatus()); } }
public void deadlineNotExceeded() { // warm up the channel and JVM blockingStub.emptyCall(new EmptyProtos.Empty()); StreamingOutputCallRequest request = new StreamingOutputCallRequest(); request.responseParameters = new ResponseParameters[1]; request.responseParameters[0] = new ResponseParameters(); request.responseParameters[0].intervalUs = 0; TestServiceGrpc.newBlockingStub(channel) .withDeadlineAfter(10, TimeUnit.SECONDS) .streamingOutputCall(request); }
public void veryLargeResponse() throws Exception { final SimpleRequest request = new SimpleRequest(); request.responseSize = unaryPayloadLength(); request.responseType = Messages.COMPRESSABLE; SimpleResponse resp = blockingStub.unaryCall(request); final SimpleResponse goldenResponse = new SimpleResponse(); goldenResponse.payload = new Payload(); goldenResponse.payload.type = Messages.COMPRESSABLE; goldenResponse.payload.body = new byte[unaryPayloadLength()]; assertMessageSizeEquals(goldenResponse, resp); }
public void largeUnary() { final Messages.SimpleRequest request = new Messages.SimpleRequest(); request.responseSize = 314159; request.responseType = Messages.COMPRESSABLE; request.payload = new Payload(); request.payload.body = new byte[271828]; final Messages.SimpleResponse goldenResponse = new Messages.SimpleResponse(); goldenResponse.payload = new Payload(); goldenResponse.payload.body = new byte[314159]; Messages.SimpleResponse response = blockingStub.unaryCall(request); assertMessageEquals(goldenResponse, response); }
public void deadlineExceededServerStreaming() throws Exception { // warm up the channel and JVM blockingStub.emptyCall(new EmptyProtos.Empty()); ResponseParameters responseParameters = new ResponseParameters(); responseParameters.size = 1; responseParameters.intervalUs = 10000; StreamingOutputCallRequest request = new StreamingOutputCallRequest(); request.responseType = Messages.COMPRESSABLE; request.responseParameters = new ResponseParameters[4]; request.responseParameters[0] = responseParameters; request.responseParameters[1] = responseParameters; request.responseParameters[2] = responseParameters; request.responseParameters[3] = responseParameters; StreamRecorder<StreamingOutputCallResponse> recorder = StreamRecorder.create(); TestServiceGrpc.newStub(channel) .withDeadlineAfter(30, TimeUnit.MILLISECONDS) .streamingOutputCall(request, recorder); assertTrue(recorder.awaitCompletion(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)); assertCodeEquals( io.grpc.Status.DEADLINE_EXCEEDED, io.grpc.Status.fromThrowable(recorder.getError())); }
public void emptyUnary() { assertMessageEquals(new EmptyProtos.Empty(), blockingStub.emptyCall(new EmptyProtos.Empty())); }