UnittestLite.optionalNestedMessageExtensionLite).getBb());
}
public void testSerialize() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
TestAllTypesLite expected =
TestAllTypesLite.newBuilder()
.setOptionalInt32(123)
.addRepeatedString("hello")
.setOptionalNestedMessage(
TestAllTypesLite.NestedMessage.newBuilder().setBb(7))
.build();
ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(expected);
out.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream in = new ObjectInputStream(bais);
TestAllTypesLite actual = (TestAllTypesLite) in.readObject();
assertEquals(expected.getOptionalInt32(), actual.getOptionalInt32());
assertEquals(expected.getRepeatedStringCount(),
actual.getRepeatedStringCount());
assertEquals(expected.getRepeatedString(0),
actual.getRepeatedString(0));
assertEquals(expected.getOptionalNestedMessage().getBb(),
actual.getOptionalNestedMessage().getBb());
}