diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java index e86257d8e36f..8fcd8c52a493 100644 --- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java @@ -19,6 +19,7 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; import com.intellij.ide.DataManager; import com.intellij.injected.editor.EditorWindow; +import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.Result; @@ -40,9 +41,11 @@ import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.*; +import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; @@ -119,6 +122,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase { for (int i = 0; i < files.length; i++) { String path = files[i]; final String fullPath = FileUtil.toSystemIndependentName(getTestDataPath() + path); + allowRootAccess(fullPath); VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(fullPath); vFiles[i] = vFile; assertNotNull("file " + fullPath + " not found", vFile); @@ -129,8 +133,19 @@ public abstract class CodeInsightTestCase extends PsiTestCase { return configureByFiles(projectFile, vFiles); } + private void allowRootAccess(final String filePath) { + VfsRootAccess.allowRootAccess(filePath); + Disposer.register(myTestRootDisposable, new Disposable() { + @Override + public void dispose() { + VfsRootAccess.disallowRootAccess(filePath); + } + }); + } + protected VirtualFile configureByFile(@NonNls String filePath, @Nullable String projectRoot) throws Exception { String fullPath = getTestDataPath() + filePath; + allowRootAccess(fullPath); final VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(fullPath.replace(File.separatorChar, '/')); assertNotNull("file " + fullPath + " not found", vFile); @@ -475,6 +490,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase { PsiDocumentManager.getInstance(myProject).commitAllDocuments(); String fullPath = getTestDataPath() + filePath; + allowRootAccess(fullPath); final VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(fullPath.replace(File.separatorChar, '/')); assertNotNull("Cannot find file " + fullPath, vFile); @@ -549,6 +565,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase { protected VirtualFile getVirtualFile(@NonNls @NotNull String filePath) { String fullPath = getTestDataPath() + filePath; + allowRootAccess(fullPath); final VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(fullPath.replace(File.separatorChar, '/')); assertNotNull("file " + fullPath + " not found", vFile);