zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjward <...@git.apache.org>
Subject [GitHub] zookeeper pull request #529: [ZOOKEEPER-2368] Send a watch event is when a c...
Date Wed, 20 Jun 2018 10:56:34 GMT
Github user timothyjward commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/529#discussion_r196731884
  
    --- Diff: src/java/test/org/apache/zookeeper/test/WatcherTest.java ---
    @@ -140,6 +142,55 @@ public void processResult(int rc, String path, Object ctx) {
                 }
             }
         }
    +    
    +    @Test
    +    public void testWatcherDisconnectOnClose() 
    +        throws IOException, InterruptedException, KeeperException 
    +    {
    +        ZooKeeper zk = null;
    +        try {
    +            final BlockingQueue<WatchedEvent> queue = new LinkedBlockingQueue<>();
    +            
    +            MyWatcher connWatcher = new MyWatcher();
    +            
    +            Watcher watcher = new Watcher(){
    +                @Override
    +                public void process(WatchedEvent event) {
    +                    try {
    +                        queue.put(event);
    +                    } catch (InterruptedException e) {
    +                        // Oh well, never mind
    +                    }
    +                }
    +                
    +            };
    +            
    +            zk = createClient(connWatcher, hostPort);
    +    
    +            StatCallback scb = new StatCallback() {
    +                public void processResult(int rc, String path, Object ctx,
    +                        Stat stat) {
    +                    // don't do anything
    +                }
    +            };
    +            
    +            // Register a watch on the node
    +            zk.exists("/missing", watcher, scb, null);
    +            
    +            // Close the client without changing the node
    +            zk.close();
    +            
    +            
    +            WatchedEvent event = queue.poll(10, TimeUnit.SECONDS);
    +            Assert.assertEquals(Event.EventType.None, event.getType());
    --- End diff --
    
    I've pushed updated assertions containing more human readable text. 


---

Mime
View raw message