diff --git a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ConditionUtilTest.java b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ConditionUtilTest.java index 195e190b..42067e0f 100644 --- a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ConditionUtilTest.java +++ b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ConditionUtilTest.java @@ -17,12 +17,28 @@ package cn.hippo4j.common.toolkit; +import cn.hippo4j.common.function.NoArgsConsumer; import org.junit.Test; +import java.util.concurrent.atomic.AtomicBoolean; + public class ConditionUtilTest { @Test public void assertCondition() { + // init consumer + AtomicBoolean checkValue = new AtomicBoolean(false); + NoArgsConsumer trueConsumer = () -> checkValue.set(true); + NoArgsConsumer falseConsumer = () -> checkValue.set(false); + + // test trueConsumer run + ConditionUtil.condition(true, trueConsumer, falseConsumer); + Assert.isTrue(checkValue.get()); + + // test falseConsumer run + ConditionUtil.condition(false, trueConsumer, falseConsumer); + Assert.isTrue(!checkValue.get()); + } } diff --git a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/FileUtilTest.java b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/FileUtilTest.java index 9734dbd3..f5474a1a 100644 --- a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/FileUtilTest.java +++ b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/FileUtilTest.java @@ -24,5 +24,13 @@ public class FileUtilTest { @Test public void assertReadUtf8String() { + String testText = "abcd简体繁体\uD83D\uDE04\uD83D\uDD25& *\n" + + "second line\n" + + "empty line next\n"; + + String testFilePath = "classpath:/test/test_utf8.txt"; + String contentByFileUtil = FileUtil.readUtf8String(testFilePath); + Assert.isTrue(testText.equals(contentByFileUtil)); + } } diff --git a/hippo4j-common/src/test/resources/test/test_utf8.txt b/hippo4j-common/src/test/resources/test/test_utf8.txt new file mode 100644 index 00000000..08790c5c --- /dev/null +++ b/hippo4j-common/src/test/resources/test/test_utf8.txt @@ -0,0 +1,3 @@ +abcd简体繁体😄🔥& * +second line +empty line next