当前位置: 首页>>代码示例>>Java>>正文


Java Marshaller.parse方法代码示例

本文整理汇总了Java中io.grpc.MethodDescriptor.Marshaller.parse方法的典型用法代码示例。如果您正苦于以下问题:Java Marshaller.parse方法的具体用法?Java Marshaller.parse怎么用?Java Marshaller.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.grpc.MethodDescriptor.Marshaller的用法示例。


在下文中一共展示了Marshaller.parse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testJsonIoException

import io.grpc.MethodDescriptor.Marshaller; //导入方法依赖的package包/类
@Test
public void testJsonIoException() throws Exception {
  Marshaller<Type> marshaller = ProtoUtils.jsonMarshaller(Type.getDefaultInstance());
  final IOException ioe = new IOException();
  try {
    marshaller.parse(new ByteArrayInputStream("{}".getBytes("UTF-8")) {
      @Override
      public void close() throws IOException {
        throw ioe;
      }
    });
    fail("Exception expected");
  } catch (StatusRuntimeException ex) {
    assertEquals(Status.Code.INTERNAL, ex.getStatus().getCode());
    assertEquals(ioe, ex.getCause());
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:18,代码来源:ProtoUtilsTest.java

示例2: testJsonInvalid

import io.grpc.MethodDescriptor.Marshaller; //导入方法依赖的package包/类
@Ignore("https://github.com/google/protobuf/issues/1470")
@Test
public void testJsonInvalid() throws Exception {
  Marshaller<Type> marshaller = ProtoUtils.jsonMarshaller(Type.getDefaultInstance());
  try {
    marshaller.parse(new ByteArrayInputStream("{]".getBytes("UTF-8")));
    fail("Expected exception");
  } catch (StatusRuntimeException ex) {
    assertEquals(Status.Code.INTERNAL, ex.getStatus().getCode());
    assertNotNull(ex.getCause());
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:13,代码来源:ProtoUtilsTest.java

示例3: testJsonInvalidProto

import io.grpc.MethodDescriptor.Marshaller; //导入方法依赖的package包/类
@Test
public void testJsonInvalidProto() throws Exception {
  Marshaller<Type> marshaller = ProtoUtils.jsonMarshaller(Type.getDefaultInstance());
  try {
    marshaller.parse(new ByteArrayInputStream("{\"\":3}".getBytes("UTF-8")));
    fail("Expected exception");
  } catch (StatusRuntimeException ex) {
    assertEquals(Status.Code.INTERNAL, ex.getStatus().getCode());
    assertNotNull(ex.getCause());
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:12,代码来源:ProtoUtilsTest.java

示例4: parseFromKnowLengthInputStream

import io.grpc.MethodDescriptor.Marshaller; //导入方法依赖的package包/类
@Test
public void parseFromKnowLengthInputStream() throws Exception {
  Marshaller<Type> marshaller = ProtoLiteUtils.marshaller(Type.getDefaultInstance());
  Type expect = Type.newBuilder().setName("expected name").build();

  Type result = marshaller.parse(new CustomKnownLengthInputStream(expect.toByteArray()));
  assertEquals(expect, result);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:9,代码来源:ProtoLiteUtilsTest.java


注:本文中的io.grpc.MethodDescriptor.Marshaller.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。