|
@@ -21,6 +21,7 @@ package org.apache.zookeeper.test;
|
|
|
import static org.apache.zookeeper.AddWatchMode.PERSISTENT;
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
import java.io.IOException;
|
|
|
import java.util.concurrent.BlockingQueue;
|
|
@@ -62,6 +63,20 @@ public class PersistentWatcherTest extends ClientBase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testNullWatch()
|
|
|
+ throws IOException, InterruptedException, KeeperException {
|
|
|
+ try (ZooKeeper zk = createClient(new CountdownWatcher(), hostPort)) {
|
|
|
+ assertThrows(IllegalArgumentException.class, () -> {
|
|
|
+ zk.addWatch("/a/b", null, PERSISTENT);
|
|
|
+ });
|
|
|
+ assertThrows(IllegalArgumentException.class, () -> {
|
|
|
+ AsyncCallback.VoidCallback cb = (rc, path, ctx) -> {};
|
|
|
+ zk.addWatch("/a/b", null, PERSISTENT, cb, null);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testDefaultWatcher()
|
|
|
throws IOException, InterruptedException, KeeperException {
|