Merge branch 'v5-dev' of https://github.com/totalo/hutool into v5-dev

This commit is contained in:
totalo
2020-10-10 23:11:43 +08:00
53 changed files with 1024 additions and 502 deletions

View File

@@ -1,5 +1,6 @@
package cn.hutool.core.date;
import cn.hutool.core.util.StrUtil;
import org.junit.Assert;
import org.junit.Test;
@@ -77,4 +78,11 @@ public class ChineseDateTest {
chineseDate = new ChineseDate(2020,4,15);
Assert.assertEquals("闰四月", chineseDate.getChineseMonth());
}
@Test
public void getFestivalsTest(){
// issue#I1XHSF@Gitee2023-01-20对应农历腊月29非除夕
ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate("2023-01-20"));
Assert.assertTrue(StrUtil.isEmpty(chineseDate.getFestivals()));
}
}

View File

@@ -25,7 +25,9 @@ public class ImgUtilTest {
@Test
@Ignore
public void scaleTest2() {
ImgUtil.scale(FileUtil.file("e:/pic/test.jpg"), FileUtil.file("e:/pic/test_result.jpg"), 0.8f);
ImgUtil.scale(
FileUtil.file("d:/test/2.png"),
FileUtil.file("d:/test/2_result.jpg"), 600, 337, null);
}
@Test

View File

@@ -0,0 +1,35 @@
package cn.hutool.core.lang;
import org.junit.Ignore;
import org.junit.Test;
public class ConsoleTableTest {
@Test
@Ignore
public void printTest() {
ConsoleTable t = new ConsoleTable();
t.addHeader("姓名", "年龄");
t.addBody("张三", "15");
t.addBody("李四", "29");
t.addBody("王二麻子", "37");
t.print();
Console.log();
t = new ConsoleTable();
t.addHeader("体温", "占比");
t.addHeader("", "%");
t.addBody("36.8", "10");
t.addBody("37", "5");
t.print();
Console.log();
t = new ConsoleTable();
t.addHeader("标题1", "标题2");
t.addBody("12345", "混合321654asdfcSDF");
t.addBody("sd e3ee ff22", "ff值");
t.print();
}
}

View File

@@ -263,10 +263,10 @@ public class NumberUtilTest {
@Test
public void isPowerOfTwoTest() {
Assert.assertEquals(false, NumberUtil.isPowerOfTwo(-1));
Assert.assertEquals(true, NumberUtil.isPowerOfTwo(16));
Assert.assertEquals(true, NumberUtil.isPowerOfTwo(65536));
Assert.assertEquals(true, NumberUtil.isPowerOfTwo(1));
Assert.assertEquals(false, NumberUtil.isPowerOfTwo(17));
Assert.assertFalse(NumberUtil.isPowerOfTwo(-1));
Assert.assertTrue(NumberUtil.isPowerOfTwo(16));
Assert.assertTrue(NumberUtil.isPowerOfTwo(65536));
Assert.assertTrue(NumberUtil.isPowerOfTwo(1));
Assert.assertFalse(NumberUtil.isPowerOfTwo(17));
}
}

View File

@@ -9,10 +9,13 @@ import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.w3c.dom.Document;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.xpath.XPathConstants;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
/**
* {@link XmlUtil} 工具类
@@ -148,6 +151,18 @@ public class XmlUtilTest {
Assert.assertNotNull(doc);
}
@Test
public void readBySaxTest(){
final Set<String> eles = CollUtil.newHashSet(
"returnsms", "returnstatus", "message", "remainpoint", "taskID", "successCounts");
XmlUtil.readBySax(ResourceUtil.getStream("test.xml"), new DefaultHandler(){
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) {
Assert.assertTrue(eles.contains(localName));
}
});
}
@Test
public void mapToXmlTestWithOmitXmlDeclaration() {
@@ -196,6 +211,13 @@ public class XmlUtilTest {
Assert.assertEquals(testBean.getBankCode(), testBean2.getBankCode());
}
@Test
public void cleanCommentTest() {
final String xmlContent = "<info><title>hutool</title><!-- 这是注释 --><lang>java</lang></info>";
final String ret = XmlUtil.cleanComment(xmlContent);
Assert.assertEquals("<info><title>hutool</title><lang>java</lang></info>", ret);
}
@Data
public static class TestBean {
private String ReqCode;