Exemplo n.º 1
0
  @Test
  public void testOptimizedSerializationDefaultDeserialization() throws Exception {

    TestAllTypes message = createSampleMessage();

    byte[] data = TestAllTypesSerializer.serialize(message);

    protobuf_unittest.UnittestProto.TestAllTypes result =
        protobuf_unittest.UnittestProto.TestAllTypes.parseFrom(data);
    assertNotNull(result);
    assertDeepEquals(result, message);
    assertTrue(result.getUnknownFields().asMap().isEmpty());
  }
Exemplo n.º 2
0
  @Test
  public void testOptimizedSerializeToStreamDefaultDeserialization() throws Exception {

    TestAllTypes message = createSampleMessage();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    TestAllTypesSerializer.serialize(message, baos);

    protobuf_unittest.UnittestProto.TestAllTypes result =
        protobuf_unittest.UnittestProto.TestAllTypes.parseFrom(baos.toByteArray());
    assertNotNull(result);
    assertDeepEquals(result, message);
    assertTrue(result.getUnknownFields().asMap().isEmpty());
  }