This commit is contained in:
Looly
2021-11-07 02:34:03 +08:00
parent 065c6d61c8
commit a5adc9ae94
11 changed files with 71 additions and 36 deletions

View File

@@ -0,0 +1,17 @@
package cn.hutool.core.net;
import cn.hutool.core.util.CharsetUtil;
import org.junit.Assert;
import org.junit.Test;
public class FormUrlencodedTest {
@Test
public void encodeParamTest(){
String encode = FormUrlencoded.ALL.encode("a+b", CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals("a%2Bb", encode);
encode = FormUrlencoded.ALL.encode("a b", CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals("a+b", encode);
}
}

View File

@@ -0,0 +1,14 @@
package cn.hutool.core.net;
import cn.hutool.core.util.CharsetUtil;
import org.junit.Assert;
import org.junit.Test;
public class RFC3986Test {
@Test
public void encodeQueryTest(){
final String encode = RFC3986.QUERY_PARAM_VALUE.encode("a=b", CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals("a=b", encode);
}
}

View File

@@ -1,17 +0,0 @@
package cn.hutool.core.net;
import cn.hutool.core.util.CharsetUtil;
import org.junit.Assert;
import org.junit.Test;
public class URLEncoderTest {
@Test
public void encodeTest(){
String encode = URLEncoder.DEFAULT.encode("+", CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals("+", encode);
encode = URLEncoder.DEFAULT.encode(" ", CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals("%20", encode);
}
}