io.grpc.internal.testing.StreamRecorder Java Examples
The following examples show how to use
io.grpc.internal.testing.StreamRecorder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MockUserManagementServiceTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@ParameterizedTest(name = "{0}") @MethodSource("conditionalEntitlementDataProvider") void getAccountTestIncludesConditionalEntitlement(String testCaseName, String conditionFieldName, boolean condition, String entitlementName, boolean entitlementPresentExpected) { ReflectionTestUtils.setField(underTest, "cbLicense", VALID_LICENSE); underTest.initializeWorkloadPasswordPolicy(); ReflectionTestUtils.setField(underTest, conditionFieldName, condition); GetAccountRequest req = GetAccountRequest.getDefaultInstance(); StreamRecorder<GetAccountResponse> observer = StreamRecorder.create(); underTest.getAccount(req, observer); assertThat(observer.getValues().size()).isEqualTo(1); GetAccountResponse res = observer.getValues().get(0); assertThat(res.hasAccount()).isTrue(); Account account = res.getAccount(); List<String> entitlements = account.getEntitlementsList().stream().map(Entitlement::getEntitlementName).collect(Collectors.toList()); if (entitlementPresentExpected) { assertThat(entitlements).contains(entitlementName); } else { assertThat(entitlements).doesNotContain(entitlementName); } }
Example #2
Source File: MockUserManagementServiceTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test void getAccountTestIncludesFixedEntitlements() { ReflectionTestUtils.setField(underTest, "cbLicense", VALID_LICENSE); underTest.initializeWorkloadPasswordPolicy(); GetAccountRequest req = GetAccountRequest.getDefaultInstance(); StreamRecorder<GetAccountResponse> observer = StreamRecorder.create(); underTest.getAccount(req, observer); assertThat(observer.getValues().size()).isEqualTo(1); GetAccountResponse res = observer.getValues().get(0); assertThat(res.hasAccount()).isTrue(); Account account = res.getAccount(); List<String> entitlements = account.getEntitlementsList().stream().map(Entitlement::getEntitlementName).collect(Collectors.toList()); assertThat(entitlements).contains("CDP_AZURE", "CDP_AUTOMATIC_USERSYNC_POLLER", "CLOUDERA_INTERNAL_ACCOUNT", "DATAHUB_AZURE_AUTOSCALING", "DATAHUB_AWS_AUTOSCALING", "LOCAL_DEV"); }
Example #3
Source File: ProtoReflectionServiceTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@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); }
Example #4
Source File: AbstractInteropTest.java From grpc-java with Apache License 2.0 | 6 votes |
@Test public void cancelAfterFirstResponse() throws Exception { final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder() .addResponseParameters(ResponseParameters.newBuilder() .setSize(31415)) .setPayload(Payload.newBuilder() .setBody(ByteString.copyFrom(new byte[27182]))) .build(); final StreamingOutputCallResponse goldenResponse = StreamingOutputCallResponse.newBuilder() .setPayload(Payload.newBuilder() .setBody(ByteString.copyFrom(new byte[31415]))) .build(); StreamRecorder<StreamingOutputCallResponse> responseObserver = StreamRecorder.create(); StreamObserver<StreamingOutputCallRequest> requestObserver = asyncStub.fullDuplexCall(responseObserver); requestObserver.onNext(request); assertResponse(goldenResponse, responseObserver.firstValue().get()); requestObserver.onError(new RuntimeException()); responseObserver.awaitCompletion(operationTimeoutMillis(), TimeUnit.MILLISECONDS); assertEquals(1, responseObserver.getValues().size()); assertEquals(Status.Code.CANCELLED, Status.fromThrowable(responseObserver.getError()).getCode()); assertStatsTrace("grpc.testing.TestService/FullDuplexCall", Status.Code.CANCELLED); }
Example #5
Source File: CoreServiceAuthTest.java From feast with Apache License 2.0 | 6 votes |
@Test void cantApplyFeatureSetIfNotProjectMember() throws InvalidProtocolBufferException { String project = "project1"; Authentication auth = mock(Authentication.class); SecurityContext context = mock(SecurityContext.class); SecurityContextHolder.setContext(context); when(context.getAuthentication()).thenReturn(auth); doReturn(AuthorizationResult.failed(null)) .when(authProvider) .checkAccess(anyString(), any(Authentication.class)); StreamRecorder<ApplyFeatureSetResponse> responseObserver = StreamRecorder.create(); FeatureSetProto.FeatureSet incomingFeatureSet = newDummyFeatureSet("f2", 1, project).toProto(); FeatureSetProto.FeatureSetSpec incomingFeatureSetSpec = incomingFeatureSet.getSpec().toBuilder().build(); FeatureSetProto.FeatureSet spec = FeatureSetProto.FeatureSet.newBuilder().setSpec(incomingFeatureSetSpec).build(); ApplyFeatureSetRequest request = ApplyFeatureSetRequest.newBuilder().setFeatureSet(spec).build(); assertThrows( AccessDeniedException.class, () -> coreService.applyFeatureSet(request, responseObserver)); }
Example #6
Source File: CoreServiceAuthTest.java From feast with Apache License 2.0 | 6 votes |
@Test void canApplyFeatureSetIfProjectMember() throws InvalidProtocolBufferException { String project = "project1"; Authentication auth = mock(Authentication.class); SecurityContext context = mock(SecurityContext.class); SecurityContextHolder.setContext(context); when(context.getAuthentication()).thenReturn(auth); doReturn(AuthorizationResult.success()) .when(authProvider) .checkAccess(anyString(), any(Authentication.class)); StreamRecorder<ApplyFeatureSetResponse> responseObserver = StreamRecorder.create(); FeatureSetProto.FeatureSet incomingFeatureSet = newDummyFeatureSet("f2", 1, project).toProto(); FeatureSetProto.FeatureSetSpec incomingFeatureSetSpec = incomingFeatureSet.getSpec().toBuilder().build(); FeatureSetProto.FeatureSet spec = FeatureSetProto.FeatureSet.newBuilder().setSpec(incomingFeatureSetSpec).build(); ApplyFeatureSetRequest request = ApplyFeatureSetRequest.newBuilder().setFeatureSet(spec).build(); coreService.applyFeatureSet(request, responseObserver); }
Example #7
Source File: ProtoReflectionServiceTest.java From grpc-java with Apache License 2.0 | 6 votes |
@Test public void allExtensionNumbersOfType() throws Exception { ServerReflectionRequest request = ServerReflectionRequest.newBuilder() .setHost(TEST_HOST) .setAllExtensionNumbersOfType("grpc.reflection.testing.ThirdLevelType") .build(); Set<Integer> goldenResponse = new HashSet<>(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<>( responseObserver .firstValue() .get() .getAllExtensionNumbersResponse() .getExtensionNumberList()); assertEquals(goldenResponse, extensionNumberResponseSet); }
Example #8
Source File: ProtoReflectionServiceTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@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()); }
Example #9
Source File: Http2OkHttpTest.java From grpc-java with Apache License 2.0 | 6 votes |
@Test public void receivedDataForFinishedStream() throws Exception { Messages.ResponseParameters.Builder responseParameters = Messages.ResponseParameters.newBuilder() .setSize(1); Messages.StreamingOutputCallRequest.Builder requestBuilder = Messages.StreamingOutputCallRequest.newBuilder(); for (int i = 0; i < 1000; i++) { requestBuilder.addResponseParameters(responseParameters); } StreamRecorder<Messages.StreamingOutputCallResponse> recorder = StreamRecorder.create(); StreamObserver<Messages.StreamingOutputCallRequest> requestStream = asyncStub.fullDuplexCall(recorder); Messages.StreamingOutputCallRequest request = requestBuilder.build(); requestStream.onNext(request); recorder.firstValue().get(); requestStream.onError(new Exception("failed")); recorder.awaitCompletion(); assertEquals(EMPTY, blockingStub.emptyCall(EMPTY)); }
Example #10
Source File: AbstractBrokenServerClientTest.java From grpc-spring-boot-starter with MIT License | 6 votes |
/** * Test successful call with broken setup. */ @Test @DirtiesContext public void testSuccessfulCallWithBrokenSetup() { log.info("--- Starting tests with successful call with broken setup ---"); assertThrowsStatus(UNAVAILABLE, () -> TestServiceGrpc.newBlockingStub(this.channel).normal(Empty.getDefaultInstance())); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.testServiceStub.normal(Empty.getDefaultInstance(), streamRecorder); assertFutureThrowsStatus(UNAVAILABLE, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNAVAILABLE, () -> this.testServiceBlockingStub.normal(Empty.getDefaultInstance())); assertFutureThrowsStatus(UNAVAILABLE, this.testServiceFutureStub.normal(Empty.getDefaultInstance()), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }
Example #11
Source File: AbstractSimpleServerClientTest.java From grpc-spring-boot-starter with MIT License | 6 votes |
/** * Test failing call. */ @Test @DirtiesContext public void testFailingCall() { log.info("--- Starting tests with failing call ---"); assertThrowsStatus(UNIMPLEMENTED, () -> TestServiceGrpc.newBlockingStub(this.channel).unimplemented(Empty.getDefaultInstance())); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.testServiceStub.unimplemented(Empty.getDefaultInstance(), streamRecorder); assertFutureThrowsStatus(UNIMPLEMENTED, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNIMPLEMENTED, () -> this.testServiceBlockingStub.unimplemented(Empty.getDefaultInstance())); assertFutureThrowsStatus(UNIMPLEMENTED, this.testServiceFutureStub.unimplemented(Empty.getDefaultInstance()), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }
Example #12
Source File: MockUserManagementServiceTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void testGetAccountIncludesPasswordPolicy() throws IOException { Path licenseFilePath = Files.createTempFile("license", "txt"); Files.writeString(licenseFilePath, VALID_LICENSE); ReflectionTestUtils.setField(underTest, "cmLicenseFilePath", licenseFilePath.toString()); try { underTest.init(); GetAccountRequest req = GetAccountRequest.getDefaultInstance(); StreamRecorder<GetAccountResponse> observer = StreamRecorder.create(); underTest.getAccount(req, observer); assertThat(observer.getValues().size()).isEqualTo(1); GetAccountResponse res = observer.getValues().get(0); assertThat(res.hasAccount()).isTrue(); Account account = res.getAccount(); assertThat(account.hasPasswordPolicy()).isTrue(); WorkloadPasswordPolicy passwordPolicy = account.getPasswordPolicy(); assertThat(passwordPolicy.getWorkloadPasswordMaxLifetime()).isEqualTo(MockUserManagementService.PASSWORD_LIFETIME); } finally { Files.delete(licenseFilePath); } }
Example #13
Source File: AbstractInteropTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test public void cancelAfterFirstResponse() throws Exception { final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder() .addResponseParameters(ResponseParameters.newBuilder() .setSize(31415)) .setPayload(Payload.newBuilder() .setBody(ByteString.copyFrom(new byte[27182]))) .build(); final StreamingOutputCallResponse goldenResponse = StreamingOutputCallResponse.newBuilder() .setPayload(Payload.newBuilder() .setBody(ByteString.copyFrom(new byte[31415]))) .build(); StreamRecorder<StreamingOutputCallResponse> responseObserver = StreamRecorder.create(); StreamObserver<StreamingOutputCallRequest> requestObserver = asyncStub.fullDuplexCall(responseObserver); requestObserver.onNext(request); assertResponse(goldenResponse, responseObserver.firstValue().get()); requestObserver.onError(new RuntimeException()); responseObserver.awaitCompletion(operationTimeoutMillis(), TimeUnit.MILLISECONDS); assertEquals(1, responseObserver.getValues().size()); assertEquals(Status.Code.CANCELLED, Status.fromThrowable(responseObserver.getError()).getCode()); assertStatsTrace("grpc.testing.TestService/FullDuplexCall", Status.Code.CANCELLED); }
Example #14
Source File: AbstractInteropTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test public void cancelAfterBegin() throws Exception { StreamRecorder<StreamingInputCallResponse> responseObserver = StreamRecorder.create(); StreamObserver<StreamingInputCallRequest> requestObserver = asyncStub.streamingInputCall(responseObserver); requestObserver.onError(new RuntimeException()); responseObserver.awaitCompletion(); assertEquals(Arrays.<StreamingInputCallResponse>asList(), responseObserver.getValues()); assertEquals(Status.Code.CANCELLED, Status.fromThrowable(responseObserver.getError()).getCode()); if (metricsExpected()) { MetricsRecord clientStartRecord = clientStatsRecorder.pollRecord(5, TimeUnit.SECONDS); checkStartTags(clientStartRecord, "grpc.testing.TestService/StreamingInputCall"); // CensusStreamTracerModule record final status in the interceptor, thus is guaranteed to be // recorded. The tracer stats rely on the stream being created, which is not always the case // in this test. Therefore we don't check the tracer stats. MetricsRecord clientEndRecord = clientStatsRecorder.pollRecord(5, TimeUnit.SECONDS); checkEndTags( clientEndRecord, "grpc.testing.TestService/StreamingInputCall", Status.CANCELLED.getCode()); // Do not check server-side metrics, because the status on the server side is undetermined. } }
Example #15
Source File: AbstractSimpleServerClientTest.java From grpc-spring-boot-starter with MIT License | 6 votes |
/** * Test failing call. */ @Test @DirtiesContext public void testFailingCall() { log.info("--- Starting tests with failing call ---"); assertThrowsStatus(UNIMPLEMENTED, () -> TestServiceGrpc.newBlockingStub(this.channel).unimplemented(Empty.getDefaultInstance())); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.testServiceStub.unimplemented(Empty.getDefaultInstance(), streamRecorder); assertFutureThrowsStatus(UNIMPLEMENTED, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNIMPLEMENTED, () -> this.testServiceBlockingStub.unimplemented(Empty.getDefaultInstance())); assertFutureThrowsStatus(UNIMPLEMENTED, this.testServiceFutureStub.unimplemented(Empty.getDefaultInstance()), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }
Example #16
Source File: AbstractBrokenServerClientTest.java From grpc-spring-boot-starter with MIT License | 6 votes |
/** * Test failing call with broken setup. */ @Test @DirtiesContext public void testFailingCallWithBrokenSetup() { log.info("--- Starting tests with failing call with broken setup ---"); assertThrowsStatus(UNAVAILABLE, () -> TestServiceGrpc.newBlockingStub(this.channel).unimplemented(Empty.getDefaultInstance())); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.testServiceStub.unimplemented(Empty.getDefaultInstance(), streamRecorder); assertFutureThrowsStatus(UNAVAILABLE, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNAVAILABLE, () -> this.testServiceBlockingStub.unimplemented(Empty.getDefaultInstance())); assertFutureThrowsStatus(UNAVAILABLE, this.testServiceFutureStub.unimplemented(Empty.getDefaultInstance()), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }
Example #17
Source File: InterAndInProcessSetup2Test.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Test successful call for in-process server. * * @throws ExecutionException Should never happen. * @throws InterruptedException Should never happen. */ @Test @DirtiesContext public void testSuccessfulInProcessCall() throws InterruptedException, ExecutionException { log.info("--- Starting tests with successful in-process call ---"); assertEquals("1.2.3", newBlockingStub(this.inProcessChannel).normal(EMPTY).getVersion()); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.inProcessServiceStub.normal(EMPTY, streamRecorder); assertEquals("1.2.3", streamRecorder.firstValue().get().getVersion()); assertEquals("1.2.3", this.inProcessServiceBlockingStub.normal(EMPTY).getVersion()); assertEquals("1.2.3", this.inProcessServiceFutureStub.normal(EMPTY).get().getVersion()); log.info("--- Test completed ---"); }
Example #18
Source File: ProtoReflectionServiceTest.java From grpc-java with Apache License 2.0 | 5 votes |
@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()); }
Example #19
Source File: AbstractInteropTest.java From grpc-java with Apache License 2.0 | 5 votes |
/** Start a fullDuplexCall which the server will not respond, and verify the deadline expires. */ @SuppressWarnings("MissingFail") @Test public void timeoutOnSleepingServer() throws Exception { TestServiceGrpc.TestServiceStub stub = asyncStub.withDeadlineAfter(1, TimeUnit.MILLISECONDS); StreamRecorder<StreamingOutputCallResponse> responseObserver = StreamRecorder.create(); StreamObserver<StreamingOutputCallRequest> requestObserver = stub.fullDuplexCall(responseObserver); StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder() .setPayload(Payload.newBuilder() .setBody(ByteString.copyFrom(new byte[27182]))) .build(); try { requestObserver.onNext(request); } catch (IllegalStateException expected) { // This can happen if the stream has already been terminated due to deadline exceeded. } assertTrue(responseObserver.awaitCompletion(operationTimeoutMillis(), TimeUnit.MILLISECONDS)); assertEquals(0, responseObserver.getValues().size()); assertEquals(Status.DEADLINE_EXCEEDED.getCode(), Status.fromThrowable(responseObserver.getError()).getCode()); if (metricsExpected()) { // CensusStreamTracerModule record final status in the interceptor, thus is guaranteed to be // recorded. The tracer stats rely on the stream being created, which is not always the case // in this test, thus we will not check that. MetricsRecord clientStartRecord = clientStatsRecorder.pollRecord(5, TimeUnit.SECONDS); checkStartTags(clientStartRecord, "grpc.testing.TestService/FullDuplexCall", true); MetricsRecord clientEndRecord = clientStatsRecorder.pollRecord(5, TimeUnit.SECONDS); checkEndTags( clientEndRecord, "grpc.testing.TestService/FullDuplexCall", Status.DEADLINE_EXCEEDED.getCode(), true); } }
Example #20
Source File: ProtoReflectionServiceTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void fileContainingNestedExtension() throws Exception { ServerReflectionRequest request = ServerReflectionRequest.newBuilder() .setHost(TEST_HOST) .setFileContainingExtension( ExtensionRequest.newBuilder() .setContainingType("grpc.reflection.testing.ThirdLevelType") .setExtensionNumber(101) .build()) .build(); ServerReflectionResponse goldenResponse = ServerReflectionResponse.newBuilder() .setValidHost(TEST_HOST) .setOriginalRequest(request) .setFileDescriptorResponse( FileDescriptorResponse.newBuilder() .addFileDescriptorProto( ReflectionTestDepthTwoProto.getDescriptor().toProto().toByteString()) .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()); }
Example #21
Source File: InterAndInProcessSetupTest.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Test successful call for inter-process server. * * @throws ExecutionException Should never happen. * @throws InterruptedException Should never happen. */ @Test @DirtiesContext public void testSuccessfulInterProcessCall() throws InterruptedException, ExecutionException { log.info("--- Starting tests with successful inter-process call ---"); assertEquals("1.2.3", newBlockingStub(this.interProcessChannel).normal(EMPTY).getVersion()); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.interProcessServiceStub.normal(EMPTY, streamRecorder); assertEquals("1.2.3", streamRecorder.firstValue().get().getVersion()); assertEquals("1.2.3", this.interProcessServiceBlockingStub.normal(EMPTY).getVersion()); assertEquals("1.2.3", this.interProcessServiceFutureStub.normal(EMPTY).get().getVersion()); log.info("--- Test completed ---"); }
Example #22
Source File: InterAndInProcessSetup2Test.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Test failing call for in-process server. */ @Test @DirtiesContext public void testFailingInProcessCall() { log.info("--- Starting tests with failing in-process call ---"); assertThrowsStatus(UNIMPLEMENTED, () -> newBlockingStub(this.inProcessChannel).unimplemented(EMPTY)); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.inProcessServiceStub.unimplemented(EMPTY, streamRecorder); assertFutureThrowsStatus(UNIMPLEMENTED, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNIMPLEMENTED, () -> this.inProcessServiceBlockingStub.unimplemented(EMPTY)); assertFutureThrowsStatus(UNIMPLEMENTED, this.inProcessServiceFutureStub.unimplemented(EMPTY), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }
Example #23
Source File: InterAndInProcessSetupTest.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Test failing call for inter-process server. */ @Test @DirtiesContext public void testFailingInterProcessCall() { log.info("--- Starting tests with failing inter-process call ---"); assertThrowsStatus(UNIMPLEMENTED, () -> newBlockingStub(this.interProcessChannel).unimplemented(EMPTY)); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.interProcessServiceStub.unimplemented(EMPTY, streamRecorder); assertFutureThrowsStatus(UNIMPLEMENTED, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNIMPLEMENTED, () -> this.interProcessServiceBlockingStub.unimplemented(EMPTY)); assertFutureThrowsStatus(UNIMPLEMENTED, this.interProcessServiceFutureStub.unimplemented(EMPTY), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }
Example #24
Source File: InterAndInProcessSetup2Test.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Test failing call for inter-process server. */ @Test @DirtiesContext public void testFailingInterProcessCall() { log.info("--- Starting tests with failing inter-process call ---"); assertThrowsStatus(UNIMPLEMENTED, () -> newBlockingStub(this.interProcessChannel).unimplemented(EMPTY)); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.interProcessServiceStub.unimplemented(EMPTY, streamRecorder); assertFutureThrowsStatus(UNIMPLEMENTED, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNIMPLEMENTED, () -> this.interProcessServiceBlockingStub.unimplemented(EMPTY)); assertFutureThrowsStatus(UNIMPLEMENTED, this.interProcessServiceFutureStub.unimplemented(EMPTY), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }
Example #25
Source File: AbstractSimpleServerClientTest.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Test successful call. * * @throws ExecutionException Should never happen. * @throws InterruptedException Should never happen. */ @Test @DirtiesContext public void testSuccessfulCall() throws InterruptedException, ExecutionException { log.info("--- Starting tests with successful call ---"); assertEquals("1.2.3", TestServiceGrpc.newBlockingStub(this.channel).normal(Empty.getDefaultInstance()).getVersion()); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.testServiceStub.normal(Empty.getDefaultInstance(), streamRecorder); assertEquals("1.2.3", streamRecorder.firstValue().get().getVersion()); assertEquals("1.2.3", this.testServiceBlockingStub.normal(Empty.getDefaultInstance()).getVersion()); assertEquals("1.2.3", this.testServiceFutureStub.normal(Empty.getDefaultInstance()).get().getVersion()); log.info("--- Test completed ---"); }
Example #26
Source File: AbstractInteropTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void emptyStream() throws Exception { StreamRecorder<StreamingOutputCallResponse> responseObserver = StreamRecorder.create(); StreamObserver<StreamingOutputCallRequest> requestObserver = asyncStub.fullDuplexCall(responseObserver); requestObserver.onCompleted(); responseObserver.awaitCompletion(operationTimeoutMillis(), TimeUnit.MILLISECONDS); assertSuccess(responseObserver); assertTrue("Expected an empty stream", responseObserver.getValues().isEmpty()); }
Example #27
Source File: InterAndInProcessSetupTest.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Test successful call for inter-process server. * * @throws ExecutionException Should never happen. * @throws InterruptedException Should never happen. */ @Test @DirtiesContext public void testSuccessfulInterProcessCall() throws InterruptedException, ExecutionException { log.info("--- Starting tests with successful inter-process call ---"); assertEquals("1.2.3", newBlockingStub(this.interProcessChannel).normal(EMPTY).getVersion()); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.interProcessServiceStub.normal(EMPTY, streamRecorder); assertEquals("1.2.3", streamRecorder.firstValue().get().getVersion()); assertEquals("1.2.3", this.interProcessServiceBlockingStub.normal(EMPTY).getVersion()); assertEquals("1.2.3", this.interProcessServiceFutureStub.normal(EMPTY).get().getVersion()); log.info("--- Test completed ---"); }
Example #28
Source File: InterAndInProcessSetupTest.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Test successful call for in-process server. * * @throws ExecutionException Should never happen. * @throws InterruptedException Should never happen. */ @Test @DirtiesContext public void testSuccessfulInProcessCall() throws InterruptedException, ExecutionException { log.info("--- Starting tests with successful in-process call ---"); assertEquals("1.2.3", newBlockingStub(this.inProcessChannel).normal(EMPTY).getVersion()); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.inProcessServiceStub.normal(EMPTY, streamRecorder); assertEquals("1.2.3", streamRecorder.firstValue().get().getVersion()); assertEquals("1.2.3", this.inProcessServiceBlockingStub.normal(EMPTY).getVersion()); assertEquals("1.2.3", this.inProcessServiceFutureStub.normal(EMPTY).get().getVersion()); log.info("--- Test completed ---"); }
Example #29
Source File: InterAndInProcessSetupTest.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Test failing call for inter-process server. */ @Test @DirtiesContext public void testFailingInterProcessCall() { log.info("--- Starting tests with failing inter-process call ---"); assertThrowsStatus(UNIMPLEMENTED, () -> newBlockingStub(this.interProcessChannel).unimplemented(EMPTY)); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.interProcessServiceStub.unimplemented(EMPTY, streamRecorder); assertFutureThrowsStatus(UNIMPLEMENTED, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNIMPLEMENTED, () -> this.interProcessServiceBlockingStub.unimplemented(EMPTY)); assertFutureThrowsStatus(UNIMPLEMENTED, this.interProcessServiceFutureStub.unimplemented(EMPTY), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }
Example #30
Source File: InterAndInProcessSetupTest.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Test failing call for in-process server. */ @Test @DirtiesContext public void testFailingInProcessCall() { log.info("--- Starting tests with failing in-process call ---"); assertThrowsStatus(UNIMPLEMENTED, () -> newBlockingStub(this.inProcessChannel).unimplemented(EMPTY)); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.inProcessServiceStub.unimplemented(EMPTY, streamRecorder); assertFutureThrowsStatus(UNIMPLEMENTED, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNIMPLEMENTED, () -> this.inProcessServiceBlockingStub.unimplemented(EMPTY)); assertFutureThrowsStatus(UNIMPLEMENTED, this.inProcessServiceFutureStub.unimplemented(EMPTY), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }