调整方法修饰符为public并添加junit测试例子

This commit is contained in:
zhaoxinhu 2022-08-18 09:02:43 +08:00
parent 914463b4d8
commit 331fd1f2bc
2 changed files with 10 additions and 2 deletions

View File

@ -30,7 +30,7 @@ public class PunyCode {
* @return
* @throws UtilException
*/
private static String encodeDomain(String domain) throws UtilException{
public static String encodeDomain(String domain) throws UtilException{
Assert.notNull(domain, "domain must not be null!");
String[] split = domain.split("\\.");
StringBuilder outStringBuilder = new StringBuilder();
@ -154,7 +154,7 @@ public class PunyCode {
* @return
* @throws UtilException
*/
private static String decodeDomain(String domain) throws UtilException{
public static String decodeDomain(String domain) throws UtilException{
Assert.notNull(domain, "domain must not be null!");
String[] split = domain.split("\\.");
StringBuilder outStringBuilder = new StringBuilder();

View File

@ -15,4 +15,12 @@ public class PunyCodeTest {
decode = PunyCode.decode("xn--Hutool-ux9js33tgln");
Assert.assertEquals(text, decode);
}
@Test
public void encodeEncodeDomainTest(){
String domain = "赵新虎.中国";
String strPunyCode = PunyCode.encodeDomain(domain);
String decode = PunyCode.decodeDomain(strPunyCode);
Assert.assertEquals(decode, domain);
}
}