io.grpc.testing.GrpcCleanupRule Java Examples
The following examples show how to use
io.grpc.testing.GrpcCleanupRule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestingTools.java From gcp-token-broker with Apache License 2.0 | 6 votes |
/** * Starts a live instance of a mock implementation of the broker server. */ static void startServer(FakeBrokerImpl fakeServer, GrpcCleanupRule grpcCleanup) { String serverName = InProcessServerBuilder.generateName(); try { grpcCleanup.register(InProcessServerBuilder.forName(serverName).directExecutor() .addService(ServerInterceptors.intercept(fakeServer, new AuthorizationHeaderServerInterceptor())) .build().start()); } catch (IOException e) { throw new RuntimeException(e); } ManagedChannel channel = grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()); BrokerGrpc.BrokerBlockingStub stub = BrokerGrpc.newBlockingStub(channel); mockStatic(GrpcUtils.class); when(GrpcUtils.newManagedChannel(BROKER_HOST, 1234, false, null)).thenReturn(channel); when(GrpcUtils.newStub(channel)).thenReturn(stub); }
Example #2
Source File: FeastClientTest.java From feast with Apache License 2.0 | 6 votes |
@Before public void setup() throws Exception { this.grpcRule = new GrpcCleanupRule(); // setup fake serving service String serverName = InProcessServerBuilder.generateName(); this.grpcRule.register( InProcessServerBuilder.forName(serverName) .directExecutor() .addService(this.servingMock) .build() .start()); // setup test feast client target ManagedChannel channel = this.grpcRule.register( InProcessChannelBuilder.forName(serverName).directExecutor().build()); this.client = new FeastClient(channel); }