當前位置: 首頁>>代碼示例>>Java>>正文


Java TestUtils類代碼示例

本文整理匯總了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();
}
 
開發者ID:line,項目名稱:armeria,代碼行數:21,代碼來源:ArmeriaGrpcServerInteropTest.java

示例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);
    }
}
 
開發者ID:line,項目名稱:armeria,代碼行數:18,代碼來源:ArmeriaGrpcServerInteropTest.java

示例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);
  }
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:36,代碼來源:AbstractInteropTest.java


注:本文中的io.grpc.testing.TestUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。