Search in sources :

Example 6 with ServerReflectionResponse

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

Example 7 with ServerReflectionResponse

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

Example 8 with ServerReflectionResponse

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

Example 9 with ServerReflectionResponse

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

Example 10 with ServerReflectionResponse

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