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 TrailingZerosTest method testFailsToReadMessageWithTooManyTrailingZeros.
public void testFailsToReadMessageWithTooManyTrailingZeros() throws Exception {
TypicalData data = TypicalData.newBuilder().build();
byte[] serializedData = data.toByteArray();
byte[] paddedSerializedData = Arrays.copyOf(serializedData, serializedData.length + 8);
try {
TypicalData.parseFrom(paddedSerializedData);
fail("should not have parsed a buffer with too many trailing zeros");
} catch (InvalidProtocolBufferException e) {
// expected
}
}
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 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
}
}
Aggregations