Search in sources :

Example 11 with ServerReflectionResponse

use of io.grpc.reflection.v1alpha.ServerReflectionResponse 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());
}
Also used : ServerReflectionRequest(io.grpc.reflection.v1alpha.ServerReflectionRequest) ServerReflectionResponse(io.grpc.reflection.v1alpha.ServerReflectionResponse) Test(org.junit.Test)

Aggregations

ServerReflectionRequest (io.grpc.reflection.v1alpha.ServerReflectionRequest)11 ServerReflectionResponse (io.grpc.reflection.v1alpha.ServerReflectionResponse)11 Test (org.junit.Test)10 ByteString (com.google.protobuf.ByteString)3 ServiceResponse (io.grpc.reflection.v1alpha.ServiceResponse)1 HashSet (java.util.HashSet)1