@Test
public void testAutoReloadFail() throws Exception {

  final Props props = new Props(this.baseProps);
  final Path filePath = getFilePath("testAutoReloadFail");
  props.put(XmlUserManager.XML_FILE_PARAM, filePath.toString());
  final CountDownLatch managerLoaded = setupMocks(filePath);
  final UserManager manager;
  try {
    manager = new XmlUserManager(props, () -> this.fileWatcher);
  } catch (final RuntimeException e) {
    fail("Should have found the xml file");
    return;
  }
  // Get the user8 from existing XML with password == password8
  final User user8 = manager.getUser("user8", "password8");
  assertEquals("user8", user8.getUserId());
  // Update the file to make it empty.
  Files.write(filePath, new byte[0], StandardOpenOption.TRUNCATE_EXISTING);
  managerLoaded.countDown();
  // Make sure the file gets reverted back.
  managerLoaded.await(10L, TimeUnit.SECONDS);
  assertEquals(0, managerLoaded.getCount());
  // assert that watcher.take() was still called after the failed reload
  Mockito.verify(this.fileWatcher, Mockito.timeout(10_000L).atLeast(3)).take();
  // Nothing should've changed, login should succeed as originally
  final User user = manager.getUser("user8", "password8");
  assertEquals("user8", user.getUserId());
}