ServiceTest.java 文件源码

java
阅读 33 收藏 0 点赞 0 评论 0

项目:s-store 作者:
/** Tests generated blocking stubs. */
public void testBlockingStub() throws Exception {
  FooRequest fooRequest = FooRequest.newBuilder().build();
  BarRequest barRequest = BarRequest.newBuilder().build();
  BlockingRpcChannel mockChannel =
      control.createMock(BlockingRpcChannel.class);
  TestService.BlockingInterface stub =
      TestService.newBlockingStub(mockChannel);

  FooResponse fooResponse = FooResponse.newBuilder().build();
  BarResponse barResponse = BarResponse.newBuilder().build();

  EasyMock.expect(mockChannel.callBlockingMethod(
    EasyMock.same(fooDescriptor),
    EasyMock.same(mockController),
    EasyMock.same(fooRequest),
    EasyMock.same(FooResponse.getDefaultInstance()))).andReturn(fooResponse);
  EasyMock.expect(mockChannel.callBlockingMethod(
    EasyMock.same(barDescriptor),
    EasyMock.same(mockController),
    EasyMock.same(barRequest),
    EasyMock.same(BarResponse.getDefaultInstance()))).andReturn(barResponse);
  control.replay();

  assertSame(fooResponse, stub.foo(mockController, fooRequest));
  assertSame(barResponse, stub.bar(mockController, barRequest));
  control.verify();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号