@Override
  protected void setUp() throws Exception {
    LOG.debug("================== setting up " + getName() + " ==================");

    super.setUp();

    myFileSystem = LocalFileSystem.getInstance();
    assertNotNull(myFileSystem);

    myWatcher = ((LocalFileSystemImpl) myFileSystem).getFileWatcher();
    assertNotNull(myWatcher);
    assertFalse(myWatcher.isOperational());
    myWatcher.startup(myNotifier);
    assertTrue(myWatcher.isOperational());

    myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, getProject());
    myTimeout = NATIVE_PROCESS_DELAY;

    myConnection = ApplicationManager.getApplication().getMessageBus().connect();
    myConnection.subscribe(
        VirtualFileManager.VFS_CHANGES,
        new BulkFileListener.Adapter() {
          @Override
          public void after(@NotNull List<? extends VFileEvent> events) {
            synchronized (myEvents) {
              myEvents.addAll(events);
            }
          }
        });

    ((LocalFileSystemImpl) myFileSystem).cleanupForNextTest();

    LOG = FileWatcher.getLog();
    LOG.debug("================== setting up " + getName() + " ==================");
  }
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    MessageBusConnection connection =
        ApplicationManager.getApplication().getMessageBus().connect(myTestRootDisposable);
    connection.subscribe(
        VirtualFileManager.VFS_CHANGES,
        new BulkFileListener() {
          @Override
          public void before(@NotNull List<? extends VFileEvent> events) {
            checkFiles(events, true);
          }

          @Override
          public void after(@NotNull List<? extends VFileEvent> events) {
            checkFiles(events, false);
          }

          private void checkFiles(List<? extends VFileEvent> events, boolean before) {
            for (VFileEvent event : events) {
              VirtualFile file = event.getFile();
              if (file != null) {
                boolean shouldBeInvalid =
                    event instanceof VFileCreateEvent
                            && before
                            && !((VFileCreateEvent) event).isReCreation()
                        || event instanceof VFileDeleteEvent && !before;
                assertEquals(event.toString(), !shouldBeInvalid, file.isValid());
              }
            }
          }
        });
  }