### Question:
JsonUtil { public static String toJsonString(final Token<? extends TokenIdentifier> token ) throws IOException { return toJsonString(Token.class, toJsonMap(token)); }  static String toJsonString(final Token<? extends TokenIdentifier> token
      ); static Token<? extends TokenIdentifier> toToken(
      final Map<?, ?> m); @SuppressWarnings("unchecked") static Token<DelegationTokenIdentifier> toDelegationToken(
      final Map<?, ?> json); static String toJsonString(final Token<? extends TokenIdentifier>[] tokens
      ); static List<Token<?>> toTokenList(final Map<?, ?> json); static String toJsonString(final Exception e); static RemoteException toRemoteException(final Map<?, ?> json); static String toJsonString(final String key, final Object value); static String toJsonString(final HdfsFileStatus status,
      boolean includeType); static HdfsFileStatus toFileStatus(final Map<?, ?> json, boolean includesType); static String toJsonString(final LocatedBlocks locatedblocks
      ); static LocatedBlocks toLocatedBlocks(final Map<?, ?> json
      ); static String toJsonString(final ContentSummary contentsummary); static ContentSummary toContentSummary(final Map<?, ?> json); static String toJsonString(final MD5MD5CRC32FileChecksum checksum); static MD5MD5CRC32FileChecksum toMD5MD5CRC32FileChecksum(
      final Map<?, ?> json); static String toJsonString(final AclStatus status); static AclStatus toAclStatus(final Map<?, ?> json); static String toJsonString(final List<XAttr> xAttrs, 
      final XAttrCodec encoding); static String toJsonString(final List<XAttr> xAttrs); static byte[] getXAttr(final Map<?, ?> json, final String name); static Map<String, byte[]> toXAttrs(final Map<?, ?> json); static List<String> toXAttrNames(final Map<?, ?> json);  }### Answer:
@Test public void testToJsonFromAclStatus() { String jsonString = "{\"AclStatus\":{\"entries\":[\"user:user1:rwx\",\"group::rw-\"],\"group\":\"supergroup\",\"owner\":\"testuser\",\"stickyBit\":false}}"; AclStatus.Builder aclStatusBuilder = new AclStatus.Builder(); aclStatusBuilder.owner("testuser"); aclStatusBuilder.group("supergroup"); aclStatusBuilder.stickyBit(false); List<AclEntry> aclSpec = Lists.newArrayList(aclEntry(ACCESS, USER,"user1", ALL), aclEntry(ACCESS, GROUP, READ_WRITE)); aclStatusBuilder.addEntries(aclSpec); Assert.assertEquals(jsonString, JsonUtil.toJsonString(aclStatusBuilder.build())); }
@Test public void testToJsonFromXAttrs() throws IOException { String jsonString = "{\"XAttrs\":[{\"name\":\"user.a1\",\"value\":\"0x313233\"}," + "{\"name\":\"user.a2\",\"value\":\"0x313131\"}]}"; XAttr xAttr1 = (new XAttr.Builder()).setNameSpace(XAttr.NameSpace.USER). setName("a1").setValue(XAttrCodec.decodeValue("0x313233")).build(); XAttr xAttr2 = (new XAttr.Builder()).setNameSpace(XAttr.NameSpace.USER). setName("a2").setValue(XAttrCodec.decodeValue("0x313131")).build(); List<XAttr> xAttrs = Lists.newArrayList(); xAttrs.add(xAttr1); xAttrs.add(xAttr2); Assert.assertEquals(jsonString, JsonUtil.toJsonString(xAttrs, XAttrCodec.HEX)); }