use of io.grpc.reflection.v1alpha.ServerReflectionRequest in project grpc-java by grpc.
the class ProtoReflectionServiceTest method fileContainingSymbolForMutableServices.
@Test
public void fileContainingSymbolForMutableServices() throws Exception {
ServerReflectionRequest request = ServerReflectionRequest.newBuilder().setHost(TEST_HOST).setFileContainingSymbol("grpc.reflection.testing.DynamicRequest").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());
}
use of io.grpc.reflection.v1alpha.ServerReflectionRequest in project grpc-java by grpc.
the class ProtoReflectionServiceTest method fileByFilename.
@Test
public void fileByFilename() throws Exception {
ServerReflectionRequest request = ServerReflectionRequest.newBuilder().setHost(TEST_HOST).setFileByFilename("io/grpc/reflection/testing/reflection_test_depth_three.proto").build();
ServerReflectionResponse goldenResponse = ServerReflectionResponse.newBuilder().setValidHost(TEST_HOST).setOriginalRequest(request).setFileDescriptorResponse(FileDescriptorResponse.newBuilder().addFileDescriptorProto(ReflectionTestDepthThreeProto.getDescriptor().toProto().toByteString()).build()).build();
StreamRecorder<ServerReflectionResponse> responseObserver = StreamRecorder.create();
StreamObserver<ServerReflectionRequest> requestObserver = stub.serverReflectionInfo(responseObserver);
requestObserver.onNext(request);
requestObserver.onCompleted();
assertEquals(goldenResponse, responseObserver.firstValue().get());
}
use of io.grpc.reflection.v1alpha.ServerReflectionRequest in project grpc-java by grpc.
the class ProtoReflectionServiceTest method assertServiceResponseEquals.
private void assertServiceResponseEquals(Set<ServiceResponse> goldenResponse) throws Exception {
ServerReflectionRequest request = ServerReflectionRequest.newBuilder().setHost(TEST_HOST).setListServices("services").build();
StreamRecorder<ServerReflectionResponse> responseObserver = StreamRecorder.create();
StreamObserver<ServerReflectionRequest> requestObserver = stub.serverReflectionInfo(responseObserver);
requestObserver.onNext(request);
requestObserver.onCompleted();
List<ServiceResponse> response = responseObserver.firstValue().get().getListServicesResponse().getServiceList();
assertEquals(goldenResponse.size(), response.size());
assertEquals(goldenResponse, new HashSet<ServiceResponse>(response));
}
use of io.grpc.reflection.v1alpha.ServerReflectionRequest in project grpc-java by grpc.
the class ProtoReflectionServiceTest method fileContainingNestedSymbol.
@Test
public void fileContainingNestedSymbol() throws Exception {
ServerReflectionRequest request = ServerReflectionRequest.newBuilder().setHost(TEST_HOST).setFileContainingSymbol("grpc.reflection.testing.NestedTypeOuter.Middle.Inner").build();
ServerReflectionResponse goldenResponse = ServerReflectionResponse.newBuilder().setValidHost(TEST_HOST).setOriginalRequest(request).setFileDescriptorResponse(FileDescriptorResponse.newBuilder().addFileDescriptorProto(ReflectionTestDepthThreeProto.getDescriptor().toProto().toByteString()).build()).build();
StreamRecorder<ServerReflectionResponse> responseObserver = StreamRecorder.create();
StreamObserver<ServerReflectionRequest> requestObserver = stub.serverReflectionInfo(responseObserver);
requestObserver.onNext(request);
requestObserver.onCompleted();
assertEquals(goldenResponse, responseObserver.firstValue().get());
}
use of io.grpc.reflection.v1alpha.ServerReflectionRequest in project grpc-java by grpc.
the class ProtoReflectionServiceTest method allExtensionNumbersOfType.
@Test
public void allExtensionNumbersOfType() throws Exception {
ServerReflectionRequest request = ServerReflectionRequest.newBuilder().setHost(TEST_HOST).setAllExtensionNumbersOfType("grpc.reflection.testing.ThirdLevelType").build();
Set<Integer> goldenResponse = new HashSet<Integer>(Arrays.asList(100, 101));
StreamRecorder<ServerReflectionResponse> responseObserver = StreamRecorder.create();
StreamObserver<ServerReflectionRequest> requestObserver = stub.serverReflectionInfo(responseObserver);
requestObserver.onNext(request);
requestObserver.onCompleted();
Set<Integer> extensionNumberResponseSet = new HashSet<Integer>(responseObserver.firstValue().get().getAllExtensionNumbersResponse().getExtensionNumberList());
assertEquals(goldenResponse, extensionNumberResponseSet);
}
Aggregations