fix WatchMonitor

This commit is contained in:
Looly
2023-12-29 02:53:51 +08:00
parent bedee44420
commit 76bcbfe67c
15 changed files with 384 additions and 492 deletions

View File

@@ -164,13 +164,20 @@ public class ArrayUtilTest {
}
@Test
public void mapTest() {
public void zipTest() {
final String[] keys = {"a", "b", "c"};
final Integer[] values = {1, 2, 3};
final Map<String, Integer> map = ArrayUtil.zip(keys, values, true);
Assertions.assertEquals(Objects.requireNonNull(map).toString(), "{a=1, b=2, c=3}");
}
@Test
public void mapToArrayTest() {
final String[] keys = {"a", "b", "c"};
final Integer[] integers = ArrayUtil.mapToArray(keys, String::length, Integer[]::new);
Assertions.assertArrayEquals(integers, new Integer[]{1, 1, 1});
}
@Test
public void castTest() {
final Object[] values = {"1", "2", "3"};
@@ -453,7 +460,7 @@ public class ArrayUtilTest {
final Object a = new int[]{1, 2, 3, 4};
final Object[] wrapA = ArrayUtil.wrap(a);
for (final Object o : wrapA) {
Assertions.assertTrue(o instanceof Integer);
Assertions.assertInstanceOf(Integer.class, o);
}
}

View File

@@ -15,8 +15,9 @@ package org.dromara.hutool.core.io;
import java.nio.file.Path;
import java.nio.file.WatchEvent;
import org.dromara.hutool.core.io.watch.SimpleWatcher;
import org.dromara.hutool.core.io.watch.watchers.SimpleWatcher;
import org.dromara.hutool.core.io.watch.WatchMonitor;
import org.dromara.hutool.core.io.watch.WatchUtil;
import org.dromara.hutool.core.io.watch.Watcher;
import org.dromara.hutool.core.io.watch.watchers.DelayWatcher;
import org.dromara.hutool.core.lang.Console;
@@ -56,7 +57,8 @@ public class WatchMonitorTest {
}
};
final WatchMonitor monitor = WatchMonitor.ofAll("d:/test/aaa.txt", new DelayWatcher(watcher, 500));
//noinspection resource
final WatchMonitor monitor = WatchUtil.ofAll("d:/test/aaa.txt", new DelayWatcher(watcher, 500));
monitor.setMaxDepth(0);
monitor.start();