Exemple #1
0
 public void testParseRequiredStringWithBadUtf8() throws Exception {
   ByteString serialized =
       BytesWrapper.newBuilder().setReq(NON_UTF8_BYTE_STRING).build().toByteString();
   try {
     StringWrapper.PARSER.parseFrom(serialized);
     fail("Expected InvalidProtocolBufferException for non UTF-8 byte string.");
   } catch (InvalidProtocolBufferException exception) {
     assertEquals("Protocol message had invalid UTF-8.", exception.getMessage());
   }
 }
Exemple #2
0
 public void testParseRequiredStringWithGoodUtf8() throws Exception {
   ByteString serialized =
       BytesWrapper.newBuilder().setReq(UTF8_BYTE_STRING).build().toByteString();
   assertEquals(UTF8_BYTE_STRING_TEXT, StringWrapper.PARSER.parseFrom(serialized).getReq());
 }