use of com.google.protobuf.InvalidProtocolBufferException in project j2objc by google.
the class CompatibilityTest method testMergeDelimitedFromInvalidProtocolBufferException.
public void testMergeDelimitedFromInvalidProtocolBufferException() throws Exception {
try {
ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x03, 0x01, 0x02 });
TypicalData.Builder builder = TypicalData.newBuilder();
builder.mergeDelimitedFrom(in, ExtensionRegistry.getEmptyRegistry());
builder.build();
fail("Expected InvalidProtocolBufferException to be thrown.");
} catch (InvalidProtocolBufferException e) {
// Expected
}
}
use of com.google.protobuf.InvalidProtocolBufferException in project j2objc by google.
the class CompatibilityTest method testParseFromInvalidProtocolBufferException.
public void testParseFromInvalidProtocolBufferException() throws Exception {
try {
@SuppressWarnings("unused") TypicalData output = TypicalData.parseFrom(new byte[] { 0x08 });
fail("Expected InvalidProtocolBufferException to be thrown.");
} catch (InvalidProtocolBufferException e) {
// Expected
}
}
use of com.google.protobuf.InvalidProtocolBufferException in project j2objc by google.
the class CompatibilityTest method testParseDelimitedFromInvalidProtocolBufferException.
public void testParseDelimitedFromInvalidProtocolBufferException() throws Exception {
try {
ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x03, 0x01, 0x02 });
@SuppressWarnings("unused") TypicalData output = TypicalData.parseDelimitedFrom(in);
fail("Expected InvalidProtocolBufferException to be thrown.");
} catch (InvalidProtocolBufferException e) {
// Expected
}
}
use of com.google.protobuf.InvalidProtocolBufferException in project j2objc by google.
the class CompatibilityTest method testMergeFromInvalidProtocolBufferException.
public void testMergeFromInvalidProtocolBufferException() throws Exception {
try {
ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x00 });
@SuppressWarnings("unused") TypicalData output = TypicalData.newBuilder().mergeFrom(in, ExtensionRegistry.getEmptyRegistry()).build();
fail("Expected InvalidProtocolBufferException to be thrown.");
} catch (InvalidProtocolBufferException e) {
// Expected
}
}
use of com.google.protobuf.InvalidProtocolBufferException in project grpc-java by grpc.
the class ProtoLiteUtilsTest method parseInvalid.
@Test
public void parseInvalid() throws Exception {
InputStream is = new ByteArrayInputStream(new byte[] { -127 });
try {
marshaller.parse(is);
fail("Expected exception");
} catch (StatusRuntimeException ex) {
assertEquals(Status.Code.INTERNAL, ex.getStatus().getCode());
assertNotNull(((InvalidProtocolBufferException) ex.getCause()).getUnfinishedMessage());
}
}
Aggregations