@Test
public void testInvalidUTF8() throws Exception {

  byte[] invalid = new byte[] {
      0x01, 0x02, (byte)0xff, (byte)0xff, 0x01, 0x02, 0x03, 0x04, 0x05 };
  try {
    UTF8.fromBytes(invalid);
    fail("did not throw an exception");
  } catch (UTFDataFormatException utfde) {
    GenericTestUtils.assertExceptionContains(
        "Invalid UTF8 at ffff01020304", utfde);
  }
}