mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
add test
This commit is contained in:
parent
c0fdd353cd
commit
27e8aa6043
@ -3,10 +3,15 @@ package cn.hutool.core.net;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
import cn.hutool.core.net.url.UrlQuery;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class UrlQueryTest {
|
||||
|
||||
@ -43,4 +48,19 @@ public class UrlQueryTest {
|
||||
final UrlQuery query = UrlQuery.of(u, Charset.defaultCharset());
|
||||
Assert.assertTrue(MapUtil.isEmpty(query.getQueryMap()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildWithMapTest() {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("username", "SSM");
|
||||
map.put("password", "123456");
|
||||
String query = URLUtil.buildQuery(map, StandardCharsets.UTF_8);
|
||||
Assert.assertEquals("username=SSM&password=123456", query);
|
||||
|
||||
map = new TreeMap<>();
|
||||
map.put("username", "SSM");
|
||||
map.put("password", "123456");
|
||||
query = URLUtil.buildQuery(map, StandardCharsets.UTF_8);
|
||||
Assert.assertEquals("password=123456&username=SSM", query);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user