use of services.TreeMapService in project helidon by oracle.
the class ClientServiceDescriptorTest method shouldAddClientStreamingMethodWithConfigurer.
@Test
public void shouldAddClientStreamingMethodWithConfigurer() {
ClientInterceptor interceptor = mock(ClientInterceptor.class);
ClientServiceDescriptor descriptor = ClientServiceDescriptor.builder(TreeMapService.class).clientStreaming("foo", cfg -> cfg.intercept(interceptor)).build();
ClientMethodDescriptor method = descriptor.method("foo");
assertThat(method, is(notNullValue()));
assertThat(method.interceptors(), contains(interceptor));
MethodDescriptor<Object, Object> methodDescriptor = method.descriptor();
assertThat(methodDescriptor.getType(), is(MethodDescriptor.MethodType.CLIENT_STREAMING));
assertThat(methodDescriptor.getFullMethodName(), is("TreeMapService/foo"));
}
use of services.TreeMapService in project helidon by oracle.
the class ClientServiceDescriptorTest method shouldAddBidirectionalMethodWithConfigurer.
@Test
public void shouldAddBidirectionalMethodWithConfigurer() {
ClientInterceptor interceptor = mock(ClientInterceptor.class);
ClientServiceDescriptor descriptor = ClientServiceDescriptor.builder(TreeMapService.class).bidirectional("foo", cfg -> cfg.intercept(interceptor)).build();
ClientMethodDescriptor method = descriptor.method("foo");
assertThat(method, is(notNullValue()));
assertThat(method.interceptors(), contains(interceptor));
MethodDescriptor<Object, Object> methodDescriptor = method.descriptor();
assertThat(methodDescriptor.getType(), is(MethodDescriptor.MethodType.BIDI_STREAMING));
assertThat(methodDescriptor.getFullMethodName(), is("TreeMapService/foo"));
}
use of services.TreeMapService in project helidon by oracle.
the class ClientServiceDescriptorTest method shouldAddUnaryMethodWithConfigurer.
@Test
public void shouldAddUnaryMethodWithConfigurer() {
ClientInterceptor interceptor = mock(ClientInterceptor.class);
ClientServiceDescriptor descriptor = ClientServiceDescriptor.builder(TreeMapService.class).unary("foo", cfg -> cfg.intercept(interceptor)).build();
ClientMethodDescriptor method = descriptor.method("foo");
assertThat(method, is(notNullValue()));
assertThat(method.interceptors(), contains(interceptor));
MethodDescriptor<Object, Object> methodDescriptor = method.descriptor();
assertThat(methodDescriptor.getType(), is(MethodDescriptor.MethodType.UNARY));
assertThat(methodDescriptor.getFullMethodName(), is("TreeMapService/foo"));
}
use of services.TreeMapService in project helidon by oracle.
the class ClientServiceDescriptorTest method shouldAddServerStreamingMethodWithConfigurer.
@Test
public void shouldAddServerStreamingMethodWithConfigurer() {
ClientInterceptor interceptor = mock(ClientInterceptor.class);
ClientServiceDescriptor descriptor = ClientServiceDescriptor.builder(TreeMapService.class).serverStreaming("foo", cfg -> cfg.intercept(interceptor)).build();
ClientMethodDescriptor method = descriptor.method("foo");
assertThat(method, is(notNullValue()));
assertThat(method.interceptors(), contains(interceptor));
MethodDescriptor<Object, Object> methodDescriptor = method.descriptor();
assertThat(methodDescriptor.getType(), is(MethodDescriptor.MethodType.SERVER_STREAMING));
assertThat(methodDescriptor.getFullMethodName(), is("TreeMapService/foo"));
}
use of services.TreeMapService in project helidon by oracle.
the class GrpcChannelsProviderIT method startGrpcServer.
/**
* Start a gRPC server listening on the specified port and with ssl enabled (if sslEnabled is true).
*
* @param nPort The server port where the server will listen.
* @param sslEnabled true if ssl enabled.
* @param mutual if true then 2 way (mutual) or just one way ssl.
* @return A reference to a {@link io.helidon.grpc.server.GrpcServer}.
*/
private static GrpcServer startGrpcServer(int nPort, boolean sslEnabled, boolean mutual) throws Exception {
Resource tlsCert = Resource.create(SERVER_CERT);
Resource tlsKey = Resource.create(SERVER_KEY);
Resource tlsCaCert = Resource.create(CA_CERT);
GrpcTlsDescriptor sslConfig = null;
String name = "grpc.server";
if (!sslEnabled) {
name = name + 1;
} else if (mutual) {
name = name + 2;
sslConfig = GrpcTlsDescriptor.builder().jdkSSL(false).tlsCert(tlsCert).tlsKey(tlsKey).tlsCaCert(tlsCaCert).build();
} else {
name = name + 3;
sslConfig = GrpcTlsDescriptor.builder().jdkSSL(false).tlsCert(tlsCert).tlsKey(tlsKey).build();
}
// Add the EchoService
GrpcRouting routing = GrpcRouting.builder().register(new TreeMapService()).build();
GrpcServerConfiguration.Builder bldr = GrpcServerConfiguration.builder().name(name).port(nPort);
if (sslEnabled) {
bldr.tlsConfig(sslConfig);
}
return GrpcServer.create(bldr.build(), routing).start().toCompletableFuture().get(10, TimeUnit.SECONDS);
}
Aggregations