diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java index 5dd23cd3f91e..8762fcb6303f 100644 --- a/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.psi; import com.intellij.openapi.application.ApplicationManager; @@ -58,7 +73,7 @@ public class ClsRepositoryUseTest extends PsiTestCase{ } public void testClassFileUpdate() throws Exception { - final File classes = createTempDir("classes"); + final File classes = createTempDir("classes", false); final File com = new File(classes, "com"); //noinspection ResultOfMethodCallIgnored diff --git a/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/InvalidateClassFileTest.java b/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/InvalidateClassFileTest.java index ac79a1761d87..721f0d4dd3cc 100644 --- a/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/InvalidateClassFileTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/InvalidateClassFileTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.psi.impl.file.impl; import com.intellij.JavaTestUtil; @@ -14,6 +29,7 @@ import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiTreeChangeAdapter; import com.intellij.psi.PsiTreeChangeEvent; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.testFramework.PsiTestCase; import java.io.File; @@ -26,11 +42,10 @@ public class InvalidateClassFileTest extends PsiTestCase { private static final String BASE_PATH = "/psi/java/cls/"; - @Override protected void setUp() throws Exception { super.setUp(); - myRoot = createTempDirectory(); + myRoot = createTempDirectory(false); myFilesToDelete.add(myRoot); } @@ -58,8 +73,7 @@ public class InvalidateClassFileTest extends PsiTestCase { } }); - - PsiClass clazz = getJavaFacade().findClass("Clazz"); + PsiClass clazz = getJavaFacade().findClass("Clazz", GlobalSearchScope.allScope(myProject)); assertNotNull(clazz); final boolean[] notified = new boolean[] {false}; final PsiTreeChangeAdapter listener = new PsiTreeChangeAdapter() { @@ -85,6 +99,6 @@ public class InvalidateClassFileTest extends PsiTestCase { } assertFalse(clazz.isValid()); - assertNotNull(getJavaFacade().findClass("Clazz")); + assertNotNull(getJavaFacade().findClass("Clazz", GlobalSearchScope.allScope(myProject))); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java index 3dc2dd5ef977..f21d098313e4 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java @@ -66,7 +66,7 @@ public class LocalFileSystemTest extends PlatformLangTestCase { @Override public void run() { try{ - File dir = createTempDirectory(); + File dir = createTempDirectory(false); final ManagingFS managingFS = ManagingFS.getInstance(); VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(dir.getPath().replace(File.separatorChar, '/')); diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java index 23f1e94625fd..2a853d4ea32f 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java @@ -720,12 +720,19 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro } public static File createTempDir(@NonNls final String prefix) throws IOException { + return createTempDir(prefix, true); + } + + public static File createTempDir(@NonNls final String prefix, final boolean refresh) throws IOException { final File tempDirectory = FileUtil.createTempDirectory(TEST_DIR_PREFIX + prefix, null); myFilesToDelete.add(tempDirectory); - getVirtualFile(tempDirectory); + if (refresh) { + getVirtualFile(tempDirectory); + } return tempDirectory; } + @Nullable protected static VirtualFile getVirtualFile(final File file) { return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file); } @@ -734,6 +741,11 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro return createTempDir(getTestName(true)); } + protected File createTempDirectory(final boolean refresh) throws IOException { + return createTempDir(getTestName(true), refresh); + } + + @Nullable protected PsiFile getPsiFile(final Document document) { return PsiDocumentManager.getInstance(getProject()).getPsiFile(document); }