/**
   * Simulates deadlock issue 133616 - create MultiFileSystem - create lookup to set our
   * MultiFileSystem and system filesystem - create handler to manage threads - put test FileObject
   * to 'potentialLock' set - call hasLocks - it call LocalFileSystemEx.getInvalid which ends in our
   * DeadlockHandler - it starts lockingThread which calls FileObject.lock which locks our
   * FileObject - when we in LocalFileSystemEx.lock, we notify main thread which continues in
   * getInvalid and tries to accuire lock on FileObject and it dead locks
   */
  public void testLocalFileSystemEx133616() throws Exception {
    System.setProperty("workdir", getWorkDirPath());
    clearWorkDir();

    FileSystem lfs =
        TestUtilHid.createLocalFileSystem("mfs1" + getName(), new String[] {"/fold/file1"});
    LocalFileSystemEx exfs = new LocalFileSystemEx();
    exfs.setRootDirectory(FileUtil.toFile(lfs.getRoot()));
    FileSystem xfs = TestUtilHid.createXMLFileSystem(getName(), new String[] {});
    FileSystem mfs = new MultiFileSystem(exfs, xfs);
    testedFS = mfs;
    System.setProperty(
        "org.openide.util.Lookup", LocalFileSystemEx133616Test.class.getName() + "$Lkp");
    Lookup l = Lookup.getDefault();
    if (!(l instanceof Lkp)) {
      fail("Wrong lookup: " + l);
    }

    final FileObject file1FO = mfs.findResource("/fold/file1");
    File file1File = FileUtil.toFile(file1FO);

    Logger.getLogger(LocalFileSystemEx.class.getName()).setLevel(Level.FINEST);
    Logger.getLogger(LocalFileSystemEx.class.getName()).addHandler(new DeadlockHandler(file1FO));
    LocalFileSystemEx.potentialLock(file1FO.getPath());
    LocalFileSystemEx.hasLocks();
  }