void () { ExecutorService executor = AppExecutorUtil.createBoundedApplicationPoolExecutor(getTestName(false), 10); PsiFile mainFile = findFile(createFile()); Document mainDoc = getDocument(mainFile); PsiFileFactory factory = PsiFileFactory.getInstance(getProject()); List<Future<?>> futures = new ArrayList<>(); for (int i = 0; i < 5; i++) { for (int j = 0; j < 20; j++) { PsiFile tempFile = factory.createFileFromText(i + ".xml", XMLLanguage.INSTANCE, "<a><b><c/></b></a>", false, false); Document document = FileDocumentManager.getInstance().getDocument(tempFile.getViewProvider().getVirtualFile()); document.insertString(0, " "); futures.add(ReadAction.nonBlocking(() -> { getPsiDocumentManager().commitDocument(document); assertEquals(tempFile.getText(), document.getText()); }).submit(executor)); } Semaphore semaphore = new Semaphore(1); WriteCommandAction.runWriteCommandAction(myProject, () -> { mainDoc.insertString(0, " "); getPsiDocumentManager().performWhenAllCommitted(semaphore::up); }); waitAndPump(semaphore); assertTrue(getPsiDocumentManager().isCommitted(mainDoc)); assertEquals(mainFile.getText(), mainDoc.getText()); } for (Future<?> future : futures) { PlatformTestUtil.waitForFuture(future, 10_000); } }