本文整理汇总了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());
}
}
示例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());
}
}
示例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());
}
}
示例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);
}