🎨 修复单元测试代码
Some checks failed
Publish to Maven Central / build-and-publish (push) Has been cancelled

This commit is contained in:
Binary Wang 2025-06-06 17:06:07 +08:00
parent 22d288f6cd
commit 8878f06c1e

View File

@ -1,16 +1,19 @@
package me.chanjar.weixin.common.util.http; package me.chanjar.weixin.common.util.http;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpResponseProxy;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import static org.testng.Assert.*; import static org.testng.Assert.*;
public class HttpResponseProxyTest { public class HttpResponseProxyTest {
public final ApacheHttpResponseProxy httpResponseProxy = new ApacheHttpResponseProxy(null);
@Test @Test
public void testExtractFileNameFromContentString() throws WxErrorException { public void testExtractFileNameFromContentString() throws WxErrorException {
String content = "attachment; filename*=utf-8''%E6%B5%8B%E8%AF%95.xlsx; filename=\"æµ<EFBFBD>è¯<EFBFBD>.xlsx\""; String content = "attachment; filename*=utf-8''%E6%B5%8B%E8%AF%95.xlsx; filename=\"æµ<EFBFBD>è¯<EFBFBD>.xlsx\"";
String filename = HttpResponseProxy.extractFileNameFromContentString(content); String filename = httpResponseProxy.extractFileNameFromContentString(content);
assertNotNull(filename); assertNotNull(filename);
assertEquals(filename, "测试.xlsx"); assertEquals(filename, "测试.xlsx");
} }
@ -19,7 +22,7 @@ public class HttpResponseProxyTest {
public void testExtractFileNameFromContentString_another() throws WxErrorException { public void testExtractFileNameFromContentString_another() throws WxErrorException {
String content = "attachment; filename*=utf-8''%E8%90%A5%E4%B8%9A%E6%89%A7%E7%85%A7.jpg; filename=\"è<EFBFBD>¥ä¸<EFBFBD>æ<EFBFBD>§ç<EFBFBD>§.jpg\""; String content = "attachment; filename*=utf-8''%E8%90%A5%E4%B8%9A%E6%89%A7%E7%85%A7.jpg; filename=\"è<EFBFBD>¥ä¸<EFBFBD>æ<EFBFBD>§ç<EFBFBD>§.jpg\"";
// String content = "attachment; filename=\"è<EFBFBD>¥ä¸<EFBFBD>æ<EFBFBD>§ç<EFBFBD>§.jpg\""; // String content = "attachment; filename=\"è<EFBFBD>¥ä¸<EFBFBD>æ<EFBFBD>§ç<EFBFBD>§.jpg\"";
String filename = HttpResponseProxy.extractFileNameFromContentString(content); String filename = httpResponseProxy.extractFileNameFromContentString(content);
assertNotNull(filename); assertNotNull(filename);
assertEquals(filename, "营业执照.jpg"); assertEquals(filename, "营业执照.jpg");
} }