Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. @Test
  2. public void testValidateConnectionEventRaces() throws Exception
  3. {
  4. try (CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)))
  5. {
  6. CuratorFrameworkImpl clientImpl = (CuratorFrameworkImpl)client;
  7.  
  8. client.start();
  9. client.getChildren().forPath("/");
  10.  
  11. BlockingQueue<ConnectionState> stateQueue = new LinkedBlockingQueue<>();
  12. client.getConnectionStateListenable().addListener((__, newState) -> stateQueue.add(newState));
  13.  
  14. server.stop();
  15. Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.SUSPENDED);
  16. Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.LOST);
  17.  
  18. clientImpl.debugCheckBackgroundRetryReadyLatch = new CountDownLatch(1);
  19. clientImpl.debugCheckBackgroundRetryLatch = new CountDownLatch(1);
  20.  
  21. client.create().inBackground().forPath("/foo");
  22. timing.awaitLatch(clientImpl.debugCheckBackgroundRetryReadyLatch);
  23. server.restart();
  24. Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.RECONNECTED);
  25. clientImpl.debugCheckBackgroundRetryLatch.countDown();
  26.  
  27. //Assert.assertNull(stateQueue.poll(timing.milliseconds(), TimeUnit.MILLISECONDS));
  28. for(;;)
  29. {
  30. System.out.println(stateQueue.take());
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement