use of io.grpc.reflection.v1alpha.ServerReflectionRequest in project grpc-java by grpc.
the class ProtoReflectionServiceTest method fileContainingExtensionForMutableServices.
@Test
public void fileContainingExtensionForMutableServices() throws Exception {
ServerReflectionRequest request = ServerReflectionRequest.newBuilder().setHost(TEST_HOST).setFileContainingExtension(ExtensionRequest.newBuilder().setContainingType("grpc.reflection.testing.TypeWithExtensions").setExtensionNumber(200).build()).build();
ServerReflectionResponse goldenResponse = ServerReflectionResponse.newBuilder().setValidHost(TEST_HOST).setOriginalRequest(request).setFileDescriptorResponse(FileDescriptorResponse.newBuilder().addFileDescriptorProto(DynamicReflectionTestDepthTwoProto.getDescriptor().toProto().toByteString()).build()).build();
StreamRecorder<ServerReflectionResponse> responseObserver = StreamRecorder.create();
StreamObserver<ServerReflectionRequest> requestObserver = stub.serverReflectionInfo(responseObserver);
handlerRegistry.addService(dynamicService);
requestObserver.onNext(request);
requestObserver.onCompleted();
StreamRecorder<ServerReflectionResponse> responseObserver2 = StreamRecorder.create();
StreamObserver<ServerReflectionRequest> requestObserver2 = stub.serverReflectionInfo(responseObserver2);
handlerRegistry.removeService(dynamicService);
requestObserver2.onNext(request);
requestObserver2.onCompleted();
StreamRecorder<ServerReflectionResponse> responseObserver3 = StreamRecorder.create();
StreamObserver<ServerReflectionRequest> requestObserver3 = stub.serverReflectionInfo(responseObserver3);
requestObserver3.onNext(request);
requestObserver3.onCompleted();
assertEquals(ServerReflectionResponse.MessageResponseCase.ERROR_RESPONSE, responseObserver.firstValue().get().getMessageResponseCase());
assertEquals(goldenResponse, responseObserver2.firstValue().get());
assertEquals(ServerReflectionResponse.MessageResponseCase.ERROR_RESPONSE, responseObserver3.firstValue().get().getMessageResponseCase());
}
Aggregations