### Question:
DnsName implements CharSequence, Serializable, Comparable<DnsName> { public static DnsName parse(DataInputStream dis, byte[] data) throws IOException { int c = dis.readUnsignedByte(); if ((c & 0xc0) == 0xc0) { c = ((c & 0x3f) << 8) + dis.readUnsignedByte(); HashSet<Integer> jumps = new HashSet<Integer>(); jumps.add(c); return parse(data, c, jumps); } if (c == 0) { return DnsName.ROOT; } byte[] b = new byte[c]; dis.readFully(b); String childLabelString = new String(b, StandardCharsets.US_ASCII); DnsName child = new DnsName(childLabelString); DnsName parent = parse(dis, data); return DnsName.from(child, parent); } private  DnsName(String name); private  DnsName(String name, boolean inAce); private  DnsName(DnsLabel[] rawLabels, boolean validateMaxDnsnameLength); void writeToStream(OutputStream os); byte[] getBytes(); byte[] getRawBytes(); String getRawAce(); String asIdn(); String getDomainpart(); String getHostpart(); DnsLabel getHostpartLabel(); int size(); @Override int length(); @Override char charAt(int index); @Override CharSequence subSequence(int start, int end); @Override String toString(); static DnsName from(CharSequence name); static DnsName from(String name); static DnsName from(DnsName child, DnsName parent); static DnsName from(DnsLabel child, DnsName parent); static DnsName from(DnsLabel grandchild, DnsLabel child, DnsName parent); static DnsName from(DnsName... nameComponents); static DnsName from(String[] parts); static DnsName parse(DataInputStream dis, byte[] data); @Override int compareTo(DnsName other); @Override boolean equals(Object other); @Override int hashCode(); boolean isDirectChildOf(DnsName parent); boolean isChildOf(DnsName parent); int getLabelCount(); DnsLabel[] getLabels(); DnsLabel getLabel(int labelNum); DnsLabel[] getRawLabels(); DnsName stripToLabels(int labelCount); DnsName getParent(); boolean isRootLabel(); static final int MAX_LABELS; static final DnsName ROOT; static final DnsName IN_ADDR_ARPA; static final DnsName IP6_ARPA; static boolean VALIDATE; final String ace; }### Answer:
@Test public void parseTest() throws IOException { byte[] test = new byte[] {7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 0}; assertCsEquals("example", DnsName.parse(new DataInputStream(new ByteArrayInputStream(test)), test)); test = new byte[] {7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0}; assertCsEquals("example.com", DnsName.parse(new DataInputStream(new ByteArrayInputStream(test)), test)); }