Search in sources :

Example 1 with SimpleServiceBlockingStub

use of io.grpc.testing.protobuf.SimpleServiceGrpc.SimpleServiceBlockingStub in project grpc-java by grpc.

the class ShadingTest method basic.

@Test
public void basic() throws Exception {
    server = Grpc.newServerBuilderForPort(0, InsecureServerCredentials.create()).addService(new SimpleServiceImpl()).build().start();
    channel = Grpc.newChannelBuilder("localhost:" + server.getPort(), InsecureChannelCredentials.create()).build();
    SimpleServiceBlockingStub stub = SimpleServiceGrpc.newBlockingStub(channel);
    assertThat(SimpleResponse.getDefaultInstance()).isEqualTo(stub.unaryRpc(SimpleRequest.getDefaultInstance()));
}
Also used : SimpleServiceBlockingStub(io.grpc.testing.protobuf.SimpleServiceGrpc.SimpleServiceBlockingStub) Test(org.junit.Test)

Example 2 with SimpleServiceBlockingStub

use of io.grpc.testing.protobuf.SimpleServiceGrpc.SimpleServiceBlockingStub in project grpc-java by grpc.

the class ShadingTest method tcnative.

@Test
public void tcnative() throws Exception {
    ServerCredentials serverCreds = TlsServerCredentials.create(TestUtils.loadCert("server1.pem"), TestUtils.loadCert("server1.key"));
    server = Grpc.newServerBuilderForPort(0, serverCreds).addService(new SimpleServiceImpl()).build().start();
    ChannelCredentials creds = NettySslContextChannelCredentials.create(GrpcSslContexts.configure(SslContextBuilder.forClient(), SslProvider.OPENSSL).trustManager(TestUtils.loadCert("ca.pem")).build());
    channel = Grpc.newChannelBuilder("localhost:" + server.getPort(), creds).overrideAuthority("foo.test.google.fr").build();
    SimpleServiceBlockingStub stub = SimpleServiceGrpc.newBlockingStub(channel);
    assertThat(SimpleResponse.getDefaultInstance()).isEqualTo(stub.unaryRpc(SimpleRequest.getDefaultInstance()));
}
Also used : TlsServerCredentials(io.grpc.TlsServerCredentials) ServerCredentials(io.grpc.ServerCredentials) InsecureServerCredentials(io.grpc.InsecureServerCredentials) InsecureChannelCredentials(io.grpc.InsecureChannelCredentials) ChannelCredentials(io.grpc.ChannelCredentials) NettySslContextChannelCredentials(io.grpc.netty.shaded.io.grpc.netty.NettySslContextChannelCredentials) SimpleServiceBlockingStub(io.grpc.testing.protobuf.SimpleServiceGrpc.SimpleServiceBlockingStub) Test(org.junit.Test)

Aggregations

SimpleServiceBlockingStub (io.grpc.testing.protobuf.SimpleServiceGrpc.SimpleServiceBlockingStub)2 Test (org.junit.Test)2 ChannelCredentials (io.grpc.ChannelCredentials)1 InsecureChannelCredentials (io.grpc.InsecureChannelCredentials)1 InsecureServerCredentials (io.grpc.InsecureServerCredentials)1 ServerCredentials (io.grpc.ServerCredentials)1 TlsServerCredentials (io.grpc.TlsServerCredentials)1 NettySslContextChannelCredentials (io.grpc.netty.shaded.io.grpc.netty.NettySslContextChannelCredentials)1