Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- public void testValidateConnectionEventRaces() throws Exception
- {
- try (CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)))
- {
- CuratorFrameworkImpl clientImpl = (CuratorFrameworkImpl)client;
- client.start();
- client.getChildren().forPath("/");
- BlockingQueue<ConnectionState> stateQueue = new LinkedBlockingQueue<>();
- client.getConnectionStateListenable().addListener((__, newState) -> stateQueue.add(newState));
- server.stop();
- Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.SUSPENDED);
- Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.LOST);
- clientImpl.debugCheckBackgroundRetryReadyLatch = new CountDownLatch(1);
- clientImpl.debugCheckBackgroundRetryLatch = new CountDownLatch(1);
- client.create().inBackground().forPath("/foo");
- timing.awaitLatch(clientImpl.debugCheckBackgroundRetryReadyLatch);
- server.restart();
- Assert.assertEquals(timing.takeFromQueue(stateQueue), ConnectionState.RECONNECTED);
- clientImpl.debugCheckBackgroundRetryLatch.countDown();
- //Assert.assertNull(stateQueue.poll(timing.milliseconds(), TimeUnit.MILLISECONDS));
- for(;;)
- {
- System.out.println(stateQueue.take());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement