Java 类io.grpc.inprocess.InProcessChannelBuilder 实例源码

项目:grpc-java-contrib    文件:CompletableFutureStubTest.java   
@Test
public void AbstractStubFeaturesShouldPropagate() throws Exception {
    com.google.common.base.Preconditions.checkArgument(true);
    Channel channel = InProcessChannelBuilder.forName("ignore").build();
    com.salesforce.jprotoc.GreeterGrpc8.GreeterCompletableFutureStub stub = com.salesforce.jprotoc.GreeterGrpc8
                    .newCompletableFutureStub(channel)
                    .withCompression("bz2")
                    .withMaxInboundMessageSize(42);

    Field innerStubField = com.salesforce.jprotoc.GreeterGrpc8.GreeterCompletableFutureStub.class.getDeclaredField("innerStub");
    innerStubField.setAccessible(true);
    com.salesforce.jprotoc.GreeterGrpc.GreeterFutureStub innerStub = (com.salesforce.jprotoc.GreeterGrpc.GreeterFutureStub) innerStubField.get(stub);

    assertEquals("bz2", stub.getCallOptions().getCompressor());
    assertEquals(new Integer(42), stub.getCallOptions().getMaxInboundMessageSize());

    assertEquals("bz2", innerStub.getCallOptions().getCompressor());
    assertEquals(new Integer(42), innerStub.getCallOptions().getMaxInboundMessageSize());

    assertEquals(stub.getCallOptions().toString(), innerStub.getCallOptions().toString());
}
项目:generator-jhipster-grpc    文件:_ProfileInfoServiceIntTest.java   
@Before
public void setUp() throws IOException {
    MockitoAnnotations.initMocks(this);
    String mockProfile[] = {"other", "test"};
    JHipsterProperties.Ribbon ribbon = new JHipsterProperties.Ribbon();
    ribbon.setDisplayOnActiveProfiles(mockProfile);
    when(jHipsterProperties.getRibbon()).thenReturn(ribbon);

    String activeProfiles[] = {"test"};
    when(environment.getDefaultProfiles()).thenReturn(activeProfiles);
    when(environment.getActiveProfiles()).thenReturn(activeProfiles);
    ProfileInfoService service = new ProfileInfoService(jHipsterProperties, environment);
    String uniqueServerName = "Mock server for " + ProfileInfoService.class;
    mockServer = InProcessServerBuilder
        .forName(uniqueServerName).directExecutor().addService(service).build().start();
    InProcessChannelBuilder channelBuilder =
        InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
    stub = ProfileInfoServiceGrpc.newBlockingStub(channelBuilder.build());
}
项目:beam    文件:ReferenceRunnerJobServiceTest.java   
@Before
public void setup() throws Exception {
  service =
      ReferenceRunnerJobService.create(serverFactory)
          .withStagingPathSupplier(
              new Callable<Path>() {
                @Override
                public Path call() throws Exception {
                  return runnerTemp.getRoot().toPath();
                }
              });
  server = GrpcFnServer.allocatePortAndCreateFor(service, serverFactory);
  stub =
      JobServiceGrpc.newBlockingStub(
          InProcessChannelBuilder.forName(server.getApiServiceDescriptor().getUrl()).build());
}
项目:beam    文件:ReferenceRunnerJobServiceTest.java   
@Test
public void testPrepareJob() throws Exception {
  PrepareJobResponse response =
      stub.prepare(
          PrepareJobRequest.newBuilder()
              .setPipelineOptions(Struct.getDefaultInstance())
              .setPipeline(Pipeline.getDefaultInstance())
              .setJobName("myJobName")
              .build());

  ApiServiceDescriptor stagingEndpoint = response.getArtifactStagingEndpoint();
  ArtifactServiceStager stager =
      ArtifactServiceStager.overChannel(
          InProcessChannelBuilder.forName(stagingEndpoint.getUrl()).build());
  File foo = writeTempFile("foo", "foo, bar, baz".getBytes());
  File bar = writeTempFile("spam", "spam, ham, eggs".getBytes());
  stager.stage(ImmutableList.<File>of(foo, bar));
  List<byte[]> tempDirFiles = readFlattendFiles(runnerTemp.getRoot());
  assertThat(
      tempDirFiles,
      hasItems(
          arrayEquals(Files.readAllBytes(foo.toPath())),
          arrayEquals(Files.readAllBytes(bar.toPath()))));
  // TODO: 'run' the job with some sort of noop backend, to verify state is cleaned up.
}
项目:onos    文件:GrpcNbMastershipServiceTest.java   
/**
 * Initializes the test environment.
 */
@Before
public void setUp() throws IllegalAccessException, IOException, InstantiationException {
    GrpcNbMastershipService grpcMastershipService = new GrpcNbMastershipService();
    grpcMastershipService.mastershipService = mastershipService;
    inprocessServer = grpcMastershipService.registerInProcessServer();
    inprocessServer.start();

    channel = InProcessChannelBuilder.forName("test").directExecutor()
            .usePlaintext(true).build();

    blockingStub = MastershipServiceGrpc.newBlockingStub(channel);

    initMastershipMap();
    initNodeIdMap();
    initRoleInfoMap();
}
项目:onos    文件:GrpcNbMeterServiceTest.java   
/**
 * Create inProcessServer and bind grpcNbMeterService.
 *
 * @throws IllegalAccessException
 * @throws IOException
 * @throws InstantiationException
 */
@BeforeClass
public static void setup() throws IllegalAccessException, IOException, InstantiationException {

    GrpcNbMeterService grpcNbMeterService = new GrpcNbMeterService();
    grpcNbMeterService.meterService = MOCK_METER;
    inProcessServer = new InProcessServer(GrpcNbMeterService.class);
    inProcessServer.addServiceToBind(grpcNbMeterService);

    inProcessServer.start();
    channel = InProcessChannelBuilder.forName("test").directExecutor()
            // Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid
            // needing certificates.
            .usePlaintext(true).build();
    blockingStub = MeterServiceGrpc.newBlockingStub(channel);

    allMeters.add(METER_2);
    allMeters.add(METER_3);
    allMeters.add(METER_4);
}
项目:grpc-java    文件:GrpcServerRule.java   
/**
 * Before the test has started, create the server and channel.
 */
@Override
protected void before() throws Throwable {
  serverName = UUID.randomUUID().toString();

  serviceRegistry = new MutableHandlerRegistry();

  InProcessServerBuilder serverBuilder = InProcessServerBuilder.forName(serverName)
      .fallbackHandlerRegistry(serviceRegistry);

  if (useDirectExecutor) {
    serverBuilder.directExecutor();
  }

  server = serverBuilder.build().start();

  InProcessChannelBuilder channelBuilder = InProcessChannelBuilder.forName(serverName);

  if (useDirectExecutor) {
    channelBuilder.directExecutor();
  }

  channel = channelBuilder.build();
}
项目:reactive-grpc    文件:GradleProof.java   
public String doClient(String name) {
    ManagedChannel channel = InProcessChannelBuilder
            .forName("GradleProof")
            .build();
    try {
        GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(channel);
        HelloRequest request = HelloRequest.newBuilder().setName(name).build();
        HelloResponse response = stub.sayHello(request);
        return response.getMessage();
    } finally {
        channel.shutdownNow();
    }
}
项目:grpc-java-contrib    文件:GrpcServerHostInProcessEndToEndTest.java   
@Test
public void serverIsRunningAndSayHelloReturnsExpectedResponse() throws Exception {
    final String name = UUID.randomUUID().toString();
    grpcServerHost.start();

    ManagedChannel channel = InProcessChannelBuilder
            .forName(SERVER_NAME)
            .usePlaintext(true)
            .build();

    GreeterGrpc.GreeterFutureStub stub = GreeterGrpc.newFutureStub(channel);

    ListenableFuture<HelloResponse> responseFuture = stub.sayHello(HelloRequest.newBuilder().setName(name).build());
    AtomicReference<HelloResponse> response = new AtomicReference<>();

    Futures.addCallback(
            responseFuture,
            new FutureCallback<HelloResponse>() {
                @Override
                public void onSuccess(@Nullable HelloResponse result) {
                    response.set(result);
                }

                @Override
                public void onFailure(Throwable t) {

                }
            },
            MoreExecutors.directExecutor());

    await().atMost(10, TimeUnit.SECONDS).until(responseFuture::isDone);

    channel.shutdownNow();

    assertThat(response.get()).isNotNull();
    assertThat(response.get().getMessage()).contains(name);
}
项目:grpc-java-contrib    文件:SessionIdTest.java   
@Test
public void uniqueSessionIdPerChannel() throws Exception {
    GreeterGrpc.GreeterImplBase svc = new GreeterGrpc.GreeterImplBase() {
        @Override
        public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
            responseObserver.onNext(HelloResponse.newBuilder().setMessage(SessionIdServerInterceptor.SESSION_ID.get().toString()).build());
            responseObserver.onCompleted();
        }
    };

    Server server = InProcessServerBuilder.forName("uniqueSessionIdPerChannel")
            .addTransportFilter(new ClientSessionTransportFilter())
            .intercept(new SessionIdServerInterceptor())
            .addService(svc)
            .build()
            .start();

    ManagedChannel channel1 = InProcessChannelBuilder.forName("uniqueSessionIdPerChannel")
            .usePlaintext(true)
            .build();
    GreeterGrpc.GreeterBlockingStub stub1 = GreeterGrpc.newBlockingStub(channel1);

    ManagedChannel channel2 = InProcessChannelBuilder.forName("uniqueSessionIdPerChannel")
            .usePlaintext(true)
            .build();
    GreeterGrpc.GreeterBlockingStub stub2 = GreeterGrpc.newBlockingStub(channel2);

    try {
        String sessionId1 = stub1.sayHello(HelloRequest.getDefaultInstance()).getMessage();
        String sessionId2 = stub2.sayHello(HelloRequest.getDefaultInstance()).getMessage();

        assertThat(sessionId1).isNotEqualTo(sessionId2);
    } finally {
        channel1.shutdown();
        channel2.shutdown();
        server.shutdown();
    }
}
项目:grpc-java-contrib    文件:SessionIdTest.java   
@Test
public void interceptorThrowsIfMissingTransportFilter() throws Exception {
    GreeterGrpc.GreeterImplBase svc = new GreeterGrpc.GreeterImplBase() {
        @Override
        public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
            responseObserver.onNext(HelloResponse.newBuilder().setMessage(SessionIdServerInterceptor.SESSION_ID.get().toString()).build());
            responseObserver.onCompleted();
        }
    };

    Server server = InProcessServerBuilder.forName("interceptorThrowsIfMissingTransportFilter")
            .intercept(new SessionIdServerInterceptor())
            .addService(svc)
            .build()
            .start();

    ManagedChannel channel = InProcessChannelBuilder.forName("interceptorThrowsIfMissingTransportFilter")
            .usePlaintext(true)
            .build();
    GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(channel);

    try {
        assertThatThrownBy(() -> stub.sayHello(HelloRequest.getDefaultInstance()).getMessage()).isInstanceOf(StatusRuntimeException.class);

    } finally {
        channel.shutdown();
        server.shutdown();
    }
}
项目:grpc-java-contrib    文件:PerSessionServiceTest.java   
@Test
public void perSessionShouldFailMissingTransportFilter() throws Exception {
    class TestService extends GreeterGrpc.GreeterImplBase {
        @Override
        public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
            responseObserver.onNext(HelloResponse.newBuilder().setMessage(Integer.toString(System.identityHashCode(this))).build());
            responseObserver.onCompleted();
        }
    }

    ClientSessionTransportFilter tf = new ClientSessionTransportFilter();
    Server server = InProcessServerBuilder.forName("perSessionShouldInstantiateOneInstancePerSession")
            .addService(new PerSessionService<>(() -> new TestService(), tf))
            .build()
            .start();

    ManagedChannel channel = InProcessChannelBuilder.forName("perSessionShouldInstantiateOneInstancePerSession")
            .usePlaintext(true)
            .build();
    GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(channel);

    try {
        assertThatThrownBy(() -> stub.sayHello(HelloRequest.getDefaultInstance()).getMessage()).isInstanceOf(StatusRuntimeException.class);
    } finally {
        channel.shutdown();
        server.shutdown();
    }
}
项目:bazel-buildfarm    文件:BuildFarmServerTest.java   
@Before
public void setUp() throws Exception {
  String uniqueServerName = "in-process server for " + getClass();

  memoryInstanceConfig = MemoryInstanceConfig.newBuilder()
      .setListOperationsDefaultPageSize(1024)
      .setListOperationsMaxPageSize(16384)
      .setTreeDefaultPageSize(1024)
      .setTreeMaxPageSize(16384)
      .setOperationPollTimeout(Duration.newBuilder()
          .setSeconds(10)
          .setNanos(0))
      .setOperationCompletedDelay(Duration.newBuilder()
          .setSeconds(10)
          .setNanos(0))
      .build();

  BuildFarmServerConfig.Builder configBuilder =
      BuildFarmServerConfig.newBuilder().setPort(0);
  configBuilder.addInstancesBuilder()
      .setName("memory")
      .setMemoryInstanceConfig(memoryInstanceConfig);

  server = new BuildFarmServer(
      InProcessServerBuilder.forName(uniqueServerName).directExecutor(),
      configBuilder.build());
  server.start();
  inProcessChannel = InProcessChannelBuilder.forName(uniqueServerName)
      .directExecutor().build();
}
项目:generator-jhipster-grpc    文件:_JWTServiceIntTest.java   
@Before
public void setUp() throws IOException {
    JWTService service = new JWTService(tokenProvider, authenticationManager);
    String uniqueServerName = "Mock server for " + JWTService.class;
    mockServer = InProcessServerBuilder
        .forName(uniqueServerName).directExecutor().addService(service).build().start();
    InProcessChannelBuilder channelBuilder =
        InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
    stub = JWTServiceGrpc.newBlockingStub(channelBuilder.build());
}
项目:generator-jhipster-grpc    文件:_MetricServiceIntTest.java   
@Before
public void setUp() throws IOException {
    MetricService service = new MetricService(publicMetrics);
    String uniqueServerName = "Mock server for " + MetricService.class;
    mockServer = InProcessServerBuilder
        .forName(uniqueServerName).directExecutor().addService(service).build().start();
    InProcessChannelBuilder channelBuilder =
        InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
    stub = MetricServiceGrpc.newBlockingStub(channelBuilder.build());
}
项目:generator-jhipster-grpc    文件:_ConfigurationPropertiesReportServiceIntTest.java   
@Before
public void setUp() throws IOException {
    ConfigurationPropertiesReportService service = new ConfigurationPropertiesReportService(configurationPropertiesReportEndpoint);
    String uniqueServerName = "Mock server for " + ConfigurationPropertiesReportService.class;
    mockServer = InProcessServerBuilder
        .forName(uniqueServerName).directExecutor().addService(service).build().start();
    InProcessChannelBuilder channelBuilder =
        InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
    stub = ConfigurationPropertiesReportServiceGrpc.newBlockingStub(channelBuilder.build());
}
项目:generator-jhipster-grpc    文件:_LoggersServiceIntTest.java   
@Before
public void setUp() throws IOException {
    LoggersService service = new LoggersService(loggingSystem);
    String uniqueServerName = "Mock server for " + LoggersService.class;
    mockServer = InProcessServerBuilder
        .forName(uniqueServerName).directExecutor().addService(service).build().start();
    InProcessChannelBuilder channelBuilder =
        InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
    stub = LoggersServiceGrpc.newBlockingStub(channelBuilder.build());
}
项目:generator-jhipster-grpc    文件:_EnvironmentServiceIntTest.java   
@Before
public void setUp() throws IOException {
    EnvironmentService service = new EnvironmentService(endpoint);
    String uniqueServerName = "Mock server for " + EnvironmentService.class;
    mockServer = InProcessServerBuilder
        .forName(uniqueServerName).directExecutor().addService(service).build().start();
    InProcessChannelBuilder channelBuilder =
        InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
    stub = EnvironmentServiceGrpc.newBlockingStub(channelBuilder.build());
}
项目:generator-jhipster-grpc    文件:_HealthServiceIntTest.java   
@Before
public void setUp() throws IOException {
    HealthService service = new HealthService(healthAggregator, healthIndicators);
    String uniqueServerName = "Mock server for " + HealthService.class;
    mockServer = InProcessServerBuilder
        .forName(uniqueServerName).directExecutor().addService(service).build().start();
    InProcessChannelBuilder channelBuilder =
        InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
    stub = HealthServiceGrpc.newBlockingStub(channelBuilder.build());
}
项目:generator-jhipster-grpc    文件:_AuditGrpcServiceIntTest.java   
@Before
public void setUp() throws IOException {
    AuditEventService auditEventService =
        new AuditEventService(auditEventRepository, auditEventConverter);
    AuditGrpcService service = new AuditGrpcService(auditEventService);
    String uniqueServerName = "Mock server for " + AuditGrpcService.class;
    mockServer = InProcessServerBuilder
        .forName(uniqueServerName).directExecutor().addService(service).build().start();
    InProcessChannelBuilder channelBuilder =
        InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
    stub = AuditServiceGrpc.newBlockingStub(channelBuilder.build());
}
项目:grpc-spring-boot-starter    文件:GrpcServerTestBase.java   
@Before
public final void setupChannels() {
    if(gRpcServerProperties.isEnabled()) {
        channel = onChannelBuild(ManagedChannelBuilder.forAddress("localhost",getPort() )
                .usePlaintext(true)
                ).build();
    }
    if(StringUtils.hasText(gRpcServerProperties.getInProcessServerName())){
        inProcChannel = onChannelBuild(
                            InProcessChannelBuilder.forName(gRpcServerProperties.getInProcessServerName())
                            .usePlaintext(true)
                        ).build();

    }
}
项目:beam    文件:BeamFnStateGrpcClientCacheTest.java   
@Before
public void setUp() throws Exception {
  values = new LinkedBlockingQueue<>();
  outboundServerObservers = new LinkedBlockingQueue<>();
  CallStreamObserver<StateRequest> inboundServerObserver =
      TestStreams.withOnNext(values::add).build();

  apiServiceDescriptor =
      Endpoints.ApiServiceDescriptor.newBuilder()
          .setUrl(this.getClass().getName() + "-" + UUID.randomUUID().toString())
          .build();
  testServer = InProcessServerBuilder.forName(apiServiceDescriptor.getUrl())
      .addService(new BeamFnStateGrpc.BeamFnStateImplBase() {
        @Override
        public StreamObserver<StateRequest> state(
            StreamObserver<StateResponse> outboundObserver) {
          Uninterruptibles.putUninterruptibly(outboundServerObservers, outboundObserver);
          return inboundServerObserver;
        }
      })
      .build();
  testServer.start();

  testChannel = InProcessChannelBuilder.forName(apiServiceDescriptor.getUrl()).build();

  clientCache = new BeamFnStateGrpcClientCache(
      PipelineOptionsFactory.create(),
      IdGenerator::generate,
      (Endpoints.ApiServiceDescriptor descriptor) -> testChannel,
      this::createStreamForTest);
}
项目:beam    文件:PubsubGrpcClientTest.java   
@Before
public void setup() {
  channelName = String.format("%s-%s",
      PubsubGrpcClientTest.class.getName(), ThreadLocalRandom.current().nextInt());
  inProcessChannel = InProcessChannelBuilder.forName(channelName).directExecutor().build();
  testCredentials = new TestCredential();
  client =
      new PubsubGrpcClient(
          TIMESTAMP_ATTRIBUTE, ID_ATTRIBUTE, 10, inProcessChannel, testCredentials);
}
项目:beam    文件:ArtifactServiceStagerTest.java   
@Before
public void setup() throws IOException {
  stager =
      ArtifactServiceStager.overChannel(
          InProcessChannelBuilder.forName("service_stager").build(), 6);
  service = new InMemoryArtifactStagerService();
  server =
      InProcessServerBuilder.forName("service_stager")
          .directExecutor()
          .addService(service)
          .build()
          .start();
}
项目:beam    文件:LocalFileSystemArtifactStagerServiceTest.java   
@Before
public void setup() throws Exception {
  stager = LocalFileSystemArtifactStagerService.withRootDirectory(temporaryFolder.newFolder());

  server =
      InProcessServerBuilder.forName("fs_stager")
          .directExecutor()
          .addService(stager)
          .build()
          .start();

  stub =
      ArtifactStagingServiceGrpc.newStub(
          InProcessChannelBuilder.forName("fs_stager").usePlaintext(true).build());
}
项目:beam    文件:GrpcLoggingServiceTest.java   
@Test
public void testMultipleClientsFailingIsHandledGracefullyByServer() throws Exception {
  ConcurrentLinkedQueue<BeamFnApi.LogEntry> logs = new ConcurrentLinkedQueue<>();
  GrpcLoggingService service =
      GrpcLoggingService.forWriter(new CollectionAppendingLogWriter(logs));
  try (GrpcFnServer<GrpcLoggingService> server =
      GrpcFnServer.allocatePortAndCreateFor(service, InProcessServerFactory.create())) {

    Collection<Callable<Void>> tasks = new ArrayList<>();
    for (int i = 1; i <= 3; ++i) {
      final int instructionReference = i;
      tasks.add(
          new Callable<Void>() {
            public Void call() throws Exception {
              CountDownLatch waitForTermination = new CountDownLatch(1);
              ManagedChannel channel =
                  InProcessChannelBuilder.forName(server.getApiServiceDescriptor().getUrl())
                      .build();
              StreamObserver<BeamFnApi.LogEntry.List> outboundObserver =
                  BeamFnLoggingGrpc.newStub(channel)
                      .logging(
                          TestStreams.withOnNext(messageDiscarder)
                              .withOnError(new CountDown(waitForTermination))
                              .build());
              outboundObserver.onNext(
                  createLogsWithIds(instructionReference, -instructionReference));
              outboundObserver.onError(new RuntimeException("Client " + instructionReference));
              waitForTermination.await();
              return null;
            }
          });
    }
    ExecutorService executorService = Executors.newCachedThreadPool();
    executorService.invokeAll(tasks);
  }
}
项目:bazel    文件:ByteStreamUploaderTest.java   
@Before
public final void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);

  String serverName = "Server for " + this.getClass();
  server = InProcessServerBuilder.forName(serverName).fallbackHandlerRegistry(serviceRegistry)
      .build().start();
  channel = InProcessChannelBuilder.forName(serverName).build();
  withEmptyMetadata =
      TracingMetadataUtils.contextWithMetadata(
          "none", "none", DIGEST_UTIL.asActionKey(Digest.getDefaultInstance()));
  // Needs to be repeated in every test that uses the timeout setting, since the tests run
  // on different threads than the setUp.
  withEmptyMetadata.attach();
}
项目:bazel    文件:GrpcRemoteCacheTest.java   
private GrpcRemoteCache newClient() throws IOException {
  AuthAndTLSOptions authTlsOptions = Options.getDefaults(AuthAndTLSOptions.class);
  authTlsOptions.useGoogleDefaultCredentials = true;
  authTlsOptions.googleCredentials = "/exec/root/creds.json";
  authTlsOptions.googleAuthScopes = ImmutableList.of("dummy.scope");

  GenericJson json = new GenericJson();
  json.put("type", "authorized_user");
  json.put("client_id", "some_client");
  json.put("client_secret", "foo");
  json.put("refresh_token", "bar");
  Scratch scratch = new Scratch();
  scratch.file(authTlsOptions.googleCredentials, new JacksonFactory().toString(json));

  CallCredentials creds =
      GoogleAuthUtils.newCallCredentials(
          scratch.resolve(authTlsOptions.googleCredentials).getInputStream(),
          authTlsOptions.googleAuthScopes);
  RemoteOptions remoteOptions = Options.getDefaults(RemoteOptions.class);
  RemoteRetrier retrier =
      new RemoteRetrier(
          remoteOptions, RemoteRetrier.RETRIABLE_GRPC_ERRORS, Retrier.ALLOW_ALL_CALLS);
  return new GrpcRemoteCache(
      ClientInterceptors.intercept(
          InProcessChannelBuilder.forName(fakeServerName).directExecutor().build(),
          ImmutableList.of(new CallCredentialsInterceptor(creds))),
      creds,
      remoteOptions,
      retrier,
      DIGEST_UTIL);
}
项目:onos    文件:P4RuntimeGroupTest.java   
@BeforeClass
public static void globalSetup() throws IOException {
    AbstractServerImplBuilder builder = InProcessServerBuilder
            .forName(GRPC_SERVER_NAME).directExecutor();
    builder.addService(p4RuntimeServerImpl);
    grpcServer = builder.build().start();
    grpcChannel = InProcessChannelBuilder.forName(GRPC_SERVER_NAME)
            .directExecutor()
            .usePlaintext(true)
            .build();
}
项目:onos    文件:GrpcNbHostServiceTest.java   
/**
 * Initialization before start testing gRPC northbound host service.
 */
@BeforeClass
public static void beforeClass() throws InstantiationException, IllegalAccessException, IOException {
    GrpcNbHostService hostService = new GrpcNbHostService();
    hostService.hostService = MOCK_HOST;
    inprocessServer = hostService.registerInProcessServer();

    inprocessServer.start();
    channel = InProcessChannelBuilder.forName("test").directExecutor()
            // Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid
            // needing certificates.
            .usePlaintext(true).build();
    blockingStub = HostServiceGrpc.newBlockingStub(channel);
    populateHosts();
}
项目:onos    文件:GrpcNbLinkServiceTest.java   
@BeforeClass
public static void beforeClass() throws InstantiationException, IllegalAccessException, IOException {
    GrpcNbLinkService linkService = new GrpcNbLinkService();
    linkService.linkService = MOCK_LINK;
    inprocessServer = linkService.registerInProcessServer();
    inprocessServer.start();

    channel = InProcessChannelBuilder.forName("test").directExecutor()
            // Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid
            // needing certificates.
            .usePlaintext(true).build();
    blockingStub = LinkServiceGrpc.newBlockingStub(channel);

    populateLinks();
}
项目:onos    文件:GrpcNbRegionServiceTest.java   
@BeforeClass
public static void beforeClass() throws InstantiationException, IllegalAccessException, IOException {
    GrpcNbRegionService regionService = new GrpcNbRegionService();
    regionService.regionService = MOCK_REGION;
    inprocessServer = regionService.registerInProcessServer();
    inprocessServer.start();

    channel = InProcessChannelBuilder.forName("test").directExecutor()
            // Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid
            // needing certificates.
            .usePlaintext(true).build();
    blockingStub = RegionServiceGrpc.newBlockingStub(channel);
    populateHosts();
}
项目:onos    文件:GrpcNbApplicationServiceTest.java   
/**
 * Initializes the test environment.
 */
@Before
public void setUp() throws IllegalAccessException, IOException, InstantiationException {

    GrpcNbApplicationService grpcAppService = new GrpcNbApplicationService();
    grpcAppService.applicationService = appService;
    inprocessServer = grpcAppService.registerInProcessServer();
    inprocessServer.start();

    channel = InProcessChannelBuilder.forName("test").directExecutor()
            .usePlaintext(true).build();

    blockingStub = ApplicationServiceGrpc.newBlockingStub(channel);
}
项目:onos    文件:GrpcNbComponentConfigServiceTest.java   
/**
 * Initialization before start testing gRPC northbound component config service.
 */
@BeforeClass
public static void beforeClass() throws InstantiationException, IllegalAccessException, IOException {
    GrpcNbComponentConfigService componentConfigService = new GrpcNbComponentConfigService();
    componentConfigService.componentConfigService = MOCK_COMPONENTCONFIG;
    inprocessServer = componentConfigService.registerInProcessServer();
    inprocessServer.start();

    channel = InProcessChannelBuilder.forName("test").directExecutor()
            // Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid
            // needing certificates.
            .usePlaintext(true).build();
    blockingStub = ComponentConfigServiceGrpc.newBlockingStub(channel);
    populateComponentNames();
}
项目:grpc-java    文件:RouteGuideServerTest.java   
@Before
public void setUp() throws Exception {
  String uniqueServerName = "in-process server for " + getClass();
  features = new ArrayList<Feature>();
  // use directExecutor for both InProcessServerBuilder and InProcessChannelBuilder can reduce the
  // usage timeouts and latches in test. But we still add timeout and latches where they would be
  // needed if no directExecutor were used, just for demo purpose.
  server = new RouteGuideServer(
      InProcessServerBuilder.forName(uniqueServerName).directExecutor(), 0, features);
  server.start();
  inProcessChannel = InProcessChannelBuilder.forName(uniqueServerName).directExecutor().build();
}
项目:grpc-java    文件:RouteGuideClientTest.java   
@Before
public void setUp() throws Exception {
  String uniqueServerName = "fake server for " + getClass();

  // use a mutable service registry for later registering the service impl for each test case.
  fakeServer = InProcessServerBuilder.forName(uniqueServerName)
      .fallbackHandlerRegistry(serviceRegistry).directExecutor().build().start();
  client =
      new RouteGuideClient(InProcessChannelBuilder.forName(uniqueServerName).directExecutor());
  client.setTestHelper(testHelper);
}
项目:grpc-java    文件:CascadingTest.java   
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  // Use a cached thread pool as we need a thread for each blocked call
  otherWork = Executors.newCachedThreadPool();
  channel = InProcessChannelBuilder.forName("channel").executor(otherWork).build();
  blockingStub = TestServiceGrpc.newBlockingStub(channel);
  asyncStub = TestServiceGrpc.newStub(channel);
  futureStub = TestServiceGrpc.newFutureStub(channel);
}
项目:grpc-java    文件:InProcessTest.java   
@Override
protected ManagedChannel createChannel() {
  InProcessChannelBuilder builder = InProcessChannelBuilder.forName(SERVER_NAME);
  io.grpc.internal.TestingAccessor.setStatsImplementation(
      builder, createClientCensusStatsModule());
  return builder.build();
}
项目:grpc-java    文件:ProtoReflectionServiceTest.java   
@Before
public void setUp() throws Exception {
  reflectionService = ProtoReflectionService.newInstance();
  server =
      InProcessServerBuilder.forName("proto-reflection-test")
          .directExecutor()
          .addService(reflectionService)
          .addService(new ReflectableServiceGrpc.ReflectableServiceImplBase() {})
          .fallbackHandlerRegistry(handlerRegistry)
          .build()
          .start();
  channel = InProcessChannelBuilder.forName("proto-reflection-test").directExecutor().build();
  stub = ServerReflectionGrpc.newStub(channel);
}
项目:reactive-grpc    文件:RxGrpcPublisherOneToManyVerificationTest.java   
@BeforeClass
public static void setup() throws Exception {
    System.out.println("RxGrpcPublisherOneToManyVerificationTest");
    server = InProcessServerBuilder.forName("RxGrpcPublisherOneToManyVerificationTest").addService(new TckService()).build().start();
    channel = InProcessChannelBuilder.forName("RxGrpcPublisherOneToManyVerificationTest").usePlaintext(true).build();
}