mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-11 16:18:02 +08:00
调整方法修饰符为public并添加junit测试例子
This commit is contained in:
parent
914463b4d8
commit
331fd1f2bc
@ -30,7 +30,7 @@ public class PunyCode {
|
|||||||
* @return
|
* @return
|
||||||
* @throws UtilException
|
* @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!");
|
Assert.notNull(domain, "domain must not be null!");
|
||||||
String[] split = domain.split("\\.");
|
String[] split = domain.split("\\.");
|
||||||
StringBuilder outStringBuilder = new StringBuilder();
|
StringBuilder outStringBuilder = new StringBuilder();
|
||||||
@ -154,7 +154,7 @@ public class PunyCode {
|
|||||||
* @return
|
* @return
|
||||||
* @throws UtilException
|
* @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!");
|
Assert.notNull(domain, "domain must not be null!");
|
||||||
String[] split = domain.split("\\.");
|
String[] split = domain.split("\\.");
|
||||||
StringBuilder outStringBuilder = new StringBuilder();
|
StringBuilder outStringBuilder = new StringBuilder();
|
||||||
|
@ -15,4 +15,12 @@ public class PunyCodeTest {
|
|||||||
decode = PunyCode.decode("xn--Hutool-ux9js33tgln");
|
decode = PunyCode.decode("xn--Hutool-ux9js33tgln");
|
||||||
Assert.assertEquals(text, decode);
|
Assert.assertEquals(text, decode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void encodeEncodeDomainTest(){
|
||||||
|
String domain = "赵新虎.中国";
|
||||||
|
String strPunyCode = PunyCode.encodeDomain(domain);
|
||||||
|
String decode = PunyCode.decodeDomain(strPunyCode);
|
||||||
|
Assert.assertEquals(decode, domain);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user