@Test
public void testAutoReload() throws Exception {

  final Props props = new Props(this.baseProps);
  final Path filePath = getFilePath("testAutoReload");
  props.put(XmlUserManager.XML_FILE_PARAM, filePath.toString());
  final CountDownLatch managerLoaded = setupMocks(filePath);
  final UserManager manager = new XmlUserManager(props, () -> this.fileWatcher);
  // Get the user8 from existing XML with password == password8
  User user8 = manager.getUser("user8", "password8");
  // Modify the password for user8
  // TODO : djaiswal : Find a better way to modify XML
  final List<String> lines = new ArrayList<>();
  for (final String line : Files.readAllLines(filePath)) {
    if (line.contains("password8")) {
      lines.add(line.replace("password8", "passwordModified"));
    } else {
      lines.add(line);
    }
  }
  // Make sure the file gets reverted back.
  // Update the file
  Files.write(filePath, lines);
  managerLoaded.countDown();
  // Wait until login fails with the old password
  Awaitility.await().atMost(10L, TimeUnit.SECONDS).
      pollInterval(10L, TimeUnit.MILLISECONDS).until(
      () -> {
        User user;
        try {
          user = manager.getUser("user8", "password8");
        } catch (final UserManagerException e) {
          user = null;
        }
        return user == null;
      });
  // Assert that login succeeds with the modified password
  user8 = manager.getUser("user8", "passwordModified");
  assertEquals("user8", user8.getUserId());
  Mockito.verify(this.fileWatcher, Mockito.timeout(10_000L).atLeast(3)).take();
}