This commit is contained in:
Looly
2020-05-10 00:06:11 +08:00
parent c1edd9b401
commit bd4a0a075f
7 changed files with 85 additions and 6 deletions

View File

@@ -36,7 +36,6 @@ public class CollUtilTest {
@Test
public void isNotEmptyTest(){
Assert.assertFalse(CollUtil.isNotEmpty((Collection<?>) null));
;
}
@Test
@@ -589,8 +588,11 @@ public class CollUtilTest {
public void containsAllTest() {
ArrayList<Integer> list1 = CollUtil.newArrayList(1, 2, 3, 4, 5);
ArrayList<Integer> list2 = CollUtil.newArrayList(5, 3, 1);
Assert.assertTrue(CollUtil.containsAll(list1, list2));
ArrayList<Integer> list3 = CollUtil.newArrayList(1);
ArrayList<Integer> list4 = CollUtil.newArrayList();
Assert.assertTrue(CollUtil.containsAll(list3, list4));
}
@Test

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.BetweenFormater.Level;
import cn.hutool.core.date.format.FastDateFormat;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.text.SimpleDateFormat;
@@ -379,6 +380,14 @@ public class DateUtilTest {
Assert.assertEquals("2019-06-01 19:45:43", dateTime.toString());
}
@Test
@Ignore
public void parseTest8() {
String str = "2020-04-24 9:00:00";
DateTime dateTime = DateUtil.parse(str);
Assert.assertEquals("2019-06-01 19:45:43", dateTime.toString());
}
@Test
public void parseAndOffsetTest() {
// 检查UTC时间偏移是否准确

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.map.MapUtil;
import lombok.Data;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -174,4 +175,33 @@ public class XmlUtilTest {
document,XPathConstants.STRING);//
Assert.assertEquals("2020/04/15 21:01:21", value);
}
@Test
public void xmlToBeanTest(){
final TestBean testBean = new TestBean();
testBean.setReqCode("1111");
testBean.setAccountName("账户名称");
testBean.setOperator("cz");
testBean.setProjectCode("123");
testBean.setBankCode("00001");
final Document doc = XmlUtil.beanToXml(testBean);
Assert.assertEquals(TestBean.class.getSimpleName(), doc.getDocumentElement().getTagName());
final TestBean testBean2 = XmlUtil.xmlToBean(doc, TestBean.class);
Assert.assertEquals(testBean.getReqCode(), testBean2.getReqCode());
Assert.assertEquals(testBean.getAccountName(), testBean2.getAccountName());
Assert.assertEquals(testBean.getOperator(), testBean2.getOperator());
Assert.assertEquals(testBean.getProjectCode(), testBean2.getProjectCode());
Assert.assertEquals(testBean.getBankCode(), testBean2.getBankCode());
}
@Data
public static class TestBean{
private String ReqCode;
private String AccountName;
private String Operator;
private String ProjectCode;
private String BankCode;
}
}