Search in sources :

Example 1 with HostnameGreeter

use of io.grpc.examples.hostname.HostnameGreeter in project grpc-java by grpc.

the class HostnameGreeterTest method sayHello_fixedHostname.

@Test
public void sayHello_fixedHostname() throws Exception {
    grpcCleanup.register(InProcessServerBuilder.forName("hostname").directExecutor().addService(new HostnameGreeter("me")).build().start());
    HelloReply reply = blockingStub.sayHello(HelloRequest.newBuilder().setName("you").build());
    assertEquals("Hello you, from me", reply.getMessage());
}
Also used : HostnameGreeter(io.grpc.examples.hostname.HostnameGreeter) HelloReply(io.grpc.examples.helloworld.HelloReply) Test(org.junit.Test)

Example 2 with HostnameGreeter

use of io.grpc.examples.hostname.HostnameGreeter in project grpc-java by grpc.

the class HostnameGreeterTest method sayHello_dynamicHostname.

@Test
public void sayHello_dynamicHostname() throws Exception {
    grpcCleanup.register(InProcessServerBuilder.forName("hostname").directExecutor().addService(new HostnameGreeter(null)).build().start());
    // Just verifing the service doesn't crash
    HelloReply reply = blockingStub.sayHello(HelloRequest.newBuilder().setName("anonymous").build());
    assertTrue(reply.getMessage(), reply.getMessage().startsWith("Hello anonymous, from "));
}
Also used : HostnameGreeter(io.grpc.examples.hostname.HostnameGreeter) HelloReply(io.grpc.examples.helloworld.HelloReply) Test(org.junit.Test)

Aggregations

HelloReply (io.grpc.examples.helloworld.HelloReply)2 HostnameGreeter (io.grpc.examples.hostname.HostnameGreeter)2 Test (org.junit.Test)2