mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
Merge remote-tracking branch 'origin/v5-dev' into v5-dev
This commit is contained in:
@@ -9,6 +9,7 @@ public class ChineseDateTest {
|
||||
@Test
|
||||
public void chineseDateTest() {
|
||||
ChineseDate date = new ChineseDate(DateUtil.parseDate("2020-01-25"));
|
||||
Assert.assertEquals("2020-01-25 00:00:00", date.getGregorianDate().toString());
|
||||
Assert.assertEquals(2020, date.getChineseYear());
|
||||
|
||||
Assert.assertEquals(1, date.getMonth());
|
||||
@@ -50,6 +51,7 @@ public class ChineseDateTest {
|
||||
@Test
|
||||
public void getChineseMonthTest(){
|
||||
ChineseDate chineseDate = new ChineseDate(2020,6,15);
|
||||
Assert.assertEquals("2020-08-04 00:00:00", chineseDate.getGregorianDate().toString());
|
||||
Assert.assertEquals("六月", chineseDate.getChineseMonth());
|
||||
|
||||
chineseDate = new ChineseDate(2020,4,15);
|
||||
|
@@ -550,6 +550,13 @@ public class DateUtilTest {
|
||||
assert dt != null;
|
||||
dateStr = dt.toString(simpleDateFormat);
|
||||
Assert.assertEquals("2018-09-13 13:34:39.999", dateStr);
|
||||
|
||||
// 使用UTC时区
|
||||
dateStr1 = "2018-09-13T13:34:39.99";
|
||||
dt = DateUtil.parse(dateStr1);
|
||||
assert dt != null;
|
||||
dateStr = dt.toString();
|
||||
Assert.assertEquals("2018-09-13 13:34:39", dateStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -6,10 +6,6 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 文件类型判断单元测试
|
||||
|
@@ -0,0 +1,45 @@
|
||||
package cn.hutool.core.lang.loader;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LazyFunLoaderTest {
|
||||
|
||||
static class BigObject {
|
||||
|
||||
private boolean isDestroy = false;
|
||||
|
||||
public void destroy() {
|
||||
this.isDestroy = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
|
||||
LazyFunLoader<BigObject> loader = new LazyFunLoader<>(BigObject::new);
|
||||
|
||||
Assert.assertNotNull(loader.get());
|
||||
Assert.assertTrue(loader.isInitialize());
|
||||
|
||||
// 对于某些对象,在程序关闭时,需要进行销毁操作
|
||||
loader.ifInitialized(BigObject::destroy);
|
||||
|
||||
Assert.assertTrue(loader.get().isDestroy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
|
||||
LazyFunLoader<BigObject> loader = new LazyFunLoader<>(BigObject::new);
|
||||
|
||||
// 若从未使用,则可以避免不必要的初始化
|
||||
loader.ifInitialized(it -> {
|
||||
|
||||
Assert.fail();
|
||||
it.destroy();
|
||||
});
|
||||
|
||||
Assert.assertFalse(loader.isInitialize());
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ModifierUtilTest {
|
||||
|
||||
@Test
|
||||
public void hasModifierTest() throws NoSuchMethodException {
|
||||
Method method = ModifierUtilTest.class.getDeclaredMethod("ddd");
|
||||
Assert.assertTrue(ModifierUtil.hasModifier(method, ModifierUtil.ModifierType.PRIVATE));
|
||||
Assert.assertTrue(ModifierUtil.hasModifier(method,
|
||||
ModifierUtil.ModifierType.PRIVATE,
|
||||
ModifierUtil.ModifierType.STATIC)
|
||||
);
|
||||
}
|
||||
private static void ddd() {
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user