Commit f2d5f4a8 authored by jerrykcode's avatar jerrykcode

为WebUtils.encodeUrlFileName方法添加测试用例

parent 2177aed6
package cn.keking.utils;
import org.junit.jupiter.api.Test;
public class WebUtilsTests {
@Test
void encodeUrlFileNameTest() {
// 测试对URL中的文件名部分进行UTF-8编码
String in = "https://file.keking.cn/demo/hello#0.txt";
String out = "https://file.keking.cn/demo/hello%230.txt";
assert WebUtils.encodeUrlFileName(in).equals(out);
}
@Test
void encodeUrlFileNameTestWithParams() {
// 测试对URL中的文件名部分进行UTF-8编码
// URL带参数
// 文件名"#hello&world"中的"&"应该被编码成为"%26",而?后的参数列表中的"&"不会被编码
String in = "https://file.keking.cn/demo/#hello&world.txt?param0=0&param1=1";
String out = "https://file.keking.cn/demo/%23hello%26world.txt?param0=0&param1=1";
assert WebUtils.encodeUrlFileName(in).equals(out);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment