mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
update PsiEventsTest exception expectations
This commit is contained in:
@@ -18,6 +18,7 @@ package com.intellij.java.psi.impl.file.impl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.diagnostic.DefaultLogger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
@@ -793,7 +794,23 @@ public class PsiEventsTest extends PsiTestCase {
|
||||
assertTrue(documentManager.isCommitted(document));
|
||||
}
|
||||
|
||||
public void testTreeChangePreprocessorThrowsException() throws Exception {
|
||||
public void testCopyFile() throws Exception {
|
||||
VirtualFile original = createFile(myModule, mySrcDir1, "a.xml", "<tag/>").getVirtualFile();
|
||||
|
||||
EventsTestListener listener = new EventsTestListener();
|
||||
myPsiManager.addPsiTreeChangeListener(listener,getTestRootDisposable());
|
||||
|
||||
PsiDirectory psiDir2 = PsiManager.getInstance(myProject).findDirectory(mySrcDir2);
|
||||
assertNotNull(psiDir2);
|
||||
WriteAction.run(() -> original.copy(this, mySrcDir2, "b.xml"));
|
||||
|
||||
assertEquals("beforeChildAddition\n" +
|
||||
"childAdded\n", listener.getEventsString());
|
||||
}
|
||||
|
||||
public void testSuccessfulRecoveryAfterTreeChangePreprocessorThrowsException() throws Exception {
|
||||
DefaultLogger.disableStderrDumping(getTestRootDisposable());
|
||||
|
||||
PsiFile psiFile = createFile("a.xml", "<tag/>");
|
||||
VirtualFile vFile = psiFile.getVirtualFile();
|
||||
Document document = FileDocumentManager.getInstance().getDocument(vFile);
|
||||
@@ -809,7 +826,8 @@ public class PsiEventsTest extends PsiTestCase {
|
||||
WriteCommandAction.runWriteCommandAction(myProject, () -> document.insertString(0, " "));
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
fail("NPE expected");
|
||||
} catch (NullPointerException ignore) {
|
||||
} catch (AssertionError e) {
|
||||
assertInstanceOf(e.getCause(), NullPointerException.class);
|
||||
} finally {
|
||||
((PsiManagerImpl)getPsiManager()).removeTreeChangePreprocessor(preprocessor);
|
||||
}
|
||||
@@ -818,18 +836,4 @@ public class PsiEventsTest extends PsiTestCase {
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
assertEquals(" <tag/>", getPsiManager().findFile(vFile).getText());
|
||||
}
|
||||
|
||||
public void testCopyFile() throws Exception {
|
||||
VirtualFile original = createFile(myModule, mySrcDir1, "a.xml", "<tag/>").getVirtualFile();
|
||||
|
||||
EventsTestListener listener = new EventsTestListener();
|
||||
myPsiManager.addPsiTreeChangeListener(listener,getTestRootDisposable());
|
||||
|
||||
PsiDirectory psiDir2 = PsiManager.getInstance(myProject).findDirectory(mySrcDir2);
|
||||
assertNotNull(psiDir2);
|
||||
WriteAction.run(() -> original.copy(this, mySrcDir2, "b.xml"));
|
||||
|
||||
assertEquals("beforeChildAddition\n" +
|
||||
"childAdded\n", listener.getEventsString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user