mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
update to junit5
This commit is contained in:
@@ -2,8 +2,8 @@ package cn.hutool.http;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.http.meta.ContentType;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* ContentType 单元测试
|
||||
@@ -14,6 +14,6 @@ public class ContentTypeTest {
|
||||
@Test
|
||||
public void testBuild() {
|
||||
final String result = ContentType.build(ContentType.JSON, CharsetUtil.UTF_8);
|
||||
Assert.assertEquals("application/json;charset=UTF-8", result);
|
||||
Assertions.assertEquals("application/json;charset=UTF-8", result);
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,17 @@
|
||||
package cn.hutool.http;
|
||||
|
||||
import cn.hutool.core.codec.binary.Base64;
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.StreamProgress;
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.http.client.HttpDownloader;
|
||||
import cn.hutool.http.client.Request;
|
||||
import cn.hutool.http.client.engine.ClientEngineFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
@@ -28,7 +28,7 @@ import java.util.UUID;
|
||||
public class DownloadTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadPicTest() {
|
||||
final String url = "http://wx.qlogo.cn/mmopen/vKhlFcibVUtNBVDjcIowlg0X8aJfHXrTNCEFBukWVH9ta99pfEN88lU39MKspCUCOP3yrFBH3y2NbV7sYtIIlon8XxLwAEqv2/0";
|
||||
HttpDownloader.downloadFile(url, new File("e:/pic/t3.jpg"));
|
||||
@@ -36,7 +36,7 @@ public class DownloadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadSizeTest() {
|
||||
final String url = "https://res.t-io.org/im/upload/img/67/8948/1119501/88097554/74541310922/85/231910/366466 - 副本.jpg";
|
||||
ClientEngineFactory.get().send(Request.of(url)).body().write("e:/pic/366466.jpg");
|
||||
@@ -44,14 +44,14 @@ public class DownloadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadTest1() {
|
||||
final File size = HttpDownloader.downloadFile("http://explorer.bbfriend.com/crossdomain.xml", new File("e:/temp/"));
|
||||
System.out.println("Download size: " + size);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadTest() {
|
||||
// 带进度显示的文件下载
|
||||
HttpDownloader.downloadFile("http://mirrors.sohu.com/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso", FileUtil.file("d:/"), -1, new StreamProgress() {
|
||||
@@ -77,16 +77,16 @@ public class DownloadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadFileFromUrlTest1() {
|
||||
final File file = HttpDownloader.downloadFile("http://groovy-lang.org/changelogs/changelog-3.0.5.html", new File("d:/download/temp"));
|
||||
Assert.assertNotNull(file);
|
||||
Assert.assertTrue(file.isFile());
|
||||
Assert.assertTrue(file.length() > 0);
|
||||
Assertions.assertNotNull(file);
|
||||
Assertions.assertTrue(file.isFile());
|
||||
Assertions.assertTrue(file.length() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadFileFromUrlTest2() {
|
||||
File file = null;
|
||||
try {
|
||||
@@ -107,20 +107,20 @@ public class DownloadTest {
|
||||
}
|
||||
});
|
||||
|
||||
Assert.assertNotNull(file);
|
||||
Assert.assertTrue(file.exists());
|
||||
Assert.assertTrue(file.isFile());
|
||||
Assert.assertTrue(file.length() > 0);
|
||||
Assert.assertTrue(file.getName().length() > 0);
|
||||
Assertions.assertNotNull(file);
|
||||
Assertions.assertTrue(file.exists());
|
||||
Assertions.assertTrue(file.isFile());
|
||||
Assertions.assertTrue(file.length() > 0);
|
||||
Assertions.assertTrue(file.getName().length() > 0);
|
||||
} catch (final Exception e) {
|
||||
Assert.assertTrue(e instanceof IORuntimeException);
|
||||
Assertions.assertTrue(e instanceof IORuntimeException);
|
||||
} finally {
|
||||
FileUtil.del(file);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadFileFromUrlTest3() {
|
||||
File file = null;
|
||||
try {
|
||||
@@ -141,30 +141,30 @@ public class DownloadTest {
|
||||
}
|
||||
});
|
||||
|
||||
Assert.assertNotNull(file);
|
||||
Assert.assertTrue(file.exists());
|
||||
Assert.assertTrue(file.isFile());
|
||||
Assert.assertTrue(file.length() > 0);
|
||||
Assert.assertTrue(file.getName().length() > 0);
|
||||
Assertions.assertNotNull(file);
|
||||
Assertions.assertTrue(file.exists());
|
||||
Assertions.assertTrue(file.isFile());
|
||||
Assertions.assertTrue(file.length() > 0);
|
||||
Assertions.assertTrue(file.getName().length() > 0);
|
||||
} finally {
|
||||
FileUtil.del(file);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadFileFromUrlTest4() {
|
||||
File file = null;
|
||||
try {
|
||||
file = HttpDownloader.downloadFile("http://groovy-lang.org/changelogs/changelog-3.0.5.html", FileUtil.file("d:/download/temp"), 1);
|
||||
|
||||
Assert.assertNotNull(file);
|
||||
Assert.assertTrue(file.exists());
|
||||
Assert.assertTrue(file.isFile());
|
||||
Assert.assertTrue(file.length() > 0);
|
||||
Assert.assertTrue(file.getName().length() > 0);
|
||||
Assertions.assertNotNull(file);
|
||||
Assertions.assertTrue(file.exists());
|
||||
Assertions.assertTrue(file.isFile());
|
||||
Assertions.assertTrue(file.length() > 0);
|
||||
Assertions.assertTrue(file.getName().length() > 0);
|
||||
} catch (final Exception e) {
|
||||
Assert.assertTrue(e instanceof IORuntimeException);
|
||||
Assertions.assertTrue(e instanceof IORuntimeException);
|
||||
} finally {
|
||||
FileUtil.del(file);
|
||||
}
|
||||
@@ -172,16 +172,16 @@ public class DownloadTest {
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadFileFromUrlTest5() {
|
||||
File file = null;
|
||||
try {
|
||||
file = HttpDownloader.downloadFile("http://groovy-lang.org/changelogs/changelog-3.0.5.html", FileUtil.file("d:/download/temp", UUID.randomUUID().toString()));
|
||||
|
||||
Assert.assertNotNull(file);
|
||||
Assert.assertTrue(file.exists());
|
||||
Assert.assertTrue(file.isFile());
|
||||
Assert.assertTrue(file.length() > 0);
|
||||
Assertions.assertNotNull(file);
|
||||
Assertions.assertTrue(file.exists());
|
||||
Assertions.assertTrue(file.isFile());
|
||||
Assertions.assertTrue(file.length() > 0);
|
||||
} finally {
|
||||
FileUtil.del(file);
|
||||
}
|
||||
@@ -190,17 +190,17 @@ public class DownloadTest {
|
||||
try {
|
||||
file1 = HttpDownloader.downloadFile("http://groovy-lang.org/changelogs/changelog-3.0.5.html", FileUtil.file("d:/download/temp"));
|
||||
|
||||
Assert.assertNotNull(file1);
|
||||
Assert.assertTrue(file1.exists());
|
||||
Assert.assertTrue(file1.isFile());
|
||||
Assert.assertTrue(file1.length() > 0);
|
||||
Assertions.assertNotNull(file1);
|
||||
Assertions.assertTrue(file1.exists());
|
||||
Assertions.assertTrue(file1.isFile());
|
||||
Assertions.assertTrue(file1.length() > 0);
|
||||
} finally {
|
||||
FileUtil.del(file1);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadTeamViewerTest() throws IOException {
|
||||
// 此URL有3次重定向, 需要请求4次
|
||||
final String url = "https://download.teamviewer.com/download/TeamViewer_Setup_x64.exe";
|
||||
@@ -211,7 +211,7 @@ public class DownloadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadToStreamTest() {
|
||||
String url2 = "http://storage.chancecloud.com.cn/20200413_%E7%B2%A4B12313_386.pdf";
|
||||
final ByteArrayOutputStream os2 = new ByteArrayOutputStream();
|
||||
@@ -222,7 +222,7 @@ public class DownloadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadStringTest() {
|
||||
final String url = "https://www.baidu.com";
|
||||
// 从远程直接读取字符串,需要自定义编码,直接调用JDK方法
|
||||
@@ -231,7 +231,7 @@ public class DownloadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void gimg2Test(){
|
||||
final byte[] bytes = HttpDownloader.downloadBytes("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.jj20.com%2Fup%2Fallimg%2F1114%2F0H320120Z3%2F200H3120Z3-6-1200.jpg&refer=http%3A%2F%2Fpic.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1621996490&t=8c384c2823ea453da15a1b9cd5183eea");
|
||||
Console.log(Base64.encode(bytes));
|
||||
|
@@ -3,8 +3,8 @@ package cn.hutool.http;
|
||||
import cn.hutool.core.regex.ReUtil;
|
||||
import cn.hutool.http.html.HtmlUtil;
|
||||
import cn.hutool.http.meta.ContentTypeUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Html单元测试
|
||||
@@ -19,32 +19,32 @@ public class HtmlUtilTest {
|
||||
//非闭合标签
|
||||
String str = "pre<img src=\"xxx/dfdsfds/test.jpg\">";
|
||||
String result = HtmlUtil.removeHtmlTag(str, "img");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//闭合标签
|
||||
str = "pre<img>";
|
||||
result = HtmlUtil.removeHtmlTag(str, "img");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//闭合标签
|
||||
str = "pre<img src=\"xxx/dfdsfds/test.jpg\" />";
|
||||
result = HtmlUtil.removeHtmlTag(str, "img");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//闭合标签
|
||||
str = "pre<img />";
|
||||
result = HtmlUtil.removeHtmlTag(str, "img");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//包含内容标签
|
||||
str = "pre<div class=\"test_div\">dfdsfdsfdsf</div>";
|
||||
result = HtmlUtil.removeHtmlTag(str, "div");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//带换行
|
||||
str = "pre<div class=\"test_div\">\r\n\t\tdfdsfdsfdsf\r\n</div>";
|
||||
result = HtmlUtil.removeHtmlTag(str, "div");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -52,32 +52,32 @@ public class HtmlUtilTest {
|
||||
//非闭合标签
|
||||
String str = "pre<img src=\"xxx/dfdsfds/test.jpg\">";
|
||||
String result = HtmlUtil.cleanHtmlTag(str);
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//闭合标签
|
||||
str = "pre<img>";
|
||||
result = HtmlUtil.cleanHtmlTag(str);
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//闭合标签
|
||||
str = "pre<img src=\"xxx/dfdsfds/test.jpg\" />";
|
||||
result = HtmlUtil.cleanHtmlTag(str);
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//闭合标签
|
||||
str = "pre<img />";
|
||||
result = HtmlUtil.cleanHtmlTag(str);
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//包含内容标签
|
||||
str = "pre<div class=\"test_div\">dfdsfdsfdsf</div>";
|
||||
result = HtmlUtil.cleanHtmlTag(str);
|
||||
Assert.assertEquals("predfdsfdsfdsf", result);
|
||||
Assertions.assertEquals("predfdsfdsfdsf", result);
|
||||
|
||||
//带换行
|
||||
str = "pre<div class=\"test_div\">\r\n\t\tdfdsfdsfdsf\r\n</div><div class=\"test_div\">BBBB</div>";
|
||||
result = HtmlUtil.cleanHtmlTag(str);
|
||||
Assert.assertEquals("pre\r\n\t\tdfdsfdsfdsf\r\nBBBB", result);
|
||||
Assertions.assertEquals("pre\r\n\t\tdfdsfdsfdsf\r\nBBBB", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,37 +85,37 @@ public class HtmlUtilTest {
|
||||
//非闭合标签
|
||||
String str = "pre<img src=\"xxx/dfdsfds/test.jpg\">";
|
||||
String result = HtmlUtil.unwrapHtmlTag(str, "img");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//闭合标签
|
||||
str = "pre<img>";
|
||||
result = HtmlUtil.unwrapHtmlTag(str, "img");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//闭合标签
|
||||
str = "pre<img src=\"xxx/dfdsfds/test.jpg\" />";
|
||||
result = HtmlUtil.unwrapHtmlTag(str, "img");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//闭合标签
|
||||
str = "pre<img />";
|
||||
result = HtmlUtil.unwrapHtmlTag(str, "img");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//闭合标签
|
||||
str = "pre<img/>";
|
||||
result = HtmlUtil.unwrapHtmlTag(str, "img");
|
||||
Assert.assertEquals("pre", result);
|
||||
Assertions.assertEquals("pre", result);
|
||||
|
||||
//包含内容标签
|
||||
str = "pre<div class=\"test_div\">abc</div>";
|
||||
result = HtmlUtil.unwrapHtmlTag(str, "div");
|
||||
Assert.assertEquals("preabc", result);
|
||||
Assertions.assertEquals("preabc", result);
|
||||
|
||||
//带换行
|
||||
str = "pre<div class=\"test_div\">\r\n\t\tabc\r\n</div>";
|
||||
result = HtmlUtil.unwrapHtmlTag(str, "div");
|
||||
Assert.assertEquals("pre\r\n\t\tabc\r\n", result);
|
||||
Assertions.assertEquals("pre\r\n\t\tabc\r\n", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,34 +124,34 @@ public class HtmlUtilTest {
|
||||
final String htmlString = "<html><img src='aaa'><i>测试文本</i></html>";
|
||||
final String tagString = "i,br";
|
||||
final String cleanTxt = HtmlUtil.removeHtmlTag(htmlString, false, tagString.split(","));
|
||||
Assert.assertEquals("<html><img src='aaa'>测试文本</html>", cleanTxt);
|
||||
Assertions.assertEquals("<html><img src='aaa'>测试文本</html>", cleanTxt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void escapeTest() {
|
||||
final String html = "<html><body>123'123'</body></html>";
|
||||
final String escape = HtmlUtil.escape(html);
|
||||
Assert.assertEquals("<html><body>123'123'</body></html>", escape);
|
||||
Assertions.assertEquals("<html><body>123'123'</body></html>", escape);
|
||||
final String restoreEscaped = HtmlUtil.unescape(escape);
|
||||
Assert.assertEquals(html, restoreEscaped);
|
||||
Assert.assertEquals("'", HtmlUtil.unescape("'"));
|
||||
Assertions.assertEquals(html, restoreEscaped);
|
||||
Assertions.assertEquals("'", HtmlUtil.unescape("'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void escapeTest2() {
|
||||
final char c = ' '; // 不断开空格(non-breaking space,缩写nbsp。)
|
||||
Assert.assertEquals(c, 160);
|
||||
Assertions.assertEquals(c, 160);
|
||||
final String html = "<html><body> </body></html>";
|
||||
final String escape = HtmlUtil.escape(html);
|
||||
Assert.assertEquals("<html><body> </body></html>", escape);
|
||||
Assert.assertEquals(" ", HtmlUtil.unescape(" "));
|
||||
Assertions.assertEquals("<html><body> </body></html>", escape);
|
||||
Assertions.assertEquals(" ", HtmlUtil.unescape(" "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterTest() {
|
||||
final String html = "<alert></alert>";
|
||||
final String filter = HtmlUtil.filter(html);
|
||||
Assert.assertEquals("", filter);
|
||||
Assertions.assertEquals("", filter);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,43 +160,43 @@ public class HtmlUtilTest {
|
||||
// 去除的属性加双引号测试
|
||||
String html = "<div class=\"test_div\"></div><span class=\"test_div\"></span>";
|
||||
String result = HtmlUtil.removeHtmlAttr(html, "class");
|
||||
Assert.assertEquals("<div></div><span></span>", result);
|
||||
Assertions.assertEquals("<div></div><span></span>", result);
|
||||
|
||||
// 去除的属性后跟空格、加单引号、不加引号测试
|
||||
html = "<div class=test_div></div><span Class='test_div' ></span>";
|
||||
result = HtmlUtil.removeHtmlAttr(html, "class");
|
||||
Assert.assertEquals("<div></div><span></span>", result);
|
||||
Assertions.assertEquals("<div></div><span></span>", result);
|
||||
|
||||
// 去除的属性位于标签末尾、其它属性前测试
|
||||
html = "<div style=\"margin:100%\" class=test_div></div><span Class='test_div' width=100></span>";
|
||||
result = HtmlUtil.removeHtmlAttr(html, "class");
|
||||
Assert.assertEquals("<div style=\"margin:100%\"></div><span width=100></span>", result);
|
||||
Assertions.assertEquals("<div style=\"margin:100%\"></div><span width=100></span>", result);
|
||||
|
||||
// 去除的属性名和值之间存在空格
|
||||
html = "<div style = \"margin:100%\" class = test_div></div><span Class = 'test_div' width=100></span>";
|
||||
result = HtmlUtil.removeHtmlAttr(html, "class");
|
||||
Assert.assertEquals("<div style = \"margin:100%\"></div><span width=100></span>", result);
|
||||
Assertions.assertEquals("<div style = \"margin:100%\"></div><span width=100></span>", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeAllHtmlAttrTest() {
|
||||
final String html = "<div class=\"test_div\" width=\"120\"></div>";
|
||||
final String result = HtmlUtil.removeAllHtmlAttr(html, "div");
|
||||
Assert.assertEquals("<div></div>", result);
|
||||
Assertions.assertEquals("<div></div>", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCharsetTest() {
|
||||
String charsetName = ReUtil.get(ContentTypeUtil.CHARSET_PATTERN, "Charset=UTF-8;fq=0.9", 1);
|
||||
Assert.assertEquals("UTF-8", charsetName);
|
||||
Assertions.assertEquals("UTF-8", charsetName);
|
||||
|
||||
charsetName = ReUtil.get(HtmlUtil.META_CHARSET_PATTERN, "<meta charset=utf-8", 1);
|
||||
Assert.assertEquals("utf-8", charsetName);
|
||||
Assertions.assertEquals("utf-8", charsetName);
|
||||
charsetName = ReUtil.get(HtmlUtil.META_CHARSET_PATTERN, "<meta charset='utf-8'", 1);
|
||||
Assert.assertEquals("utf-8", charsetName);
|
||||
Assertions.assertEquals("utf-8", charsetName);
|
||||
charsetName = ReUtil.get(HtmlUtil.META_CHARSET_PATTERN, "<meta charset=\"utf-8\"", 1);
|
||||
Assert.assertEquals("utf-8", charsetName);
|
||||
Assertions.assertEquals("utf-8", charsetName);
|
||||
charsetName = ReUtil.get(HtmlUtil.META_CHARSET_PATTERN, "<meta charset = \"utf-8\"", 1);
|
||||
Assert.assertEquals("utf-8", charsetName);
|
||||
Assertions.assertEquals("utf-8", charsetName);
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ package cn.hutool.http;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.StopWatch;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
@@ -11,8 +10,9 @@ import cn.hutool.http.client.Request;
|
||||
import cn.hutool.http.client.Response;
|
||||
import cn.hutool.http.meta.Header;
|
||||
import cn.hutool.http.meta.Method;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -29,7 +29,7 @@ public class HttpRequestTest {
|
||||
final String url = "http://photo.qzone.qq.com/fcgi-bin/fcg_list_album?uin=88888&outstyle=2";
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getHttpsThenTest() {
|
||||
Request.of("https://hutool.cn")
|
||||
.send()
|
||||
@@ -37,7 +37,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getCookiesTest() {
|
||||
// 检查在Connection关闭情况下Cookie是否可以正常获取
|
||||
final Response res = Request.of("https://www.oschina.net/").send();
|
||||
@@ -47,7 +47,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void toStringTest() {
|
||||
final String url = "http://gc.ditu.aliyun.com/geocoding?ccc=你好";
|
||||
|
||||
@@ -56,7 +56,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void asyncHeadTest() {
|
||||
final Response response = Request.of(url).method(Method.HEAD).send();
|
||||
final Map<String, List<String>> headers = response.headers();
|
||||
@@ -65,7 +65,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void asyncGetTest() {
|
||||
final StopWatch timer = DateUtil.createStopWatch();
|
||||
timer.start();
|
||||
@@ -80,7 +80,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void syncGetTest() {
|
||||
final StopWatch timer = DateUtil.createStopWatch();
|
||||
timer.start();
|
||||
@@ -96,7 +96,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getDeflateTest() {
|
||||
final Response res = Request.of("https://comment.bilibili.com/67573272.xml")
|
||||
.header(Header.ACCEPT_ENCODING, "deflate")
|
||||
@@ -106,7 +106,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void bodyTest() {
|
||||
final String ddddd1 = Request.of("https://baijiahao.baidu.com/s").body("id=1625528941695652600").send().bodyStr();
|
||||
Console.log(ddddd1);
|
||||
@@ -116,7 +116,7 @@ public class HttpRequestTest {
|
||||
* 测试GET请求附带body体是否会变更为POST
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getLocalTest() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
list.add("hhhhh");
|
||||
@@ -135,7 +135,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getWithoutEncodeTest() {
|
||||
final String url = "https://img-cloud.voc.com.cn/140/2020/09/03/c3d41b93e0d32138574af8e8b50928b376ca5ba61599127028157.png?imageMogr2/auto-orient/thumbnail/500&pid=259848";
|
||||
final Request get = Request.of(url);
|
||||
@@ -145,7 +145,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void followRedirectsTest() {
|
||||
// 从5.7.19开始关闭JDK的自动重定向功能,改为手动重定向
|
||||
// 当有多层重定向时,JDK的重定向会失效,或者说只有最后一个重定向有效,因此改为手动更易控制次数
|
||||
@@ -164,7 +164,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getWithFormTest(){
|
||||
final String url = "https://postman-echo.com/get";
|
||||
final Map<String, Object> map = new HashMap<>();
|
||||
@@ -174,7 +174,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void urlWithParamIfGetTest(){
|
||||
final UrlBuilder urlBuilder = new UrlBuilder();
|
||||
urlBuilder.setScheme("https").setHost("hutool.cn");
|
||||
@@ -184,7 +184,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getCookieTest(){
|
||||
final Response execute = Request.of("http://localhost:8888/getCookier").send();
|
||||
Console.log(execute.getCookieStr());
|
||||
@@ -193,25 +193,25 @@ public class HttpRequestTest {
|
||||
@Test
|
||||
public void optionsTest() {
|
||||
final Request options = Request.of("https://hutool.cn").method(Method.OPTIONS);
|
||||
Assert.notNull(options.toString());
|
||||
Assertions.assertNotNull(options.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteTest() {
|
||||
final Request options = Request.of("https://hutool.cn").method(Method.DELETE);
|
||||
Assert.notNull(options.toString());
|
||||
Assertions.assertNotNull(options.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceTest() {
|
||||
final Request options = Request.of("https://hutool.cn").method(Method.TRACE);
|
||||
Assert.notNull(options.toString());
|
||||
Assertions.assertNotNull(options.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getToStringTest() {
|
||||
final Request a = Request.of("https://hutool.cn/").form(MapUtil.of("a", 1));
|
||||
Assert.notNull(a.toString());
|
||||
Assertions.assertNotNull(a.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -221,7 +221,7 @@ public class HttpRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void issueI5Y68WTest() {
|
||||
final Response httpResponse = Request.of("http://82.157.17.173:8100/app/getAddress").send();
|
||||
Console.log(httpResponse.body());
|
||||
|
@@ -7,9 +7,9 @@ import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.http.client.Request;
|
||||
import cn.hutool.http.meta.Header;
|
||||
import cn.hutool.http.meta.Method;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -20,21 +20,21 @@ public class HttpUtilTest {
|
||||
|
||||
@Test
|
||||
public void isHttpTest(){
|
||||
Assert.assertTrue(HttpUtil.isHttp("Http://aaa.bbb"));
|
||||
Assert.assertTrue(HttpUtil.isHttp("HTTP://aaa.bbb"));
|
||||
Assert.assertFalse(HttpUtil.isHttp("FTP://aaa.bbb"));
|
||||
Assertions.assertTrue(HttpUtil.isHttp("Http://aaa.bbb"));
|
||||
Assertions.assertTrue(HttpUtil.isHttp("HTTP://aaa.bbb"));
|
||||
Assertions.assertFalse(HttpUtil.isHttp("FTP://aaa.bbb"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isHttpsTest(){
|
||||
Assert.assertTrue(HttpUtil.isHttps("Https://aaa.bbb"));
|
||||
Assert.assertTrue(HttpUtil.isHttps("HTTPS://aaa.bbb"));
|
||||
Assert.assertTrue(HttpUtil.isHttps("https://aaa.bbb"));
|
||||
Assert.assertFalse(HttpUtil.isHttps("ftp://aaa.bbb"));
|
||||
Assertions.assertTrue(HttpUtil.isHttps("Https://aaa.bbb"));
|
||||
Assertions.assertTrue(HttpUtil.isHttps("HTTPS://aaa.bbb"));
|
||||
Assertions.assertTrue(HttpUtil.isHttps("https://aaa.bbb"));
|
||||
Assertions.assertFalse(HttpUtil.isHttps("ftp://aaa.bbb"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void postTest2() {
|
||||
// 某些接口对Accept头有特殊要求,此处自定义头
|
||||
final String result = HttpUtil.send(Request
|
||||
@@ -45,14 +45,14 @@ public class HttpUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest() {
|
||||
final String result1 = HttpUtil.get("http://photo.qzone.qq.com/fcgi-bin/fcg_list_album?uin=88888&outstyle=2", CharsetUtil.GBK);
|
||||
Console.log(result1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest2() {
|
||||
// 此链接较为特殊,User-Agent去掉后进入一个JS跳转页面,如果设置了,需要开启302跳转
|
||||
// 自定义的默认header无效
|
||||
@@ -63,7 +63,7 @@ public class HttpUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest3() {
|
||||
// 测试url中带有空格的情况
|
||||
final String result1 = HttpUtil.get("http://hutool.cn:5000/kf?abc= d");
|
||||
@@ -71,7 +71,7 @@ public class HttpUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest4() {
|
||||
// 测试url中带有空格的情况
|
||||
final byte[] str = Request.of("http://img01.fs.yiban.cn/mobile/2D0Y71").send().bodyBytes();
|
||||
@@ -81,14 +81,14 @@ public class HttpUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void get12306Test() {
|
||||
HttpUtil.send(Request.of("https://kyfw.12306.cn/otn/").setMaxRedirectCount(2))
|
||||
.then(response -> Console.log(response.bodyStr()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void oschinaTest() {
|
||||
// 请求列表页
|
||||
String listContent = HttpUtil.get("https://www.oschina.net/action/ajax/get_more_news_list?newsType=&p=2");
|
||||
@@ -105,7 +105,7 @@ public class HttpUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Ignore
|
||||
//@Disabled
|
||||
public void patchTest() {
|
||||
// 验证patch请求是否可用
|
||||
final String body = HttpUtil.send(Request.of("https://hutool.cn").method(Method.PATCH)).bodyStr();
|
||||
@@ -126,18 +126,18 @@ public class HttpUtilTest {
|
||||
param.put("Version", "1.0");
|
||||
|
||||
String urlWithForm = HttpUtil.urlWithForm("http://api.hutool.cn/login?type=aaa", param, CharsetUtil.UTF_8, false);
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
"http://api.hutool.cn/login?type=aaa&AccessKeyId=123&Action=DescribeDomainRecords&Format=date&DomainName=lesper.cn&SignatureMethod=POST&SignatureNonce=123&SignatureVersion=4.3.1&Timestamp=123432453&Version=1.0",
|
||||
urlWithForm);
|
||||
|
||||
urlWithForm = HttpUtil.urlWithForm("http://api.hutool.cn/login?type=aaa", param, CharsetUtil.UTF_8, false);
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
"http://api.hutool.cn/login?type=aaa&AccessKeyId=123&Action=DescribeDomainRecords&Format=date&DomainName=lesper.cn&SignatureMethod=POST&SignatureNonce=123&SignatureVersion=4.3.1&Timestamp=123432453&Version=1.0",
|
||||
urlWithForm);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getWeixinTest(){
|
||||
// 测试特殊URL,即URL中有&情况是否请求正常
|
||||
final String url = "https://mp.weixin.qq.com/s?__biz=MzI5NjkyNTIxMg==&mid=100000465&idx=1&sn=1044c0d19723f74f04f4c1da34eefa35&chksm=6cbda3a25bca2ab4516410db6ce6e125badaac2f8c5548ea6e18eab6dc3c5422cb8cbe1095f7";
|
||||
@@ -146,7 +146,7 @@ public class HttpUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getNocovTest(){
|
||||
final String url = "https://qiniu.nocov.cn/medical-manage%2Ftest%2FBANNER_IMG%2F444004467954556928%2F1595215173047icon.png~imgReduce?e=1597081986&token=V2lJYVgQgAv_sbypfEZ0qpKs6TzD1q5JIDVr0Tw8:89cbBkLLwEc9JsMoCLkAEOu820E=";
|
||||
final String s = HttpUtil.get(url);
|
||||
@@ -154,21 +154,21 @@ public class HttpUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void sinajsTest(){
|
||||
final String s = HttpUtil.get("http://hq.sinajs.cn/list=sh600519");
|
||||
Console.log(s);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void acplayTest(){
|
||||
final String body = HttpUtil.send(Request.of("https://api.acplay.net/api/v2/bangumi/9541")).bodyStr();
|
||||
Console.log(body);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getPicTest(){
|
||||
HttpGlobalConfig.setDecodeUrl(false);
|
||||
final String url = "https://p3-sign.douyinpic.com/tos-cn-i-0813/f41afb2e79a94dcf80970affb9a69415~noop.webp?x-expires=1647738000&x-signature=%2Br1ekUCGjXiu50Y%2Bk0MO4ovulK8%3D&from=4257465056&s=PackSourceEnum_DOUYIN_REFLOW&se=false&sh=&sc=&l=2022021809224601020810013524310DD3&biz_tag=aweme_images";
|
||||
|
@@ -2,8 +2,8 @@ package cn.hutool.http;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class HttpsTest {
|
||||
* 测试单例的SSLSocketFactory是否有线程安全问题
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest() {
|
||||
final AtomicInteger count = new AtomicInteger();
|
||||
for(int i =0; i < 100; i++){
|
||||
|
@@ -5,9 +5,9 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
import cn.hutool.http.client.Request;
|
||||
import cn.hutool.http.client.Response;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -15,7 +15,7 @@ import java.util.Map;
|
||||
public class Issue2531Test {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest(){
|
||||
final Map<String,String> map = new HashMap<>();
|
||||
map.put("str","+123");
|
||||
@@ -34,14 +34,14 @@ public class Issue2531Test {
|
||||
public void encodePlusTest(){
|
||||
// 根据RFC3986规范,在URL中,"+"是安全字符,所以不会解码也不会编码
|
||||
UrlBuilder builder = UrlBuilder.ofHttp("https://hutool.cn/a=+");
|
||||
Assert.assertEquals("https://hutool.cn/a=+", builder.toString());
|
||||
Assertions.assertEquals("https://hutool.cn/a=+", builder.toString());
|
||||
|
||||
// 由于+为安全字符无需编码,ofHttp方法会把%2B解码为+,但是编码的时候不会编码
|
||||
builder = UrlBuilder.ofHttp("https://hutool.cn/a=%2B");
|
||||
Assert.assertEquals("https://hutool.cn/a=+", builder.toString());
|
||||
Assertions.assertEquals("https://hutool.cn/a=+", builder.toString());
|
||||
|
||||
// 如果你不想解码%2B,则charset传null表示不做解码,编码时候也被忽略
|
||||
builder = UrlBuilder.ofHttp("https://hutool.cn/a=%2B", null);
|
||||
Assert.assertEquals("https://hutool.cn/a=%2B", builder.toString());
|
||||
Assertions.assertEquals("https://hutool.cn/a=%2B", builder.toString());
|
||||
}
|
||||
}
|
||||
|
@@ -9,13 +9,13 @@ import cn.hutool.http.client.Response;
|
||||
import cn.hutool.http.client.body.ResourceBody;
|
||||
import cn.hutool.http.meta.ContentType;
|
||||
import cn.hutool.http.meta.Method;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class Issue2901Test {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void bodyTest() {
|
||||
// 自定义请求体,请求体作为资源读取,解决一次性读取到内存的问题
|
||||
final Response res = Request.of("http://localhost:8888/restTest")
|
||||
|
@@ -1,13 +1,13 @@
|
||||
package cn.hutool.http;
|
||||
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class IssueI5TFPUTest {
|
||||
@Test
|
||||
public void urlBuilderTest() {
|
||||
final UrlBuilder urlBuilder = UrlBuilder.of("https://hutool.cn", null).addQuery("opt", "%");
|
||||
Assert.assertEquals("https://hutool.cn?opt=%", urlBuilder.toString());
|
||||
Assertions.assertEquals("https://hutool.cn?opt=%", urlBuilder.toString());
|
||||
}
|
||||
}
|
||||
|
@@ -4,13 +4,13 @@ import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.http.client.Request;
|
||||
import cn.hutool.http.client.Response;
|
||||
import cn.hutool.http.meta.Header;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class IssueI5TPSYTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void redirectTest() {
|
||||
final String url = "https://bsxt.gdzwfw.gov.cn/UnifiedReporting/auth/newIndex";
|
||||
final Response res = HttpUtil.send(Request.of(url)
|
||||
|
@@ -2,8 +2,8 @@ package cn.hutool.http;
|
||||
|
||||
import cn.hutool.http.client.Request;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
public class IssueI5WAV4Test {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest(){
|
||||
//测试代码
|
||||
final Map<String, Object> map = new HashMap<>();
|
||||
|
@@ -5,13 +5,13 @@ import cn.hutool.http.client.Request;
|
||||
import cn.hutool.http.client.Response;
|
||||
import cn.hutool.http.meta.Header;
|
||||
import org.brotli.dec.BrotliInputStream;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class IssueI5XBCFTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest() {
|
||||
GlobalCompressStreamRegister.INSTANCE.register("br", BrotliInputStream.class);
|
||||
|
||||
|
@@ -5,9 +5,9 @@ import cn.hutool.http.client.Request;
|
||||
import cn.hutool.http.meta.Header;
|
||||
import cn.hutool.http.meta.Method;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Rest类型请求单元测试
|
||||
@@ -24,12 +24,12 @@ public class RestTest {
|
||||
.body(JSONUtil.ofObj()
|
||||
.set("aaa", "aaaValue")
|
||||
.set("键2", "值2").toString());
|
||||
Assert.assertEquals("application/json;charset=UTF-8", request.header(Header.CONTENT_TYPE));
|
||||
Assertions.assertEquals("application/json;charset=UTF-8", request.header(Header.CONTENT_TYPE));
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void postTest() {
|
||||
final Request request = Request.of("http://localhost:8090/rest/restTest/")
|
||||
.method(Method.POST)
|
||||
@@ -40,7 +40,7 @@ public class RestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void postTest2() {
|
||||
final String result = HttpUtil.post("http://localhost:8090/rest/restTest/", JSONUtil.ofObj()//
|
||||
.set("aaa", "aaaValue")
|
||||
@@ -49,7 +49,7 @@ public class RestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getWithBodyTest() {
|
||||
final Request request = Request.of("http://localhost:8888/restTest")//
|
||||
.header(Header.CONTENT_TYPE, "application/json")
|
||||
|
@@ -8,8 +8,8 @@ import cn.hutool.http.client.Request;
|
||||
import cn.hutool.http.client.Response;
|
||||
import cn.hutool.http.meta.Header;
|
||||
import cn.hutool.http.meta.Method;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
@@ -26,7 +26,7 @@ public class UploadTest {
|
||||
* 多文件上传测试
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void uploadFilesTest() {
|
||||
final File file = FileUtil.file("d:\\图片1.JPG");
|
||||
final File file2 = FileUtil.file("d:\\图片3.png");
|
||||
@@ -47,7 +47,7 @@ public class UploadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void uploadFileTest() {
|
||||
final File file = FileUtil.file("D:\\face.jpg");
|
||||
|
||||
@@ -60,7 +60,7 @@ public class UploadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void smmsTest(){
|
||||
// https://github.com/dromara/hutool/issues/2079
|
||||
// hutool的user agent 被封了
|
||||
|
@@ -1,13 +1,13 @@
|
||||
package cn.hutool.http.client;
|
||||
|
||||
import cn.hutool.http.client.engine.ClientEngineFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ClientEngineFactoryTest {
|
||||
@Test
|
||||
public void getTest() {
|
||||
final ClientEngine clientEngineFactory = ClientEngineFactory.get();
|
||||
Assert.assertNotNull(clientEngineFactory);
|
||||
Assertions.assertNotNull(clientEngineFactory);
|
||||
}
|
||||
}
|
||||
|
@@ -3,14 +3,14 @@ package cn.hutool.http.client;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.http.client.engine.httpclient4.HttpClient4Engine;
|
||||
import cn.hutool.http.meta.Method;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class HttpClient4EngineTest {
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest() {
|
||||
final ClientEngine engine = new HttpClient4Engine();
|
||||
|
||||
|
@@ -3,14 +3,14 @@ package cn.hutool.http.client;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.http.client.engine.httpclient5.HttpClient5Engine;
|
||||
import cn.hutool.http.meta.Method;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class HttpClient5EngineTest {
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest() {
|
||||
final ClientEngine engine = new HttpClient5Engine();
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.http.client;
|
||||
|
||||
import cn.hutool.http.client.engine.jdk.HttpUrlConnectionUtil;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class HttpUrlConnectionUtilTest {
|
||||
@Test
|
||||
|
@@ -3,13 +3,13 @@ package cn.hutool.http.client;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.http.client.engine.jdk.JdkClientEngine;
|
||||
import cn.hutool.http.meta.Method;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class JdkEngineTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest(){
|
||||
final ClientEngine engine = new JdkClientEngine();
|
||||
|
||||
|
@@ -3,14 +3,14 @@ package cn.hutool.http.client;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.http.client.engine.okhttp.OkHttpEngine;
|
||||
import cn.hutool.http.meta.Method;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class OkHttpEngineTest {
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getTest(){
|
||||
final ClientEngine engine = new OkHttpEngine();
|
||||
|
||||
|
@@ -3,8 +3,8 @@ package cn.hutool.http.client.body;
|
||||
import cn.hutool.core.io.resource.HttpResource;
|
||||
import cn.hutool.core.io.resource.StringResource;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -22,7 +22,7 @@ public class MultipartBodyTest {
|
||||
|
||||
final MultipartBody body = MultipartBody.of(form, CharsetUtil.UTF_8);
|
||||
|
||||
Assert.assertNotNull(body.toString());
|
||||
Assertions.assertNotNull(body.toString());
|
||||
// Console.log(body);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.http.useragent;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class UserAgentUtilTest {
|
||||
|
||||
@@ -10,14 +10,14 @@ public class UserAgentUtilTest {
|
||||
final String uaStr = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1";
|
||||
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("Chrome", ua.getBrowser().toString());
|
||||
Assert.assertEquals("14.0.835.163", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("535.1", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 7 or Windows Server 2008R2", ua.getOs().toString());
|
||||
Assert.assertEquals("6.1", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("Chrome", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("14.0.835.163", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("535.1", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 7 or Windows Server 2008R2", ua.getOs().toString());
|
||||
Assertions.assertEquals("6.1", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -25,182 +25,182 @@ public class UserAgentUtilTest {
|
||||
final String uaStr = "User-Agent:Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5";
|
||||
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("Safari", ua.getBrowser().toString());
|
||||
Assert.assertEquals("5.0.2", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("533.17.9", ua.getEngineVersion());
|
||||
Assert.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assert.assertEquals("4_3_3", ua.getOsVersion());
|
||||
Assert.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("Safari", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("5.0.2", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("533.17.9", ua.getEngineVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assertions.assertEquals("4_3_3", ua.getOsVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMiui10WithChromeTest() {
|
||||
final String uaStr = "Mozilla/5.0 (Linux; Android 9; MIX 3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.80 Mobile Safari/537.36";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("Chrome", ua.getBrowser().toString());
|
||||
Assert.assertEquals("70.0.3538.80", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Android", ua.getOs().toString());
|
||||
Assert.assertEquals("9", ua.getOsVersion());
|
||||
Assert.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("Chrome", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("70.0.3538.80", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Android", ua.getOs().toString());
|
||||
Assertions.assertEquals("9", ua.getOsVersion());
|
||||
Assertions.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseHuaweiPhoneWithNativeBrowserTest() {
|
||||
final String uaString = "Mozilla/5.0 (Linux; Android 10; EML-AL00 Build/HUAWEIEML-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("Android Browser", ua.getBrowser().toString());
|
||||
Assert.assertEquals("4.0", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Android", ua.getOs().toString());
|
||||
Assert.assertEquals("10", ua.getOsVersion());
|
||||
Assert.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("Android Browser", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("4.0", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Android", ua.getOs().toString());
|
||||
Assertions.assertEquals("10", ua.getOsVersion());
|
||||
Assertions.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseSamsungPhoneWithNativeBrowserTest() {
|
||||
final String uaString = "Dalvik/2.1.0 (Linux; U; Android 9; SM-G950U Build/PPR1.180610.011)";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("Android Browser", ua.getBrowser().toString());
|
||||
Assert.assertNull(ua.getVersion());
|
||||
Assert.assertEquals("Unknown", ua.getEngine().toString());
|
||||
Assert.assertNull(ua.getEngineVersion());
|
||||
Assert.assertEquals("Android", ua.getOs().toString());
|
||||
Assert.assertEquals("9", ua.getOsVersion());
|
||||
Assert.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("Android Browser", ua.getBrowser().toString());
|
||||
Assertions.assertNull(ua.getVersion());
|
||||
Assertions.assertEquals("Unknown", ua.getEngine().toString());
|
||||
Assertions.assertNull(ua.getEngineVersion());
|
||||
Assertions.assertEquals("Android", ua.getOs().toString());
|
||||
Assertions.assertEquals("9", ua.getOsVersion());
|
||||
Assertions.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWindows10WithChromeTest() {
|
||||
final String uaStr = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("Chrome", ua.getBrowser().toString());
|
||||
Assert.assertEquals("70.0.3538.102", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assert.assertEquals("10.0", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("Chrome", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("70.0.3538.102", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assertions.assertEquals("10.0", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWindows10WithIe11Test() {
|
||||
final String uaStr = "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("MSIE11", ua.getBrowser().toString());
|
||||
Assert.assertEquals("11.0", ua.getVersion());
|
||||
Assert.assertEquals("Trident", ua.getEngine().toString());
|
||||
Assert.assertEquals("7.0", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assert.assertEquals("10.0", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("MSIE11", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("11.0", ua.getVersion());
|
||||
Assertions.assertEquals("Trident", ua.getEngine().toString());
|
||||
Assertions.assertEquals("7.0", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assertions.assertEquals("10.0", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWindows10WithIeMobileLumia520Test() {
|
||||
final String uaStr = "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 520) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537 ";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("IEMobile", ua.getBrowser().toString());
|
||||
Assert.assertEquals("11.0", ua.getVersion());
|
||||
Assert.assertEquals("Trident", ua.getEngine().toString());
|
||||
Assert.assertEquals("7.0", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows Phone", ua.getOs().toString());
|
||||
Assert.assertEquals("8.1", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows Phone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("IEMobile", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("11.0", ua.getVersion());
|
||||
Assertions.assertEquals("Trident", ua.getEngine().toString());
|
||||
Assertions.assertEquals("7.0", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows Phone", ua.getOs().toString());
|
||||
Assertions.assertEquals("8.1", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows Phone", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWindows10WithIe8EmulatorTest() {
|
||||
final String uaStr = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("MSIE", ua.getBrowser().toString());
|
||||
Assert.assertEquals("8.0", ua.getVersion());
|
||||
Assert.assertEquals("Trident", ua.getEngine().toString());
|
||||
Assert.assertEquals("4.0", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 7 or Windows Server 2008R2", ua.getOs().toString());
|
||||
Assert.assertEquals("6.1", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("MSIE", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("8.0", ua.getVersion());
|
||||
Assertions.assertEquals("Trident", ua.getEngine().toString());
|
||||
Assertions.assertEquals("4.0", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 7 or Windows Server 2008R2", ua.getOs().toString());
|
||||
Assertions.assertEquals("6.1", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWindows10WithEdgeTest() {
|
||||
final String uaStr = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("MSEdge", ua.getBrowser().toString());
|
||||
Assert.assertEquals("18.17763", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assert.assertEquals("10.0", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("MSEdge", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("18.17763", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assertions.assertEquals("10.0", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseEdgeOnLumia950XLTest() {
|
||||
final String uaStr = "Mozilla/5.0 (Windows Phone 10.0; Android 6.0.1; Microsoft; Lumia 950XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Mobile Safari/537.36 Edge/15.14900";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("MSEdge", ua.getBrowser().toString());
|
||||
Assert.assertEquals("15.14900", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows Phone", ua.getOs().toString());
|
||||
Assert.assertEquals("10.0", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows Phone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("MSEdge", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("15.14900", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows Phone", ua.getOs().toString());
|
||||
Assertions.assertEquals("10.0", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows Phone", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseChromeOnWindowsServer2012R2Test() {
|
||||
final String uaStr = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("Chrome", ua.getBrowser().toString());
|
||||
Assert.assertEquals("63.0.3239.132", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 8.1 or Windows Server 2012R2", ua.getOs().toString());
|
||||
Assert.assertEquals("6.3", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("Chrome", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("63.0.3239.132", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 8.1 or Windows Server 2012R2", ua.getOs().toString());
|
||||
Assertions.assertEquals("6.3", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseIE11OnWindowsServer2008R2Test() {
|
||||
final String uaStr = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("MSIE11", ua.getBrowser().toString());
|
||||
Assert.assertEquals("11.0", ua.getVersion());
|
||||
Assert.assertEquals("Trident", ua.getEngine().toString());
|
||||
Assert.assertEquals("7.0", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 7 or Windows Server 2008R2", ua.getOs().toString());
|
||||
Assert.assertEquals("6.1", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("MSIE11", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("11.0", ua.getVersion());
|
||||
Assertions.assertEquals("Trident", ua.getEngine().toString());
|
||||
Assertions.assertEquals("7.0", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 7 or Windows Server 2008R2", ua.getOs().toString());
|
||||
Assertions.assertEquals("6.1", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseEdgeTest() {
|
||||
final String uaStr = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.69 Safari/537.36 Edg/81.0.416.34";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("MSEdge", ua.getBrowser().toString());
|
||||
Assert.assertEquals("81.0.416.34", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assert.assertEquals("10.0", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("MSEdge", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("81.0.416.34", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assertions.assertEquals("10.0", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,153 +210,153 @@ public class UserAgentUtilTest {
|
||||
public void parseMicroMessengerTest() {
|
||||
final String uaString = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Mobile/15A372 MicroMessenger/7.0.17(0x17001127) NetType/WIFI Language/zh_CN";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("MicroMessenger", ua.getBrowser().toString());
|
||||
Assert.assertEquals("7.0.17", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("604.1.38", ua.getEngineVersion());
|
||||
Assert.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assert.assertEquals("11_0", ua.getOsVersion());
|
||||
Assert.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("MicroMessenger", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("7.0.17", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("604.1.38", ua.getEngineVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assertions.assertEquals("11_0", ua.getOsVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWorkWxTest() {
|
||||
final String uaString = "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 wxwork/3.0.31 MicroMessenger/7.0.1 Language/zh";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("wxwork", ua.getBrowser().toString());
|
||||
Assert.assertEquals("3.0.31", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("605.1.15", ua.getEngineVersion());
|
||||
Assert.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assert.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("wxwork", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("3.0.31", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("605.1.15", ua.getEngineVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assertions.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseQQTest() {
|
||||
final String uaString = "User-Agent: MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("QQBrowser", ua.getBrowser().toString());
|
||||
Assert.assertEquals("26", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("533.1", ua.getEngineVersion());
|
||||
Assert.assertEquals("Android", ua.getOs().toString());
|
||||
Assert.assertEquals("2.3.7", ua.getOsVersion());
|
||||
Assert.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("QQBrowser", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("26", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("533.1", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Android", ua.getOs().toString());
|
||||
Assertions.assertEquals("2.3.7", ua.getOsVersion());
|
||||
Assertions.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseDingTalkTest() {
|
||||
final String uaString = "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/18A373 AliApp(DingTalk/5.1.33) com.laiwang.DingTalk/13976299 Channel/201200 language/zh-Hans-CN WK";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("DingTalk", ua.getBrowser().toString());
|
||||
Assert.assertEquals("5.1.33", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("605.1.15", ua.getEngineVersion());
|
||||
Assert.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assert.assertEquals("14_0", ua.getOsVersion());
|
||||
Assert.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("DingTalk", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("5.1.33", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("605.1.15", ua.getEngineVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assertions.assertEquals("14_0", ua.getOsVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseAlipayTest() {
|
||||
final String uaString = "Mozilla/5.0 (Linux; U; Android 7.0; zh-CN; FRD-AL00 Build/HUAWEIFRD-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.2214.89 UCBrowser/11.3.8.909 UWS/2.10.2.5 Mobile Safari/537.36 UCBS/2.10.2.5 Nebula AlipayDefined(nt:WIFI,ws:360|0|3.0) AliApp(AP/10.0.18.062203) AlipayClient/10.0.18.062203 Language/zh-Hans useStatusBar/true";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("Alipay", ua.getBrowser().toString());
|
||||
Assert.assertEquals("10.0.18.062203", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Android", ua.getOs().toString());
|
||||
Assert.assertEquals("7.0", ua.getOsVersion());
|
||||
Assert.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("Alipay", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("10.0.18.062203", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Android", ua.getOs().toString());
|
||||
Assertions.assertEquals("7.0", ua.getOsVersion());
|
||||
Assertions.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseTaobaoTest() {
|
||||
final String uaString = "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; MI 2C Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36 AliApp(TB/4.9.2) WindVane/5.2.2 TBANDROID/700342@taobao_android_4.9.2 720X1280";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("Taobao", ua.getBrowser().toString());
|
||||
Assert.assertEquals("4.9.2", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Android", ua.getOs().toString());
|
||||
Assert.assertEquals("4.4.4", ua.getOsVersion());
|
||||
Assert.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("Taobao", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("4.9.2", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Android", ua.getOs().toString());
|
||||
Assertions.assertEquals("4.4.4", ua.getOsVersion());
|
||||
Assertions.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseUCTest() {
|
||||
final String uaString = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 UBrowser/4.0.3214.0 Safari/537.36";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("UCBrowser", ua.getBrowser().toString());
|
||||
Assert.assertEquals("4.0.3214.0", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 7 or Windows Server 2008R2", ua.getOs().toString());
|
||||
Assert.assertEquals("6.1", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("UCBrowser", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("4.0.3214.0", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 7 or Windows Server 2008R2", ua.getOs().toString());
|
||||
Assertions.assertEquals("6.1", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseUCTest2() {
|
||||
final String uaString = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/16G102 UCBrowser/12.7.6.1251 Mobile AliApp(TUnionSDK/0.1.20.3)";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("UCBrowser", ua.getBrowser().toString());
|
||||
Assert.assertEquals("12.7.6.1251", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.51.1", ua.getEngineVersion());
|
||||
Assert.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assert.assertEquals("12_4_1", ua.getOsVersion());
|
||||
Assert.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("UCBrowser", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("12.7.6.1251", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.51.1", ua.getEngineVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assertions.assertEquals("12_4_1", ua.getOsVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseQuarkTest() {
|
||||
final String uaString = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X; zh-cn) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/16G102 Quark/3.6.2.993 Mobile";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("Quark", ua.getBrowser().toString());
|
||||
Assert.assertEquals("3.6.2.993", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("601.1.46", ua.getEngineVersion());
|
||||
Assert.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assert.assertEquals("12_4_1", ua.getOsVersion());
|
||||
Assert.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("Quark", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("3.6.2.993", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("601.1.46", ua.getEngineVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assertions.assertEquals("12_4_1", ua.getOsVersion());
|
||||
Assertions.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWxworkTest() {
|
||||
final String uaString = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 QBCore/4.0.1326.400 QQBrowser/9.0.2524.400 Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 wxwork/3.1.10 (MicroMessenger/6.2) WindowsWechat";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("wxwork", ua.getBrowser().toString());
|
||||
Assert.assertEquals("3.1.10", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assert.assertEquals("10.0", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("wxwork", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("3.1.10", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assertions.assertEquals("10.0", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWxworkMobileTest() {
|
||||
final String uaString = "Mozilla/5.0 (Linux; Android 10; JSN-AL00 Build/HONORJSN-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045710 Mobile Safari/537.36 wxwork/3.1.10 ColorScheme/Light MicroMessenger/7.0.1 NetType/WIFI Language/zh Lang/zh";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("wxwork", ua.getBrowser().toString());
|
||||
Assert.assertEquals("3.1.10", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Android", ua.getOs().toString());
|
||||
Assert.assertEquals("10", ua.getOsVersion());
|
||||
Assert.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("wxwork", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("3.1.10", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Android", ua.getOs().toString());
|
||||
Assertions.assertEquals("10", ua.getOsVersion());
|
||||
Assertions.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -364,14 +364,14 @@ public class UserAgentUtilTest {
|
||||
// https://gitee.com/dromara/hutool/issues/I4MCBP
|
||||
final String uaStr = "userAgent: Mozilla/5.0 (Linux; Android 11; MI 9 Transparent Edition) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Mobile Safari/537.36 EdgA/96.0.1054.36";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("MSEdge", ua.getBrowser().toString());
|
||||
Assert.assertEquals("96.0.1054.36", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Android", ua.getOs().toString());
|
||||
Assert.assertEquals("11", ua.getOsVersion());
|
||||
Assert.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("MSEdge", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("96.0.1054.36", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Android", ua.getOs().toString());
|
||||
Assertions.assertEquals("11", ua.getOsVersion());
|
||||
Assertions.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -380,14 +380,14 @@ public class UserAgentUtilTest {
|
||||
final String uaStr = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 SLBrowser/7.0.0.6241 SLBChan/30";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
|
||||
Assert.assertEquals("Lenovo", ua.getBrowser().toString());
|
||||
Assert.assertEquals("7.0.0.6241", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assert.assertEquals("10.0", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("Lenovo", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("7.0.0.6241", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assertions.assertEquals("10.0", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -395,14 +395,14 @@ public class UserAgentUtilTest {
|
||||
final String uaStr = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/89.0.4389.116 Safari/534.24 XiaoMi/MiuiBrowser/16.0.18 swan-mibrowser";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
|
||||
Assert.assertEquals("MiuiBrowser", ua.getBrowser().toString());
|
||||
Assert.assertEquals("16.0.18", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("534.24", ua.getEngineVersion());
|
||||
Assert.assertEquals("Android", ua.getOs().toString());
|
||||
Assert.assertEquals("11", ua.getOsVersion());
|
||||
Assert.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
Assertions.assertEquals("MiuiBrowser", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("16.0.18", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("534.24", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Android", ua.getOs().toString());
|
||||
Assertions.assertEquals("11", ua.getOsVersion());
|
||||
Assertions.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assertions.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -410,20 +410,20 @@ public class UserAgentUtilTest {
|
||||
// https://gitee.com/dromara/hutool/issues/I50YGY
|
||||
final String uaStr = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("Linux", ua.getOs().toString());
|
||||
Assertions.assertEquals("Linux", ua.getOs().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issueI60UOPTest() {
|
||||
final String uaStr = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36 dingtalk-win/1.0.0 nw(0.14.7) DingTalk(6.5.40-Release.9059101) Mojo/1.0.0 Native AppType(release) Channel/201200";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
Assert.assertEquals("DingTalk-win", ua.getBrowser().toString());
|
||||
Assert.assertEquals("6.5.40-Release.9059101", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assert.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assert.assertEquals("10.0", ua.getOsVersion());
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
Assertions.assertEquals("DingTalk-win", ua.getBrowser().toString());
|
||||
Assertions.assertEquals("6.5.40-Release.9059101", ua.getVersion());
|
||||
Assertions.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assertions.assertEquals("537.36", ua.getEngineVersion());
|
||||
Assertions.assertEquals("Windows 10 or Windows Server 2016", ua.getOs().toString());
|
||||
Assertions.assertEquals("10.0", ua.getOsVersion());
|
||||
Assertions.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assertions.assertFalse(ua.isMobile());
|
||||
}
|
||||
}
|
||||
|
@@ -2,8 +2,8 @@ package cn.hutool.http.webservice;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
@@ -17,7 +17,7 @@ import javax.xml.soap.SOAPMessage;
|
||||
public class SoapClientTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void requestTest() {
|
||||
final SoapClient client = SoapClient.of("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx")
|
||||
.setMethod("web:getCountryCityByIp", "http://WebXml.com.cn/")
|
||||
@@ -30,7 +30,7 @@ public class SoapClientTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void requestForMessageTest() throws SOAPException {
|
||||
final SoapClient client = SoapClient.of("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx")
|
||||
.setMethod("web:getCountryCityByIp", "http://WebXml.com.cn/")
|
||||
|
Reference in New Issue
Block a user