### Question:
TextUtil { public static void textAppend(Text text, String string) { appendNullByte(text); textAppendNoNull(text, string); }  static void textAppend(Text text, String string); static void textAppend(Text text, String string, boolean replaceBadChar); static void textAppend(Text t, long s); static void appendNullByte(Text text); static void textAppendNoNull(Text t, String s); static void textAppendNoNull(Text t, String s, boolean replaceBadChar); static byte[] toUtf8(String string); static String fromUtf8(byte[] bytes);  }### Answer:
@Test public void testAppend_multiByteChars() throws UnsupportedEncodingException { String prefix = "prefix\u6C34"; int prefixLength = prefix.getBytes("UTF-8").length; Text text = new Text(prefix.getBytes("UTF-8")); String multiByteCharString = "\u007A\u6C34\uD834\uDD1E"; TextUtil.textAppend(text, multiByteCharString); byte[] stringBytes = multiByteCharString.getBytes("UTF-8"); Assert.assertEquals("Length was wrong", 1 + stringBytes.length, text.getLength() - prefixLength); byte[] textBytes = text.getBytes(); Assert.assertEquals("First byte was wrong", (byte) 0, textBytes[prefixLength]); byte[] restOfText = new byte[text.getLength() - prefixLength - 1]; System.arraycopy(textBytes, 1 + prefixLength, restOfText, 0, restOfText.length); Assert.assertArrayEquals("Contents were wrong", stringBytes, restOfText); }
@Test public void testAppend_long() throws IOException { String prefix = "prefix\u6C34"; int prefixLength = prefix.getBytes("UTF-8").length; Text text = new Text(prefix.getBytes("UTF-8")); long appendedLong = 0x0123456789ABCDEFl; TextUtil.textAppend(text, appendedLong); Assert.assertEquals("Length was wrong", 1 + 8, text.getLength() - prefixLength); byte[] textBytes = text.getBytes(); Assert.assertEquals("First byte was wrong", (byte) 0, textBytes[prefixLength]); byte[] restOfText = new byte[text.getLength() - prefixLength - 1]; System.arraycopy(textBytes, 1 + prefixLength, restOfText, 0, restOfText.length); Assert.assertArrayEquals("Contents were wrong", new byte[] {(byte) 0x01, (byte) 0x23, (byte) 0x45, (byte) 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF}, restOfText); }