use of io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterClient in project servicetalk by apple.
the class GrpcSslAndNonSslConnectionsTest method secureClientToSecureServerWithoutPeerHostSucceeds.
@Test
void secureClientToSecureServerWithoutPeerHostSucceeds() throws Exception {
try (ServerContext serverContext = secureGrpcServer();
BlockingTesterClient client = secureGrpcClient(serverContext, new ClientSslConfigBuilder(DefaultTestCerts::loadServerCAPem).peerHost(null).hostnameVerificationAlgorithm(""), false).buildBlocking(clientFactory())) {
final TesterProto.TestResponse response = client.test(REQUEST);
assertThat(response, is(notNullValue()));
assertThat(response.getMessage(), is(notNullValue()));
}
}
use of io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterClient in project servicetalk by apple.
the class GrpcSslAndNonSslConnectionsTest method nonSecureClientToSecureServerClosesConnection.
@Test
void nonSecureClientToSecureServerClosesConnection() throws Exception {
try (ServerContext serverContext = secureGrpcServer();
BlockingTesterClient client = nonSecureGrpcClient(serverContext)) {
GrpcStatusException e = assertThrows(GrpcStatusException.class, () -> client.test(REQUEST));
assertThat(e.getCause(), instanceOf(StacklessClosedChannelException.class));
}
}
use of io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterClient in project servicetalk by apple.
the class SingleRequestOrResponseApiTest method clientRequestStreamingCallFailsOnInvalidResponse.
private <T extends Throwable> void clientRequestStreamingCallFailsOnInvalidResponse(int numberOfResponses, Class<T> exceptionClass) throws Exception {
// No need to run the test with different server-side
assumeFalse(streamingService);
if (streamingClient) {
try (TesterClient client = newClient()) {
ExecutionException e = assertThrows(ExecutionException.class, () -> client.testRequestStream(from(newRequest(numberOfResponses))).toFuture().get());
assertThat(e.getCause(), is(instanceOf(exceptionClass)));
}
} else {
try (BlockingTesterClient client = newBlockingClient()) {
assertThrows(exceptionClass, () -> client.testRequestStream(singletonList(newRequest(numberOfResponses))));
}
}
}
use of io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterClient in project servicetalk by apple.
the class SingleRequestOrResponseApiTest method serverResponseStreamingRouteFailsWithInvalidArgument.
private void serverResponseStreamingRouteFailsWithInvalidArgument(Iterable<TestRequest> requestItems, String expectedMsg) throws Exception {
// No need to run the test with different client-side, always use blocking client
assumeFalse(streamingClient);
try (BlockingTesterClient client = newBlockingClient()) {
GrpcStatusException e = assertThrows(GrpcStatusException.class, () -> client.testBiDiStream(requestItems).forEach(response -> {
/* noop */
}));
assertThat(e.status().code(), is(INVALID_ARGUMENT));
assertThat(e.status().description(), equalTo(expectedMsg));
}
}
use of io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterClient in project servicetalk by apple.
the class GrpcRouterConfigurationTest method testMissedRouteThrowsUnimplementedException.
@Test
void testMissedRouteThrowsUnimplementedException() throws Exception {
BlockingTesterClient client = createGrpcClient(startGrpcServer(new ServiceFactory.Builder().test(DEFAULT_STRATEGY_ASYNC_SERVICE).build()));
TesterProto.TestResponse response = client.test(REQUEST);
assertThat(response, is(notNullValue()));
assertThat(response.getMessage(), is(notNullValue()));
Throwable t = assertThrows(GrpcStatusException.class, () -> client.testRequestStream(singletonList(REQUEST)));
assertThat(t.getMessage(), equalTo(UNIMPLEMENTED.name()));
}
Aggregations