### Question:
IdnaUtil { public static boolean isValidIdn(String domain) { if (domain == null || domain.isEmpty()) { return false; } try { return isValidIdnWithException(domain); } catch (Exception e) { logger.error("Idna validate failed :" + e); return false; } } private  IdnaUtil(); static boolean checkIfValidALabelDomain(String aLabelDomain); static boolean isValidIdn(String domain);  }### Answer:
@Test public void testIsValidIdn() { assertTrue(IdnaUtil.isValidIdn("cnnic.cn")); assertTrue(IdnaUtil.isValidIdn("cnnic")); assertTrue(IdnaUtil.isValidIdn("cnnic.com.cn")); assertTrue(IdnaUtil.isValidIdn("123")); assertTrue(IdnaUtil.isValidIdn("1cnnic.cn")); assertTrue(IdnaUtil .isValidIdn("63aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.cn")); assertTrue(IdnaUtil .isValidIdn("253aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); assertFalse(IdnaUtil .isValidIdn("254aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); assertFalse(IdnaUtil .isValidIdn("64aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.cn")); assertFalse(IdnaUtil.isValidIdn("")); assertFalse(IdnaUtil.isValidIdn(" ")); assertFalse(IdnaUtil.isValidIdn(null)); assertFalse(IdnaUtil.isValidIdn(".")); assertFalse(IdnaUtil.isValidIdn("Σ.cn")); assertFalse(IdnaUtil.isValidIdn("@.cn")); assertFalse(IdnaUtil.isValidIdn("a@.cn")); assertFalse(IdnaUtil.isValidIdn("@a.cn")); assertFalse(IdnaUtil.isValidIdn("cnnic.")); assertFalse(IdnaUtil.isValidIdn("cnnic-.cn")); assertFalse(IdnaUtil.isValidIdn("-cnnic.cn")); assertFalse(IdnaUtil.isValidIdn("boss.-cnnic.cn")); assertFalse(IdnaUtil.isValidIdn("boss.cnnic-.cn")); assertFalse(IdnaUtil.isValidIdn("boss.cnnic.-cn")); assertFalse(IdnaUtil.isValidIdn("boss.cnnic.cn-")); assertFalse(IdnaUtil.isValidIdn("cnnic.cn.")); assertFalse(IdnaUtil.isValidIdn("xn--55qx5d.中国")); assertFalse(IdnaUtil.isValidIdn("xn--55qx5d.中国.cn")); }