mirror of
https://gitee.com/dromara/hutool.git
synced 2025-09-18 17:48:17 +08:00
update to junit5
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
|
||||
package cn.hutool.extra.qrcode;
|
||||
|
||||
import cn.hutool.core.codec.binary.Base64;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.swing.img.ImgUtil;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
@@ -50,32 +49,6 @@ public class QrCodeUtil {
|
||||
*/
|
||||
public static final String QR_TYPE_TXT = "txt";
|
||||
|
||||
/**
|
||||
* 生成代 logo 图片的 Base64 编码格式的二维码,以 String 形式表示
|
||||
*
|
||||
* @param content 内容
|
||||
* @param qrConfig 二维码配置,包括宽度、高度、边距、颜色等
|
||||
* @param targetType 类型(图片扩展名),见{@link #QR_TYPE_SVG}、 {@link #QR_TYPE_TXT}、{@link ImgUtil}
|
||||
* @param logoBase64 logo 图片的 base64 编码
|
||||
* @return 图片 Base64 编码字符串
|
||||
*/
|
||||
public static String generateAsBase64(final String content, final QrConfig qrConfig, final String targetType, final String logoBase64) {
|
||||
return generateAsBase64DataUri(content, qrConfig, targetType, Base64.decode(logoBase64));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成代 logo 图片的 Base64 编码格式的二维码,以 String 形式表示
|
||||
*
|
||||
* @param content 内容
|
||||
* @param qrConfig 二维码配置,包括宽度、高度、边距、颜色等
|
||||
* @param targetType 类型(图片扩展名),见{@link #QR_TYPE_SVG}、 {@link #QR_TYPE_TXT}、{@link ImgUtil}
|
||||
* @param logo logo 图片的byte[]
|
||||
* @return 图片 Base64 编码字符串
|
||||
*/
|
||||
public static String generateAsBase64DataUri(final String content, final QrConfig qrConfig, final String targetType, final byte[] logo) {
|
||||
return generateAsBase64DataUri(content, qrConfig.setImg(ImgUtil.toImage(logo)), targetType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 Base64 编码格式的二维码,以 String 形式表示
|
||||
*
|
||||
|
@@ -316,6 +316,16 @@ public class QrConfig {
|
||||
return setImg(FileUtil.file(imgPath));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置二维码中的Logo文件
|
||||
*
|
||||
* @param imageBytes 二维码中的Logo图片bytes表示形式
|
||||
* @return this;
|
||||
*/
|
||||
public QrConfig setImg(final byte[] imageBytes) {
|
||||
return setImg(ImgUtil.toImage(imageBytes));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置二维码中的Logo文件
|
||||
*
|
||||
|
@@ -3,8 +3,8 @@ package cn.hutool.extra.aop;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.extra.aop.aspects.TimeIntervalAspect;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* AOP模块单元测试
|
||||
@@ -17,7 +17,7 @@ public class AopTest {
|
||||
public void aopTest() {
|
||||
final Animal cat = ProxyUtil.proxy(new Cat(), TimeIntervalAspect.class);
|
||||
final String result = cat.eat();
|
||||
Assert.assertEquals("猫吃鱼", result);
|
||||
Assertions.assertEquals("猫吃鱼", result);
|
||||
cat.seize();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class AopTest {
|
||||
public void aopByAutoCglibTest() {
|
||||
final Dog dog = ProxyUtil.proxy(new Dog(), TimeIntervalAspect.class);
|
||||
final String result = dog.eat();
|
||||
Assert.assertEquals("狗吃肉", result);
|
||||
Assertions.assertEquals("狗吃肉", result);
|
||||
|
||||
dog.seize();
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class AopTest {
|
||||
|
||||
final TagObj proxy = ProxyUtil.proxy(target, TimeIntervalAspect.class);
|
||||
//代理类获取标记tag (断言错误)
|
||||
Assert.assertEquals("tag", proxy.getTag());
|
||||
Assertions.assertEquals("tag", proxy.getTag());
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@@ -2,8 +2,8 @@ package cn.hutool.extra.cglib;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class CglibUtilTest {
|
||||
|
||||
@@ -15,20 +15,20 @@ public class CglibUtilTest {
|
||||
bean.setValue2("123");
|
||||
|
||||
CglibUtil.copy(bean, otherBean);
|
||||
Assert.assertEquals("Hello world", otherBean.getValue());
|
||||
Assertions.assertEquals("Hello world", otherBean.getValue());
|
||||
// 无定义转换器,转换失败
|
||||
Assert.assertEquals(0, otherBean.getValue2());
|
||||
Assertions.assertEquals(0, otherBean.getValue2());
|
||||
|
||||
final OtherSampleBean otherBean2 = CglibUtil.copy(bean, OtherSampleBean.class);
|
||||
Assert.assertEquals("Hello world", otherBean2.getValue());
|
||||
Assertions.assertEquals("Hello world", otherBean2.getValue());
|
||||
// 无定义转换器,转换失败
|
||||
Assert.assertEquals(0, otherBean.getValue2());
|
||||
Assertions.assertEquals(0, otherBean.getValue2());
|
||||
|
||||
otherBean = new OtherSampleBean();
|
||||
//自定义转换器
|
||||
CglibUtil.copy(bean, otherBean, (value, target, context) -> Convert.convertQuietly(target, value));
|
||||
Assert.assertEquals("Hello world", otherBean.getValue());
|
||||
Assert.assertEquals(123, otherBean.getValue2());
|
||||
Assertions.assertEquals("Hello world", otherBean.getValue());
|
||||
Assertions.assertEquals(123, otherBean.getValue2());
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@@ -5,8 +5,8 @@ import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.extra.compress.archiver.StreamArchiver;
|
||||
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.io.File;
|
||||
public class ArchiverTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void zipTest() {
|
||||
final File file = FileUtil.file("d:/test/compress/test.zip");
|
||||
StreamArchiver.of(CharsetUtil.UTF_8, ArchiveStreamFactory.ZIP, file)
|
||||
@@ -26,7 +26,7 @@ public class ArchiverTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void tarTest() {
|
||||
final File file = FileUtil.file("d:/test/compress/test.tar");
|
||||
StreamArchiver.of(CharsetUtil.UTF_8, ArchiveStreamFactory.TAR, file)
|
||||
@@ -38,7 +38,7 @@ public class ArchiverTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void cpioTest() {
|
||||
final File file = FileUtil.file("d:/test/compress/test.cpio");
|
||||
StreamArchiver.of(CharsetUtil.UTF_8, ArchiveStreamFactory.CPIO, file)
|
||||
@@ -50,7 +50,7 @@ public class ArchiverTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void sevenZTest() {
|
||||
final File file = FileUtil.file("d:/test/compress/test.7z");
|
||||
CompressUtil.createArchiver(CharsetUtil.UTF_8, ArchiveStreamFactory.SEVEN_Z, file)
|
||||
@@ -62,7 +62,7 @@ public class ArchiverTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void tgzTest() {
|
||||
final File file = FileUtil.file("d:/test/compress/test.tgz");
|
||||
CompressUtil.createArchiver(CharsetUtil.UTF_8, "tgz", file)
|
||||
|
@@ -3,13 +3,13 @@ package cn.hutool.extra.compress;
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.extra.compress.extractor.Extractor;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExtractorTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void zipTest(){
|
||||
final Extractor extractor = CompressUtil.createExtractor(
|
||||
CharsetUtil.defaultCharset(),
|
||||
@@ -19,7 +19,7 @@ public class ExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void sevenZTest(){
|
||||
final Extractor extractor = CompressUtil.createExtractor(
|
||||
CharsetUtil.defaultCharset(),
|
||||
@@ -29,7 +29,7 @@ public class ExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void tgzTest(){
|
||||
Extractor extractor = CompressUtil.createExtractor(
|
||||
CharsetUtil.defaultCharset(),
|
||||
|
@@ -1,28 +1,28 @@
|
||||
package cn.hutool.extra.emoji;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class EmojiUtilTest {
|
||||
|
||||
@Test
|
||||
public void toUnicodeTest() {
|
||||
final String emoji = EmojiUtil.toUnicode(":smile:");
|
||||
Assert.assertEquals("😄", emoji);
|
||||
Assertions.assertEquals("😄", emoji);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toAliasTest() {
|
||||
final String alias = EmojiUtil.toAlias("😄");
|
||||
Assert.assertEquals(":smile:", alias);
|
||||
Assertions.assertEquals(":smile:", alias);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsEmojiTest() {
|
||||
final boolean containsEmoji = EmojiUtil.containsEmoji("测试一下是否包含EMOJ:😄");
|
||||
Assert.assertTrue(containsEmoji);
|
||||
Assertions.assertTrue(containsEmoji);
|
||||
final boolean notContainsEmoji = EmojiUtil.containsEmoji("不包含EMOJ:^_^");
|
||||
Assert.assertFalse(notContainsEmoji);
|
||||
Assertions.assertFalse(notContainsEmoji);
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.map.Dict;
|
||||
import cn.hutool.extra.expression.engine.aviator.AviatorEngine;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -22,19 +22,19 @@ public class AviatorTest {
|
||||
String exp =
|
||||
"\"[foo i=\"+ foo.i + \", f=\" + foo.f + \", date.year=\" + (foo.date.year+1900) + \", date.month=\" + foo.date.month + \", bars[0].name=\" + #foo.bars[0].name + \"]\"";
|
||||
String result = (String) engine.eval(exp, Dict.of().set("foo", foo));
|
||||
Assert.assertEquals("[foo i=100, f=3.14, date.year=2020, date.month=10, bars[0].name=bar]", result);
|
||||
Assertions.assertEquals("[foo i=100, f=3.14, date.year=2020, date.month=10, bars[0].name=bar]", result);
|
||||
|
||||
// Assignment.
|
||||
exp = "#foo.bars[0].name='hello aviator' ; #foo.bars[0].name";
|
||||
result = (String) engine.eval(exp, Dict.of().set("foo", foo));
|
||||
Assert.assertEquals("hello aviator", result);
|
||||
Assert.assertEquals("hello aviator", foo.bars[0].getName());
|
||||
Assertions.assertEquals("hello aviator", result);
|
||||
Assertions.assertEquals("hello aviator", foo.bars[0].getName());
|
||||
|
||||
exp = "foo.bars[0] = nil ; foo.bars[0]";
|
||||
result = (String) engine.eval(exp, Dict.of().set("foo", foo));
|
||||
Console.log("Execute expression: " + exp);
|
||||
Assert.assertNull(result);
|
||||
Assert.assertNull(foo.bars[0]);
|
||||
Assertions.assertNull(result);
|
||||
Assertions.assertNull(foo.bars[0]);
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@@ -7,8 +7,8 @@ import cn.hutool.extra.expression.engine.mvel.MvelEngine;
|
||||
import cn.hutool.extra.expression.engine.qlexpress.QLExpressEngine;
|
||||
import cn.hutool.extra.expression.engine.rhino.RhinoEngine;
|
||||
import cn.hutool.extra.expression.engine.spel.SpELEngine;
|
||||
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 ExpressionUtilTest {
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
final Object eval = ExpressionUtil.eval("a-(b-c)", dict);
|
||||
Assert.assertEquals(-143.8, (double)eval, 0);
|
||||
Assertions.assertEquals(-143.8, (double)eval, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -34,7 +34,7 @@ public class ExpressionUtilTest {
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
final Object eval = engine.eval("a-(b-c)", dict);
|
||||
Assert.assertEquals(-143.8, (double)eval, 0);
|
||||
Assertions.assertEquals(-143.8, (double)eval, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -45,7 +45,7 @@ public class ExpressionUtilTest {
|
||||
final Map<String,Object> map2=new HashMap<>();
|
||||
map2.put("a", 1);
|
||||
final Object eval1 = engine.eval(exps2, map2);
|
||||
Assert.assertEquals(100, eval1);
|
||||
Assertions.assertEquals(100, eval1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,7 +57,7 @@ public class ExpressionUtilTest {
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
final Object eval = engine.eval("a-(b-c)", dict);
|
||||
Assert.assertEquals(-143.8, (double)eval, 0);
|
||||
Assertions.assertEquals(-143.8, (double)eval, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,7 +69,7 @@ public class ExpressionUtilTest {
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
final Object eval = engine.eval("a-(b-c)", dict);
|
||||
Assert.assertEquals(-143.8, (double)eval, 0);
|
||||
Assertions.assertEquals(-143.8, (double)eval, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +81,7 @@ public class ExpressionUtilTest {
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
final Object eval = engine.eval("#a-(#b-#c)", dict);
|
||||
Assert.assertEquals(-143.8, (double)eval, 0);
|
||||
Assertions.assertEquals(-143.8, (double)eval, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,7 +93,7 @@ public class ExpressionUtilTest {
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
final Object eval = engine.eval("a-(b-c)", dict);
|
||||
Assert.assertEquals(-143.8, (double)eval, 0);
|
||||
Assertions.assertEquals(-143.8, (double)eval, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,7 +105,7 @@ public class ExpressionUtilTest {
|
||||
.set("b", 45)
|
||||
.set("c", -199.100);
|
||||
final Object eval = engine.eval("a-(b-c)", dict);
|
||||
Assert.assertEquals(-143.8, (double)eval, 0);
|
||||
Assertions.assertEquals(-143.8, (double)eval, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,18 +1,18 @@
|
||||
package cn.hutool.extra.ftp;
|
||||
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.extra.ssh.Sftp;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FtpTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void cdTest() {
|
||||
final Ftp ftp = new Ftp("looly.centos");
|
||||
|
||||
@@ -23,7 +23,7 @@ public class FtpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void uploadTest() {
|
||||
final Ftp ftp = new Ftp("localhost");
|
||||
|
||||
@@ -34,7 +34,7 @@ public class FtpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void reconnectIfTimeoutTest() throws InterruptedException {
|
||||
final Ftp ftp = new Ftp("looly.centos");
|
||||
|
||||
@@ -58,7 +58,7 @@ public class FtpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void recursiveDownloadFolder() {
|
||||
final Ftp ftp = new Ftp("looly.centos");
|
||||
ftp.recursiveDownloadFolder("/",FileUtil.file("d:/test/download"));
|
||||
@@ -67,7 +67,7 @@ public class FtpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void recursiveDownloadFolderSftp() {
|
||||
final Sftp ftp = new Sftp("127.0.0.1", 22, "test", "test");
|
||||
|
||||
@@ -79,7 +79,7 @@ public class FtpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadTest() {
|
||||
final Ftp ftp = new Ftp("localhost");
|
||||
|
||||
@@ -94,7 +94,7 @@ public class FtpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void isDirTest() throws Exception {
|
||||
try (final Ftp ftp = new Ftp("127.0.0.1", 21)) {
|
||||
Console.log(ftp.pwd());
|
||||
@@ -104,7 +104,7 @@ public class FtpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void existSftpTest() {
|
||||
try (final Sftp ftp = new Sftp("127.0.0.1", 22, "test", "test")) {
|
||||
Console.log(ftp.pwd());
|
||||
@@ -127,7 +127,7 @@ public class FtpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void existFtpTest() throws Exception {
|
||||
try (final Ftp ftp = new Ftp("127.0.0.1", 21)) {
|
||||
Console.log(ftp.pwd());
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package cn.hutool.extra.mail;
|
||||
|
||||
import com.sun.mail.util.MailSSLSocketFactory;
|
||||
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.security.GeneralSecurityException;
|
||||
|
||||
@@ -19,8 +19,8 @@ public class MailAccountTest {
|
||||
final MailAccount account = GlobalMailAccount.INSTANCE.getAccount();
|
||||
account.getSmtpProps();
|
||||
|
||||
Assert.assertNotNull(account.getCharset());
|
||||
Assert.assertTrue(account.isSslEnable());
|
||||
Assertions.assertNotNull(account.getCharset());
|
||||
Assertions.assertTrue(account.isSslEnable());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ public class MailAccountTest {
|
||||
* 已经测试通过
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void customPropertyTest() throws GeneralSecurityException {
|
||||
final MailAccount mailAccount = new MailAccount();
|
||||
mailAccount.setFrom("xxx@xxx.com");
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package cn.hutool.extra.mail;
|
||||
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
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.InputStream;
|
||||
import java.util.HashMap;
|
||||
@@ -18,20 +18,20 @@ import java.util.Properties;
|
||||
public class MailTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void sendWithFileTest() {
|
||||
MailUtil.send("hutool@foxmail.com", "测试", "<h1>邮件来自Hutool测试</h1>", true, FileUtil.file("d:/测试附件文本.txt"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void sendWithLongNameFileTest() {
|
||||
//附件名长度大于60时的测试
|
||||
MailUtil.send("hutool@foxmail.com", "测试", "<h1>邮件来自Hutool测试</h1>", true, FileUtil.file("d:/6-LongLong一阶段平台建设周报2018.3.12-3.16.xlsx"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void sendWithImageTest() {
|
||||
final Map<String, InputStream> map = new HashMap<>();
|
||||
map.put("testImage", FileUtil.getInputStream("f:/test/me.png"));
|
||||
@@ -39,13 +39,13 @@ public class MailTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void sendHtmlTest() {
|
||||
MailUtil.send("hutool@foxmail.com", "测试", "<h1>邮件来自Hutool测试</h1>", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void sendByAccountTest() {
|
||||
final MailAccount account = new MailAccount();
|
||||
account.setHost("smtp.yeah.net");
|
||||
@@ -64,11 +64,11 @@ public class MailTest {
|
||||
account.setDebug(true);
|
||||
account.defaultIfEmpty();
|
||||
final Properties props = account.getSmtpProps();
|
||||
Assert.assertEquals("true", props.getProperty("mail.debug"));
|
||||
Assertions.assertEquals("true", props.getProperty("mail.debug"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void sendHtmlWithPicsTest() {
|
||||
HashMap<String, InputStream> map = new HashMap<>();
|
||||
map.put("abc", FileUtil.getInputStream("D:/test/abc.png"));
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @see JavaInfo
|
||||
@@ -11,8 +11,8 @@ public class JavaInfoTest {
|
||||
@Test
|
||||
public void isJavaVersionAtLeastTest() {
|
||||
final int versionInt = ManagementUtil.getJavaInfo().getVersionIntSimple();
|
||||
Assert.assertTrue(versionInt >= 8);
|
||||
Assertions.assertTrue(versionInt >= 8);
|
||||
final boolean javaVersionAtLeast1 = ManagementUtil.getJavaInfo().isJavaVersionAtLeast(1.8f);
|
||||
Assert.assertTrue(javaVersionAtLeast1);
|
||||
Assertions.assertTrue(javaVersionAtLeast1);
|
||||
}
|
||||
}
|
||||
|
@@ -2,14 +2,14 @@ package cn.hutool.extra.management;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.extra.management.oshi.OshiUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Ignore
|
||||
@Disabled
|
||||
public class OshiPrintTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void printCpuInfo(){
|
||||
Console.log(OshiUtil.getCpuInfo());
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package cn.hutool.extra.management;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.extra.management.oshi.CpuInfo;
|
||||
import cn.hutool.extra.management.oshi.OshiUtil;
|
||||
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 oshi.software.os.OSProcess;
|
||||
|
||||
/**
|
||||
@@ -16,23 +16,23 @@ public class OshiTest {
|
||||
@Test
|
||||
public void getMemoryTest() {
|
||||
final long total = OshiUtil.getMemory().getTotal();
|
||||
Assert.assertTrue(total > 0);
|
||||
Assertions.assertTrue(total > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCupInfo() {
|
||||
final CpuInfo cpuInfo = OshiUtil.getCpuInfo();
|
||||
Assert.assertNotNull(cpuInfo);
|
||||
Assertions.assertNotNull(cpuInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentProcessTest() {
|
||||
final OSProcess currentProcess = OshiUtil.getCurrentProcess();
|
||||
Assert.assertEquals("java", currentProcess.getName());
|
||||
Assertions.assertEquals("java", currentProcess.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getUsedTest() {
|
||||
int i = 0;
|
||||
while (i < 1000) {
|
||||
|
@@ -1,16 +1,16 @@
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import cn.hutool.core.util.SystemUtil;
|
||||
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.File;
|
||||
|
||||
public class SystemUtilTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void dumpTest() {
|
||||
ManagementUtil.dumpSystemInfo();
|
||||
}
|
||||
@@ -18,45 +18,45 @@ public class SystemUtilTest {
|
||||
@Test
|
||||
public void getCurrentPidTest() {
|
||||
final long pid = ManagementUtil.getCurrentPID();
|
||||
Assert.assertTrue(pid > 0);
|
||||
Assertions.assertTrue(pid > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getJavaInfoTest() {
|
||||
final JavaInfo javaInfo = ManagementUtil.getJavaInfo();
|
||||
Assert.assertNotNull(javaInfo);
|
||||
Assertions.assertNotNull(javaInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getJavaRuntimeInfoTest() {
|
||||
final JavaRuntimeInfo info = ManagementUtil.getJavaRuntimeInfo();
|
||||
Assert.assertNotNull(info);
|
||||
Assertions.assertNotNull(info);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOsInfoTest() {
|
||||
final OsInfo osInfo = ManagementUtil.getOsInfo();
|
||||
Assert.assertNotNull(osInfo);
|
||||
Assertions.assertNotNull(osInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHostInfo() {
|
||||
final HostInfo hostInfo = ManagementUtil.getHostInfo();
|
||||
Assert.assertNotNull(hostInfo);
|
||||
Assertions.assertNotNull(hostInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUserInfoTest(){
|
||||
// https://gitee.com/dromara/hutool/issues/I3NM39
|
||||
final UserInfo userInfo = ManagementUtil.getUserInfo();
|
||||
Assert.assertTrue(userInfo.getTempDir().endsWith(File.separator));
|
||||
Assertions.assertTrue(userInfo.getTempDir().endsWith(File.separator));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOsVersionTest(){
|
||||
String s = SystemUtil.get("os.name");
|
||||
Assert.assertNotNull(s);
|
||||
Assertions.assertNotNull(s);
|
||||
s = SystemUtil.get("os.version");
|
||||
Assert.assertNotNull(s);
|
||||
Assertions.assertNotNull(s);
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package cn.hutool.extra.pinyin;
|
||||
|
||||
import cn.hutool.extra.pinyin.engine.bopomofo4j.Bopomofo4jEngine;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class Bopomofo4jTest {
|
||||
|
||||
@@ -11,13 +11,13 @@ public class Bopomofo4jTest {
|
||||
@Test
|
||||
public void getFirstLetterByBopomofo4jTest(){
|
||||
final String result = engine.getFirstLetter("林海", "");
|
||||
Assert.assertEquals("lh", result);
|
||||
Assertions.assertEquals("lh", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPinyinByBopomofo4jTest() {
|
||||
final String pinyin = engine.getPinyin("你好h", " ");
|
||||
Assert.assertEquals("ni haoh", pinyin);
|
||||
Assertions.assertEquals("ni haoh", pinyin);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package cn.hutool.extra.pinyin;
|
||||
|
||||
import cn.hutool.extra.pinyin.engine.houbbpinyin.HoubbPinyinEngine;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class HoubbPinyinTest {
|
||||
|
||||
@@ -11,12 +11,12 @@ public class HoubbPinyinTest {
|
||||
@Test
|
||||
public void getFirstLetterTest(){
|
||||
final String result = engine.getFirstLetter("林海", "");
|
||||
Assert.assertEquals("lh", result);
|
||||
Assertions.assertEquals("lh", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPinyinTest() {
|
||||
final String pinyin = engine.getPinyin("你好h", " ");
|
||||
Assert.assertEquals("ni hao h", pinyin);
|
||||
Assertions.assertEquals("ni hao h", pinyin);
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package cn.hutool.extra.pinyin;
|
||||
|
||||
import cn.hutool.extra.pinyin.engine.jpinyin.JPinyinEngine;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class JpinyinTest {
|
||||
|
||||
@@ -11,13 +11,13 @@ public class JpinyinTest {
|
||||
@Test
|
||||
public void getFirstLetterByPinyin4jTest(){
|
||||
final String result = engine.getFirstLetter("林海", "");
|
||||
Assert.assertEquals("lh", result);
|
||||
Assertions.assertEquals("lh", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPinyinByPinyin4jTest() {
|
||||
final String pinyin = engine.getPinyin("你好h", " ");
|
||||
Assert.assertEquals("ni hao h", pinyin);
|
||||
Assertions.assertEquals("ni hao h", pinyin);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package cn.hutool.extra.pinyin;
|
||||
|
||||
import cn.hutool.extra.pinyin.engine.pinyin4j.Pinyin4jEngine;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class Pinyin4jTest {
|
||||
|
||||
@@ -11,12 +11,12 @@ public class Pinyin4jTest {
|
||||
@Test
|
||||
public void getFirstLetterByPinyin4jTest(){
|
||||
final String result = engine.getFirstLetter("林海", "");
|
||||
Assert.assertEquals("lh", result);
|
||||
Assertions.assertEquals("lh", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPinyinByPinyin4jTest() {
|
||||
final String pinyin = engine.getPinyin("你好h", " ");
|
||||
Assert.assertEquals("ni hao h", pinyin);
|
||||
Assertions.assertEquals("ni hao h", pinyin);
|
||||
}
|
||||
}
|
||||
|
@@ -1,25 +1,25 @@
|
||||
package cn.hutool.extra.pinyin;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class PinyinUtilTest {
|
||||
|
||||
@Test
|
||||
public void getPinyinTest(){
|
||||
final String pinyin = PinyinUtil.getPinyin("你好怡", " ");
|
||||
Assert.assertEquals("ni hao yi", pinyin);
|
||||
Assertions.assertEquals("ni hao yi", pinyin);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFirstLetterTest(){
|
||||
final String result = PinyinUtil.getFirstLetter("H是第一个", ", ");
|
||||
Assert.assertEquals("h, s, d, y, g", result);
|
||||
Assertions.assertEquals("h, s, d, y, g", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFirstLetterTest2(){
|
||||
final String result = PinyinUtil.getFirstLetter("崞阳", ", ");
|
||||
Assert.assertEquals("g, y", result);
|
||||
Assertions.assertEquals("g, y", result);
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package cn.hutool.extra.pinyin;
|
||||
|
||||
import cn.hutool.extra.pinyin.engine.tinypinyin.TinyPinyinEngine;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TinyPinyinTest {
|
||||
|
||||
@@ -11,12 +11,12 @@ public class TinyPinyinTest {
|
||||
@Test
|
||||
public void getFirstLetterByPinyin4jTest(){
|
||||
final String result = engine.getFirstLetter("林海", "");
|
||||
Assert.assertEquals("lh", result);
|
||||
Assertions.assertEquals("lh", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPinyinByPinyin4jTest() {
|
||||
final String pinyin = engine.getPinyin("你好h", " ");
|
||||
Assert.assertEquals("ni hao h", pinyin);
|
||||
Assertions.assertEquals("ni hao h", pinyin);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2023 looly(loolly@aliyun.com)
|
||||
* Hutool is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
package cn.hutool.extra.qrcode;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static cn.hutool.core.io.file.FileUtil.file;
|
||||
|
||||
public class Discussions3030Test {
|
||||
@Test
|
||||
@Disabled
|
||||
public void name() {
|
||||
//扫描二维码后 对应的链接正常
|
||||
String path = "https://juejin.cn/backend?name=%E5%BC%A0%E7%8F%8A&school=%E5%8E%A6%E9%97%A8%E5%A4%A7%E5%AD%A6";
|
||||
QrCodeUtil.generate(path, QrConfig.of(), file("d:/test/3030.png"));
|
||||
}
|
||||
}
|
@@ -1,17 +1,17 @@
|
||||
package cn.hutool.extra.qrcode;
|
||||
|
||||
import cn.hutool.core.codec.binary.Base64;
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.swing.img.ImgUtil;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.datamatrix.encoder.SymbolShapeHint;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
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.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -28,11 +28,11 @@ public class QrCodeUtilTest {
|
||||
@Test
|
||||
public void generateTest() {
|
||||
final BufferedImage image = QrCodeUtil.generate("https://hutool.cn/", 300, 300);
|
||||
Assert.assertNotNull(image);
|
||||
Assertions.assertNotNull(image);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void generateCustomTest() {
|
||||
final QrConfig config = QrConfig.of();
|
||||
config.setMargin(0);
|
||||
@@ -45,25 +45,25 @@ public class QrCodeUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void generateWithLogoTest() {
|
||||
final String icon = FileUtil.isWindows() ? "d:/test/pic/logo.jpg" : "~/Desktop/hutool/pic/logo.jpg";
|
||||
final String targetPath = FileUtil.isWindows() ? "d:/test/qrcodeWithLogo.jpg" : "~/Desktop/hutool/qrcodeWithLogo.jpg";
|
||||
QrCodeUtil.generate(//
|
||||
"https://hutool.cn/", //
|
||||
QrConfig.of().setImg(icon), //
|
||||
FileUtil.touch(targetPath));
|
||||
"https://hutool.cn/", //
|
||||
QrConfig.of().setImg(icon), //
|
||||
FileUtil.touch(targetPath));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void decodeTest() {
|
||||
final String decode = QrCodeUtil.decode(FileUtil.file("d:/test/pic/qr.png"));
|
||||
Console.log(decode);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void decodeTest2() {
|
||||
// 条形码
|
||||
final String decode = QrCodeUtil.decode(FileUtil.file("d:/test/90.png"));
|
||||
@@ -74,24 +74,27 @@ public class QrCodeUtilTest {
|
||||
public void generateAsBase64AndDecodeTest() {
|
||||
final String url = "https://hutool.cn/";
|
||||
String base64 = QrCodeUtil.generateAsBase64DataUri(url, new QrConfig(400, 400), "png");
|
||||
Assert.assertNotNull(base64);
|
||||
Assertions.assertNotNull(base64);
|
||||
|
||||
base64 = StrUtil.removePrefix(base64, "data:image/png;base64,");
|
||||
final String decode = QrCodeUtil.decode(IoUtil.toStream(Base64.decode(base64)));
|
||||
Assert.assertEquals(url, decode);
|
||||
Assertions.assertEquals(url, decode);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void generateAsBase64Test2() {
|
||||
final byte[] bytes = FileUtil.readBytes(new File("d:/test/qr.png"));
|
||||
final String base641 = QrCodeUtil.generateAsBase64DataUri("https://hutool.cn/",
|
||||
new QrConfig(400, 400), "png", bytes);
|
||||
Assert.assertNotNull(base641);
|
||||
final String base641 = QrCodeUtil.generateAsBase64DataUri(
|
||||
"https://hutool.cn/",
|
||||
QrConfig.of(400, 400).setImg(bytes),
|
||||
"png"
|
||||
);
|
||||
Assertions.assertNotNull(base641);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void decodeTest3() {
|
||||
final String decode = QrCodeUtil.decode(ImgUtil.read("d:/test/qr_a.png"), false, true);
|
||||
Console.log(decode);
|
||||
@@ -100,7 +103,7 @@ public class QrCodeUtilTest {
|
||||
@Test
|
||||
public void pdf417Test() {
|
||||
final BufferedImage image = QrCodeUtil.generate("content111", QrConfig.of().setFormat(BarcodeFormat.PDF_417));
|
||||
Assert.assertNotNull(image);
|
||||
Assertions.assertNotNull(image);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,49 +111,49 @@ public class QrCodeUtilTest {
|
||||
final QrConfig qrConfig = QrConfig.of();
|
||||
qrConfig.setShapeHint(SymbolShapeHint.FORCE_RECTANGLE);
|
||||
final BufferedImage image = QrCodeUtil.generate("content111", qrConfig.setFormat(BarcodeFormat.DATA_MATRIX));
|
||||
Assert.assertNotNull(image);
|
||||
Assertions.assertNotNull(image);
|
||||
final QrConfig config = QrConfig.of();
|
||||
config.setShapeHint(SymbolShapeHint.FORCE_SQUARE);
|
||||
final BufferedImage imageSquare = QrCodeUtil.generate("content111", qrConfig.setFormat(BarcodeFormat.DATA_MATRIX));
|
||||
Assert.assertNotNull(imageSquare);
|
||||
Assertions.assertNotNull(imageSquare);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void generateSvgTest() {
|
||||
final QrConfig qrConfig = QrConfig.of()
|
||||
.setImg("d:/test/pic/logo.jpg")
|
||||
.setForeColor(Color.blue)
|
||||
.setBackColor(Color.pink)
|
||||
.setRatio(8)
|
||||
.setErrorCorrection(ErrorCorrectionLevel.M)
|
||||
.setMargin(1);
|
||||
.setImg("d:/test/pic/logo.jpg")
|
||||
.setForeColor(Color.blue)
|
||||
.setBackColor(Color.pink)
|
||||
.setRatio(8)
|
||||
.setErrorCorrection(ErrorCorrectionLevel.M)
|
||||
.setMargin(1);
|
||||
final String svg = QrCodeUtil.generateAsSvg("https://hutool.cn/", qrConfig);
|
||||
Assert.assertNotNull(svg);
|
||||
Assertions.assertNotNull(svg);
|
||||
FileUtil.writeString(svg, FileUtil.touch("d:/test/hutool_qr.svg"), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateAsciiArtTest() {
|
||||
final QrConfig qrConfig = QrConfig.of()
|
||||
.setForeColor(Color.BLUE)
|
||||
.setBackColor(Color.MAGENTA)
|
||||
.setWidth(0)
|
||||
.setHeight(0).setMargin(1);
|
||||
final String asciiArt = QrCodeUtil.generateAsAsciiArt("https://hutool.cn/",qrConfig);
|
||||
Assert.assertNotNull(asciiArt);
|
||||
.setForeColor(Color.BLUE)
|
||||
.setBackColor(Color.MAGENTA)
|
||||
.setWidth(0)
|
||||
.setHeight(0).setMargin(1);
|
||||
final String asciiArt = QrCodeUtil.generateAsAsciiArt("https://hutool.cn/", qrConfig);
|
||||
Assertions.assertNotNull(asciiArt);
|
||||
//Console.log(asciiArt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateAsciiArtNoCustomColorTest() {
|
||||
final QrConfig qrConfig = QrConfig.of()
|
||||
.setForeColor(null)
|
||||
.setBackColor(null)
|
||||
.setWidth(0)
|
||||
.setHeight(0).setMargin(1);
|
||||
final String asciiArt = QrCodeUtil.generateAsAsciiArt("https://hutool.cn/",qrConfig);
|
||||
Assert.assertNotNull(asciiArt);
|
||||
.setForeColor(null)
|
||||
.setBackColor(null)
|
||||
.setWidth(0)
|
||||
.setHeight(0).setMargin(1);
|
||||
final String asciiArt = QrCodeUtil.generateAsAsciiArt("https://hutool.cn/", qrConfig);
|
||||
Assertions.assertNotNull(asciiArt);
|
||||
//Console.log(asciiArt);
|
||||
}
|
||||
}
|
||||
|
@@ -2,8 +2,8 @@ package cn.hutool.extra.script;
|
||||
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.script.CompiledScript;
|
||||
import javax.script.ScriptException;
|
||||
@@ -34,6 +34,6 @@ public class ScriptUtilTest {
|
||||
@Test
|
||||
public void invokeTest() {
|
||||
final Object result = ScriptUtil.invoke(ResourceUtil.readUtf8Str("filter1.js"), "filter1", 2, 1);
|
||||
Assert.assertTrue((Boolean) result);
|
||||
Assertions.assertTrue((Boolean) result);
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package cn.hutool.extra.servlet;
|
||||
|
||||
import cn.hutool.core.util.ByteUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -18,7 +18,7 @@ import java.nio.charset.StandardCharsets;
|
||||
public class ServletUtilTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void writeTest() {
|
||||
final HttpServletResponse response = null;
|
||||
final byte[] bytes = ByteUtil.toUtf8Bytes("地球是我们共同的家园,需要大家珍惜.");
|
||||
@@ -35,7 +35,7 @@ public class ServletUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void jakartaWriteTest() {
|
||||
final jakarta.servlet.http.HttpServletResponse response = null;
|
||||
final byte[] bytes = ByteUtil.toUtf8Bytes("地球是我们共同的家园,需要大家珍惜.");
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.extra.spring;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
@@ -17,8 +17,8 @@ public class EnableSpringUtilTest {
|
||||
@Test
|
||||
public void test() {
|
||||
// 使用@EnableSpringUtil注解后, 能获取上下文
|
||||
Assert.assertNotNull(SpringUtil.getApplicationContext());
|
||||
Assertions.assertNotNull(SpringUtil.getApplicationContext());
|
||||
// 不使用时, 为null
|
||||
// Assert.assertNull(SpringUtil.getApplicationContext());
|
||||
// Assertions.assertNull(SpringUtil.getApplicationContext());
|
||||
}
|
||||
}
|
||||
|
@@ -1,22 +1,22 @@
|
||||
package cn.hutool.extra.spring;
|
||||
|
||||
import cn.hutool.core.reflect.TypeReference;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.reflect.TypeReference;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = {SpringUtil.class, SpringUtilTest.Demo2.class})
|
||||
//@Import(cn.hutool.extra.spring.SpringUtil.class)
|
||||
public class SpringUtilTest {
|
||||
@@ -32,8 +32,8 @@ public class SpringUtilTest {
|
||||
SpringUtil.registerBean("registerBean", registerBean);
|
||||
|
||||
final Demo2 registerBean2 = SpringUtil.getBean("registerBean");
|
||||
Assert.assertEquals(123, registerBean2.getId());
|
||||
Assert.assertEquals("222", registerBean2.getName());
|
||||
Assertions.assertEquals(123, registerBean2.getId());
|
||||
Assertions.assertEquals("222", registerBean2.getName());
|
||||
|
||||
|
||||
}
|
||||
@@ -44,12 +44,12 @@ public class SpringUtilTest {
|
||||
@Test
|
||||
public void unregisterBeanTest() {
|
||||
registerTestAutoWired();
|
||||
Assert.assertNotNull(SpringUtil.getBean("testAutoWired"));
|
||||
Assertions.assertNotNull(SpringUtil.getBean("testAutoWired"));
|
||||
SpringUtil.unregisterBean("testAutoWired1");
|
||||
try {
|
||||
SpringUtil.getBean("testAutoWired");
|
||||
} catch (final NoSuchBeanDefinitionException e) {
|
||||
Assert.assertEquals(e.getClass(), NoSuchBeanDefinitionException.class);
|
||||
Assertions.assertEquals(e.getClass(), NoSuchBeanDefinitionException.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,26 +64,26 @@ public class SpringUtilTest {
|
||||
SpringUtil.registerBean("testAutoWired", testAutoWired);
|
||||
|
||||
testAutoWired = SpringUtil.getBean("testAutoWired");
|
||||
Assert.assertNotNull(testAutoWired);
|
||||
Assert.assertNotNull(testAutoWired.getAutowiredBean());
|
||||
Assert.assertNotNull(testAutoWired.getResourceBean());
|
||||
Assert.assertEquals("123", testAutoWired.getAutowiredBean().getId());
|
||||
Assertions.assertNotNull(testAutoWired);
|
||||
Assertions.assertNotNull(testAutoWired.getAutowiredBean());
|
||||
Assertions.assertNotNull(testAutoWired.getResourceBean());
|
||||
Assertions.assertEquals("123", testAutoWired.getAutowiredBean().getId());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBeanTest(){
|
||||
final Demo2 testDemo = SpringUtil.getBean("testDemo");
|
||||
Assert.assertEquals(12345, testDemo.getId());
|
||||
Assert.assertEquals("test", testDemo.getName());
|
||||
Assertions.assertEquals(12345, testDemo.getId());
|
||||
Assertions.assertEquals("test", testDemo.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBeanWithTypeReferenceTest() {
|
||||
final Map<String, Object> mapBean = SpringUtil.getBean(new TypeReference<Map<String, Object>>() {});
|
||||
Assert.assertNotNull(mapBean);
|
||||
Assert.assertEquals("value1", mapBean.get("key1"));
|
||||
Assert.assertEquals("value2", mapBean.get("key2"));
|
||||
Assertions.assertNotNull(mapBean);
|
||||
Assertions.assertEquals("value1", mapBean.get("key1"));
|
||||
Assertions.assertEquals("value2", mapBean.get("key2"));
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@@ -1,20 +1,20 @@
|
||||
package cn.hutool.extra.spring;
|
||||
|
||||
import cn.hutool.core.reflect.TypeReference;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.reflect.TypeReference;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = {SpringUtilWithAutoConfigTest.Demo2.class})
|
||||
//@Import(cn.hutool.extra.spring.SpringUtil.class)
|
||||
@EnableAutoConfiguration
|
||||
@@ -31,23 +31,23 @@ public class SpringUtilWithAutoConfigTest {
|
||||
SpringUtil.registerBean("registerBean", registerBean);
|
||||
|
||||
final Demo2 registerBean2 = SpringUtil.getBean("registerBean");
|
||||
Assert.assertEquals(123, registerBean2.getId());
|
||||
Assert.assertEquals("222", registerBean2.getName());
|
||||
Assertions.assertEquals(123, registerBean2.getId());
|
||||
Assertions.assertEquals("222", registerBean2.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBeanTest(){
|
||||
final Demo2 testDemo = SpringUtil.getBean("testDemo");
|
||||
Assert.assertEquals(12345, testDemo.getId());
|
||||
Assert.assertEquals("test", testDemo.getName());
|
||||
Assertions.assertEquals(12345, testDemo.getId());
|
||||
Assertions.assertEquals("test", testDemo.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBeanWithTypeReferenceTest() {
|
||||
final Map<String, Object> mapBean = SpringUtil.getBean(new TypeReference<Map<String, Object>>() {});
|
||||
Assert.assertNotNull(mapBean);
|
||||
Assert.assertEquals("value1", mapBean.get("key1"));
|
||||
Assert.assertEquals("value2", mapBean.get("key2"));
|
||||
Assertions.assertNotNull(mapBean);
|
||||
Assertions.assertEquals("value1", mapBean.get("key1"));
|
||||
Assertions.assertEquals("value2", mapBean.get("key2"));
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@@ -3,9 +3,9 @@ package cn.hutool.extra.ssh;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import com.jcraft.jsch.Session;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Jsch工具类单元测试
|
||||
@@ -16,7 +16,7 @@ import org.junit.Test;
|
||||
public class JschUtilTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void bindPortTest() {
|
||||
//新建会话,此会话用于ssh连接到跳板机(堡垒机),此处为10.1.1.1:22
|
||||
final Session session = JschUtil.getSession("looly.centos", 22, "test", "123456");
|
||||
@@ -26,19 +26,19 @@ public class JschUtilTest {
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void bindRemotePort() {
|
||||
// 建立会话
|
||||
final Session session = JschUtil.getSession("looly.centos", 22, "test", "123456");
|
||||
// 绑定ssh服务端8089端口到本机的8000端口上
|
||||
final boolean b = JschUtil.bindRemotePort(session, 8089, "localhost", 8000);
|
||||
Assert.assertTrue(b);
|
||||
Assertions.assertTrue(b);
|
||||
// 保证一直运行
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void sftpTest() {
|
||||
final Session session = JschUtil.getSession("looly.centos", 22, "root", "123456");
|
||||
final Sftp sftp = JschUtil.createSftp(session);
|
||||
@@ -47,7 +47,7 @@ public class JschUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void reconnectIfTimeoutTest() throws InterruptedException {
|
||||
final Session session = JschUtil.getSession("sunnyserver", 22,"mysftp","liuyang1234");
|
||||
final Sftp sftp = JschUtil.createSftp(session);
|
||||
@@ -75,7 +75,7 @@ public class JschUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void getSessionTest(){
|
||||
JschUtil.getSession("192.168.1.134", 22, "root", "aaa", null);
|
||||
}
|
||||
|
@@ -2,8 +2,8 @@ package cn.hutool.extra.ssh;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import org.junit.Before;
|
||||
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.List;
|
||||
@@ -19,13 +19,13 @@ public class SftpTest {
|
||||
private SshjSftp sshjSftp;
|
||||
|
||||
@Before
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void init() {
|
||||
sshjSftp = new SshjSftp("ip", 22, "test", "test", CharsetUtil.UTF_8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void lsTest() {
|
||||
final List<String> files = sshjSftp.ls("/");
|
||||
if (files != null && !files.isEmpty()) {
|
||||
@@ -34,33 +34,33 @@ public class SftpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void downloadTest() {
|
||||
sshjSftp.recursiveDownloadFolder("/home/test/temp", new File("C:\\Users\\akwangl\\Downloads\\temp"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void uploadTest() {
|
||||
sshjSftp.uploadFile("/home/test/temp/", new File("C:\\Users\\akwangl\\Downloads\\temp\\辽宁_20190718_104324.CIME"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void mkDirTest() {
|
||||
final boolean flag = sshjSftp.mkdir("/home/test/temp");
|
||||
System.out.println("是否创建成功: " + flag);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void mkDirsTest() {
|
||||
// 在当前目录下批量创建目录
|
||||
sshjSftp.mkDirs("/home/test/temp");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void delDirTest() {
|
||||
sshjSftp.delDir("/home/test/temp");
|
||||
}
|
||||
|
@@ -3,8 +3,8 @@ package cn.hutool.extra.template;
|
||||
import cn.hutool.core.map.Dict;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.extra.template.engine.jetbrick.JetbrickEngine;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class JetbrickTest {
|
||||
|
||||
@@ -16,7 +16,7 @@ public class JetbrickTest {
|
||||
final TemplateEngine engine = TemplateUtil.createEngine(config);
|
||||
final Template template = engine.getTemplate("jetbrick_test.jetx");
|
||||
final String result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("你好,hutool", StrUtil.trim(result));
|
||||
Assertions.assertEquals("你好,hutool", StrUtil.trim(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -27,6 +27,6 @@ public class JetbrickTest {
|
||||
final TemplateEngine engine = TemplateUtil.createEngine(config);
|
||||
final Template template = engine.getTemplate("hello,${name}");
|
||||
final String result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", StrUtil.trim(result));
|
||||
Assertions.assertEquals("hello,hutool", StrUtil.trim(result));
|
||||
}
|
||||
}
|
||||
|
@@ -10,9 +10,9 @@ import cn.hutool.extra.template.engine.rythm.RythmEngine;
|
||||
import cn.hutool.extra.template.engine.thymeleaf.ThymeleafEngine;
|
||||
import cn.hutool.extra.template.engine.velocity.VelocityEngine;
|
||||
import cn.hutool.extra.template.engine.wit.WitEngine;
|
||||
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.File;
|
||||
import java.util.HashMap;
|
||||
@@ -32,13 +32,13 @@ public class TemplateUtilTest {
|
||||
TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig());
|
||||
final Template template = engine.getTemplate("hello,${name}");
|
||||
final String result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", result);
|
||||
Assertions.assertEquals("hello,hutool", result);
|
||||
|
||||
// classpath中获取模板
|
||||
engine = TemplateUtil.createEngine(new TemplateConfig("templates", ResourceMode.CLASSPATH));
|
||||
final Template template2 = engine.getTemplate("beetl_test.btl");
|
||||
final String result2 = template2.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", result2);
|
||||
Assertions.assertEquals("hello,hutool", result2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -47,13 +47,13 @@ public class TemplateUtilTest {
|
||||
TemplateEngine engine = new BeetlEngine(new TemplateConfig("templates"));
|
||||
final Template template = engine.getTemplate("hello,${name}");
|
||||
final String result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", result);
|
||||
Assertions.assertEquals("hello,hutool", result);
|
||||
|
||||
// classpath中获取模板
|
||||
engine = new BeetlEngine(new TemplateConfig("templates", ResourceMode.CLASSPATH));
|
||||
final Template template2 = engine.getTemplate("beetl_test.btl");
|
||||
final String result2 = template2.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", result2);
|
||||
Assertions.assertEquals("hello,hutool", result2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,12 +63,12 @@ public class TemplateUtilTest {
|
||||
new TemplateConfig("templates").setCustomEngine(RythmEngine.class));
|
||||
final Template template = engine.getTemplate("hello,@name");
|
||||
final String result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", result);
|
||||
Assertions.assertEquals("hello,hutool", result);
|
||||
|
||||
// classpath中获取模板
|
||||
final Template template2 = engine.getTemplate("rythm_test.tmpl");
|
||||
final String result2 = template2.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", result2);
|
||||
Assertions.assertEquals("hello,hutool", result2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,14 +78,14 @@ public class TemplateUtilTest {
|
||||
new TemplateConfig("templates", ResourceMode.STRING).setCustomEngine(FreemarkerEngine.class));
|
||||
Template template = engine.getTemplate("hello,${name}");
|
||||
String result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", result);
|
||||
Assertions.assertEquals("hello,hutool", result);
|
||||
|
||||
//ClassPath模板
|
||||
engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(FreemarkerEngine.class));
|
||||
template = engine.getTemplate("freemarker_test.ftl");
|
||||
result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", result);
|
||||
Assertions.assertEquals("hello,hutool", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,18 +95,18 @@ public class TemplateUtilTest {
|
||||
new TemplateConfig("templates", ResourceMode.STRING).setCustomEngine(VelocityEngine.class));
|
||||
Template template = engine.getTemplate("你好,$name");
|
||||
String result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("你好,hutool", result);
|
||||
Assertions.assertEquals("你好,hutool", result);
|
||||
|
||||
//ClassPath模板
|
||||
engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(VelocityEngine.class));
|
||||
template = engine.getTemplate("velocity_test.vtl");
|
||||
result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("你好,hutool", result);
|
||||
Assertions.assertEquals("你好,hutool", result);
|
||||
|
||||
template = engine.getTemplate("templates/velocity_test.vtl");
|
||||
result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("你好,hutool", result);
|
||||
Assertions.assertEquals("你好,hutool", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,14 +116,14 @@ public class TemplateUtilTest {
|
||||
new TemplateConfig("templates").setCustomEngine(EnjoyEngine.class));
|
||||
Template template = engine.getTemplate("#(x + 123)");
|
||||
String result = template.render(Dict.of().set("x", 1));
|
||||
Assert.assertEquals("124", result);
|
||||
Assertions.assertEquals("124", result);
|
||||
|
||||
//ClassPath模板
|
||||
engine = new EnjoyEngine(
|
||||
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(EnjoyEngine.class));
|
||||
template = engine.getTemplate("enjoy_test.etl");
|
||||
result = template.render(Dict.of().set("x", 1));
|
||||
Assert.assertEquals("124", result);
|
||||
Assertions.assertEquals("124", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,18 +133,18 @@ public class TemplateUtilTest {
|
||||
new TemplateConfig("templates").setCustomEngine(ThymeleafEngine.class));
|
||||
Template template = engine.getTemplate("<h3 th:text=\"${message}\"></h3>");
|
||||
String result = template.render(Dict.of().set("message", "Hutool"));
|
||||
Assert.assertEquals("<h3>Hutool</h3>", result);
|
||||
Assertions.assertEquals("<h3>Hutool</h3>", result);
|
||||
|
||||
//ClassPath模板
|
||||
engine = TemplateUtil.createEngine(
|
||||
new TemplateConfig("templates", ResourceMode.CLASSPATH).setCustomEngine(ThymeleafEngine.class));
|
||||
template = engine.getTemplate("thymeleaf_test.ttl");
|
||||
result = template.render(Dict.of().set("message", "Hutool"));
|
||||
Assert.assertEquals("<h3>Hutool</h3>", result);
|
||||
Assertions.assertEquals("<h3>Hutool</h3>", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void renderToFileTest() {
|
||||
final TemplateEngine engine = new BeetlEngine(new TemplateConfig("templates", ResourceMode.CLASSPATH));
|
||||
final Template template = engine.getTemplate("freemarker_test.ftl");
|
||||
@@ -163,7 +163,7 @@ public class TemplateUtilTest {
|
||||
TemplateEngine engine = TemplateUtil.createEngine(config);
|
||||
Template template = engine.getTemplate("/wit_test.wit");
|
||||
String result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", StrUtil.trim(result));
|
||||
Assertions.assertEquals("hello,hutool", StrUtil.trim(result));
|
||||
|
||||
// 字符串模板
|
||||
config = new TemplateConfig("templates", ResourceMode.STRING)
|
||||
@@ -171,6 +171,6 @@ public class TemplateUtilTest {
|
||||
engine = TemplateUtil.createEngine(config);
|
||||
template = engine.getTemplate("<%var name;%>hello,${name}");
|
||||
result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", StrUtil.trim(result));
|
||||
Assertions.assertEquals("hello,hutool", StrUtil.trim(result));
|
||||
}
|
||||
}
|
||||
|
@@ -3,20 +3,15 @@ package cn.hutool.extra.template;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.Dict;
|
||||
import cn.hutool.extra.template.engine.thymeleaf.ThymeleafEngine;
|
||||
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 org.thymeleaf.context.Context;
|
||||
import org.thymeleaf.standard.StandardDialect;
|
||||
import org.thymeleaf.templateresolver.StringTemplateResolver;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Thymeleaf单元测试
|
||||
@@ -31,7 +26,7 @@ public class ThymeleafTest {
|
||||
* 自定义操作原始引擎
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void addDialectTest(){
|
||||
final TemplateEngine engine = TemplateUtil.createEngine();
|
||||
if(engine instanceof ThymeleafEngine){
|
||||
@@ -61,7 +56,7 @@ public class ThymeleafTest {
|
||||
final TemplateEngine engine = new ThymeleafEngine(new TemplateConfig());
|
||||
final Template template = engine.getTemplate("<h3 th:each=\"item : ${list}\" th:text=\"${item.name}\"></h3>");
|
||||
final String render = template.render(Dict.of().set("list", list));
|
||||
Assert.assertEquals("<h3>a</h3><h3>b</h3><h3>2019-01-01 00:00:00</h3>", render);
|
||||
Assertions.assertEquals("<h3>a</h3><h3>b</h3><h3>2019-01-01 00:00:00</h3>", render);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,7 +93,7 @@ public class ThymeleafTest {
|
||||
final Context context = new Context(Locale.getDefault(), map);
|
||||
templateEngine.process("<h3 th:each=\"item : ${list}\" th:text=\"${item.name}\"></h3>", context, writer);
|
||||
|
||||
Assert.assertEquals("<h3>a</h3><h3>b</h3><h3>2019-01-01 00:00:00</h3>", writer.toString());
|
||||
Assertions.assertEquals("<h3>a</h3><h3>b</h3><h3>2019-01-01 00:00:00</h3>", writer.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -109,6 +104,6 @@ public class ThymeleafTest {
|
||||
final Template template = engine.getTemplate("<h3 th:each=\"item : ${list}\" th:text=\"${item.name}\"></h3>");
|
||||
// "<h3 th:text=\"${nestMap.nestKey}\"></h3>"
|
||||
final String render = template.render(map);
|
||||
Assert.assertEquals("<h3>a</h3><h3>b</h3><h3>2019-01-01 00:00:00</h3>", render);
|
||||
Assertions.assertEquals("<h3>a</h3><h3>b</h3><h3>2019-01-01 00:00:00</h3>", render);
|
||||
}
|
||||
}
|
||||
|
@@ -3,8 +3,8 @@ package cn.hutool.extra.template;
|
||||
import cn.hutool.core.map.Dict;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.extra.template.engine.velocity.VelocityEngine;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class VelocityTest {
|
||||
|
||||
@@ -16,6 +16,6 @@ public class VelocityTest {
|
||||
final TemplateEngine engine = TemplateUtil.createEngine(config);
|
||||
final Template template = engine.getTemplate("velocity_test_gbk.vtl");
|
||||
final String result = template.render(Dict.of().set("name", "hutool"));
|
||||
Assert.assertEquals("你好,hutool", result);
|
||||
Assertions.assertEquals("你好,hutool", result);
|
||||
}
|
||||
}
|
||||
|
@@ -9,8 +9,8 @@ import cn.hutool.extra.tokenizer.engine.jieba.JiebaEngine;
|
||||
import cn.hutool.extra.tokenizer.engine.mmseg.MmsegEngine;
|
||||
import cn.hutool.extra.tokenizer.engine.mynlp.MynlpEngine;
|
||||
import cn.hutool.extra.tokenizer.engine.word.WordEngine;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* 模板引擎单元测试
|
||||
@@ -35,7 +35,7 @@ public class TokenizerUtilTest {
|
||||
final TokenizerEngine engine = new HanLPEngine();
|
||||
final Result result = engine.parse(text);
|
||||
final String resultStr = IterUtil.join(result, " ");
|
||||
Assert.assertEquals("这 两 个 方法 的 区别 在于 返回 值", resultStr);
|
||||
Assertions.assertEquals("这 两 个 方法 的 区别 在于 返回 值", resultStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -43,7 +43,7 @@ public class TokenizerUtilTest {
|
||||
final TokenizerEngine engine = new IKAnalyzerEngine();
|
||||
final Result result = engine.parse(text);
|
||||
final String resultStr = IterUtil.join(result, " ");
|
||||
Assert.assertEquals("这两个 方法 的 区别 在于 返回值", resultStr);
|
||||
Assertions.assertEquals("这两个 方法 的 区别 在于 返回值", resultStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,7 +58,7 @@ public class TokenizerUtilTest {
|
||||
final TokenizerEngine engine = new JiebaEngine();
|
||||
final Result result = engine.parse(text);
|
||||
final String resultStr = IterUtil.join(result, " ");
|
||||
Assert.assertEquals("这 两个 方法 的 区别 在于 返回值", resultStr);
|
||||
Assertions.assertEquals("这 两个 方法 的 区别 在于 返回值", resultStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,7 +73,7 @@ public class TokenizerUtilTest {
|
||||
final TokenizerEngine engine = new SmartcnEngine();
|
||||
final Result result = engine.parse(text);
|
||||
final String resultStr = IterUtil.join(result, " ");
|
||||
Assert.assertEquals("这 两 个 方法 的 区别 在于 返回 值", resultStr);
|
||||
Assertions.assertEquals("这 两 个 方法 的 区别 在于 返回 值", resultStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +81,7 @@ public class TokenizerUtilTest {
|
||||
final TokenizerEngine engine = new WordEngine();
|
||||
final Result result = engine.parse(text);
|
||||
final String resultStr = IterUtil.join(result, " ");
|
||||
Assert.assertEquals("这两个 方法 的 区别 在于 返回值", resultStr);
|
||||
Assertions.assertEquals("这两个 方法 的 区别 在于 返回值", resultStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,11 +89,11 @@ public class TokenizerUtilTest {
|
||||
final TokenizerEngine engine = new MynlpEngine();
|
||||
final Result result = engine.parse(text);
|
||||
final String resultStr = IterUtil.join(result, " ");
|
||||
Assert.assertEquals("这 两个 方法 的 区别 在于 返回 值", resultStr);
|
||||
Assertions.assertEquals("这 两个 方法 的 区别 在于 返回 值", resultStr);
|
||||
}
|
||||
|
||||
private void checkResult(final Result result) {
|
||||
final String resultStr = IterUtil.join(result, " ");
|
||||
Assert.assertEquals("这 两个 方法 的 区别 在于 返回 值", resultStr);
|
||||
Assertions.assertEquals("这 两个 方法 的 区别 在于 返回 值", resultStr);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.extra.validation;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
@@ -40,14 +40,14 @@ public class BeanValidatorUtilTest {
|
||||
@Test
|
||||
public void beanValidatorTest() {
|
||||
final BeanValidationResult result = ValidationUtil.warpValidate(new TestClass());
|
||||
Assert.assertFalse(result.isSuccess());
|
||||
Assert.assertEquals(2, result.getErrorMessages().size());
|
||||
Assertions.assertFalse(result.isSuccess());
|
||||
Assertions.assertEquals(2, result.getErrorMessages().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyValidatorTest() {
|
||||
final BeanValidationResult result = ValidationUtil.warpValidateProperty(new TestClass(), "name");
|
||||
Assert.assertFalse(result.isSuccess());
|
||||
Assert.assertEquals(1, result.getErrorMessages().size());
|
||||
Assertions.assertFalse(result.isSuccess());
|
||||
Assertions.assertEquals(1, result.getErrorMessages().size());
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.extra.xml;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
|
||||
@@ -34,18 +34,18 @@ public class JAXBUtilTest {
|
||||
roomVo.setRoomNo("101");
|
||||
schoolVo.setRoom(roomVo);
|
||||
|
||||
Assert.assertEquals(xmlStr, JAXBUtil.beanToXml(schoolVo));
|
||||
Assertions.assertEquals(xmlStr, JAXBUtil.beanToXml(schoolVo));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlToBeanTest() {
|
||||
final SchoolVo schoolVo = JAXBUtil.xmlToBean(xmlStr, SchoolVo.class);
|
||||
Assert.assertNotNull(schoolVo);
|
||||
Assert.assertEquals("西安市第一中学", schoolVo.getSchoolName());
|
||||
Assert.assertEquals("西安市雁塔区长安堡一号", schoolVo.getSchoolAddress());
|
||||
Assertions.assertNotNull(schoolVo);
|
||||
Assertions.assertEquals("西安市第一中学", schoolVo.getSchoolName());
|
||||
Assertions.assertEquals("西安市雁塔区长安堡一号", schoolVo.getSchoolAddress());
|
||||
|
||||
Assert.assertEquals("101教室", schoolVo.getRoom().getRoomName());
|
||||
Assert.assertEquals("101", schoolVo.getRoom().getRoomNo());
|
||||
Assertions.assertEquals("101教室", schoolVo.getRoom().getRoomName());
|
||||
Assertions.assertEquals("101", schoolVo.getRoom().getRoomNo());
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "school")
|
||||
|
Reference in New Issue
Block a user