DescriptorsTest.java 文件源码

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

项目:vsminecraft 作者:
public void testServiceDescriptor() throws Exception {
  ServiceDescriptor service = TestService.getDescriptor();

  assertEquals("TestService", service.getName());
  assertEquals("protobuf_unittest.TestService", service.getFullName());
  assertEquals(UnittestProto.getDescriptor(), service.getFile());


  MethodDescriptor fooMethod = service.getMethods().get(0);
  assertEquals("Foo", fooMethod.getName());
  assertEquals(UnittestProto.FooRequest.getDescriptor(),
               fooMethod.getInputType());
  assertEquals(UnittestProto.FooResponse.getDescriptor(),
               fooMethod.getOutputType());
  assertEquals(fooMethod, service.findMethodByName("Foo"));

  MethodDescriptor barMethod = service.getMethods().get(1);
  assertEquals("Bar", barMethod.getName());
  assertEquals(UnittestProto.BarRequest.getDescriptor(),
               barMethod.getInputType());
  assertEquals(UnittestProto.BarResponse.getDescriptor(),
               barMethod.getOutputType());
  assertEquals(barMethod, service.findMethodByName("Bar"));

  assertNull(service.findMethodByName("NoSuchMethod"));

  for (int i = 0; i < service.getMethods().size(); i++) {
    assertEquals(i, service.getMethods().get(i).getIndex());
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号