本文整理汇总了Java中io.grpc.testing.TestUtils类的典型用法代码示例。如果您正苦于以下问题:Java TestUtils类的具体用法?Java TestUtils怎么用?Java TestUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestUtils类属于io.grpc.testing包,在下文中一共展示了TestUtils类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startServer
import io.grpc.testing.TestUtils; //导入依赖的package包/类
/** Starts the server with HTTPS. */
@BeforeClass
public static void startServer() throws Exception {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
ssc = new SelfSignedCertificate("example.com");
ServerBuilder sb = new ServerBuilder()
.port(0, SessionProtocol.HTTPS)
.defaultMaxRequestLength(16 * 1024 * 1024)
.sslContext(GrpcSslContexts.forServer(ssc.certificate(), ssc.privateKey())
.applicationProtocolConfig(ALPN)
.trustManager(TestUtils.loadCert("ca.pem"))
.build());
final ArmeriaGrpcServerBuilder builder = new ArmeriaGrpcServerBuilder(sb, new GrpcServiceBuilder(),
ctxCapture);
startStaticServer(builder);
server = builder.builtServer();
}
示例2: createChannel
import io.grpc.testing.TestUtils; //导入依赖的package包/类
@Override
protected ManagedChannel createChannel() {
try {
final int port = server.getPort();
return OkHttpChannelBuilder
.forAddress("localhost", port)
.negotiationType(NegotiationType.TLS)
.maxInboundMessageSize(16 * 1024 * 1024)
.connectionSpec(ConnectionSpec.MODERN_TLS)
.overrideAuthority("example.com:" + port)
.sslSocketFactory(TestUtils.newSslSocketFactoryForCa(
Platform.get().getProvider(), ssc.certificate()))
.build();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
示例3: startServer
import io.grpc.testing.TestUtils; //导入依赖的package包/类
private void startServer() {
AbstractServerImplBuilder<?> builder = getServerBuilder();
if (builder == null) {
server = null;
return;
}
testServiceExecutor = Executors.newScheduledThreadPool(2);
List<ServerInterceptor> allInterceptors = ImmutableList.<ServerInterceptor>builder()
.add(recordServerCallInterceptor(serverCallCapture))
.add(TestUtils.recordRequestHeadersInterceptor(requestHeadersCapture))
.add(recordContextInterceptor(contextCapture))
.addAll(TestServiceImpl.interceptors())
.build();
builder
.addService(
ServerInterceptors.intercept(
new TestServiceImpl(testServiceExecutor),
allInterceptors))
.addStreamTracerFactory(serverStreamTracerFactory);
io.grpc.internal.TestingAccessor.setStatsImplementation(
builder,
new CensusStatsModule(
tagger,
tagContextBinarySerializer,
serverStatsRecorder,
GrpcUtil.STOPWATCH_SUPPLIER,
true));
try {
server = builder.build().start();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}