mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
access to myFilesToDelete should be not static
This commit is contained in:
@@ -23,7 +23,10 @@ import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
|
||||
import com.intellij.testFramework.*;
|
||||
import com.intellij.testFramework.ModuleTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.VfsTestUtil;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.io.TestFileSystemBuilder;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -304,7 +307,7 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
|
||||
//todo[nik] reuse code from PlatformTestCase
|
||||
final VirtualFile baseDir = getOrCreateProjectBaseDir();
|
||||
final File moduleFile = new File(baseDir.getPath().replace('/', File.separatorChar), moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
|
||||
PlatformTestCase.myFilesToDelete.add(moduleFile);
|
||||
myFilesToDelete.add(moduleFile);
|
||||
return WriteAction.computeAndWait(() -> {
|
||||
Module module = ModuleManager.getInstance(myProject)
|
||||
.newModule(FileUtil.toSystemIndependentName(moduleFile.getAbsolutePath()), getModuleType().getId());
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.jetbrains.jsonSchema.ide.JsonSchemaService;
|
||||
import com.jetbrains.jsonSchema.impl.JsonSchemaAnnotator;
|
||||
@@ -593,8 +592,8 @@ public class JsonSchemaHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
doTest(file.getVirtualFile(), true, false);
|
||||
}
|
||||
|
||||
public static void registerProvider(Project project, @NotNull String schema) throws IOException {
|
||||
File dir = PlatformTestCase.createTempDir("json_schema_test", true);
|
||||
public void registerProvider(Project project, @NotNull String schema) throws IOException {
|
||||
File dir = createTempDir("json_schema_test", true);
|
||||
File child = new File(dir, "schema.json");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
child.createNewFile();
|
||||
|
||||
@@ -79,13 +79,6 @@ open class FileBasedStorage(file: Path,
|
||||
storage.lineSeparator = lineSeparator
|
||||
}
|
||||
|
||||
// only app level components do not use xml prolog
|
||||
if (storage.roamingType == RoamingType.DISABLED && storage.isUseXmlProlog) {
|
||||
if (element == null) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
val isUseVfs = storage.isUseVfsForWrite
|
||||
val virtualFile = if (isUseVfs) storage.virtualFile else null
|
||||
if (element == null) {
|
||||
|
||||
+7
-4
@@ -11,8 +11,8 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jdom.Element;
|
||||
@@ -87,7 +87,7 @@ public class LightFileTemplatesTest extends LightPlatformTestCase {
|
||||
myTemplateManager.setTemplates(FileTemplateManager.DEFAULT_TEMPLATES_CATEGORY, Arrays.asList(myTemplateManager.getAllTemplates()));
|
||||
assertNotNull(myTemplateManager.getTemplate("foo.txt"));
|
||||
|
||||
File foo = PlatformTestCase.createTempDir("foo");
|
||||
File foo = FileUtilRt.createTempDirectory("foo", null, false);
|
||||
final Project project = ProjectManager.getInstance().createProject("foo", foo.getPath());
|
||||
try {
|
||||
assertNotNull(project);
|
||||
@@ -95,11 +95,12 @@ public class LightFileTemplatesTest extends LightPlatformTestCase {
|
||||
}
|
||||
finally {
|
||||
closeProject(project);
|
||||
FileUtilRt.delete(foo);
|
||||
}
|
||||
}
|
||||
|
||||
public void testSurviveOnProjectReopen() throws Exception {
|
||||
File foo = PlatformTestCase.createTempDir("foo");
|
||||
File foo = FileUtilRt.createTempDirectory("foo", null, false);
|
||||
Project reloaded = null;
|
||||
final Project project = ProjectManager.getInstance().createProject("foo", foo.getPath());
|
||||
try {
|
||||
@@ -127,11 +128,12 @@ public class LightFileTemplatesTest extends LightPlatformTestCase {
|
||||
finally {
|
||||
closeProject(project);
|
||||
closeProject(reloaded);
|
||||
FileUtilRt.delete(foo);
|
||||
}
|
||||
}
|
||||
|
||||
public void testAddRemoveShared() throws Exception {
|
||||
File foo = PlatformTestCase.createTempDir("foo");
|
||||
File foo = FileUtilRt.createTempDirectory("foo", null, false);
|
||||
final Project project = ProjectManager.getInstance().createProject("foo", foo.getPath());
|
||||
try {
|
||||
assertThat(project).isNotNull();
|
||||
@@ -169,6 +171,7 @@ public class LightFileTemplatesTest extends LightPlatformTestCase {
|
||||
}
|
||||
finally {
|
||||
closeProject(project);
|
||||
FileUtilRt.delete(foo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-18
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.diff.impl.patch
|
||||
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil
|
||||
@@ -25,7 +11,6 @@ import junit.framework.TestCase
|
||||
import java.io.File
|
||||
|
||||
class PatchReaderTest : PlatformTestCase() {
|
||||
|
||||
private val author = VcsUserImpl("D D", "aaaa@gmail.com")
|
||||
private val doubleSurname = VcsUserImpl("D D-D", "aaaa@gmail.com")
|
||||
private val longName = VcsUserImpl("very long author-surname", "aaaa@gmail.com")
|
||||
@@ -99,8 +84,8 @@ class PatchReaderTest : PlatformTestCase() {
|
||||
|
||||
private fun read(): PatchReader {
|
||||
val testDataPath = PlatformTestUtil.getPlatformTestDataPath() + "diff/patchReader/" + getTestName(true)
|
||||
PsiTestUtil.createTestProjectStructure(myProject, myModule, testDataPath, PlatformTestCase.myFilesToDelete)
|
||||
val patchPath = testDataPath + "/test.patch"
|
||||
PsiTestUtil.createTestProjectStructure(myProject, myModule, testDataPath, myFilesToDelete)
|
||||
val patchPath = "$testDataPath/test.patch"
|
||||
val patchFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(patchPath.replace(File.separatorChar, '/'))
|
||||
|
||||
val patchContents = patchFile!!.contentsToByteArray()
|
||||
|
||||
+3
-20
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.diff.impl.patch
|
||||
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil
|
||||
@@ -23,7 +9,6 @@ import com.intellij.testFramework.PsiTestUtil
|
||||
import java.io.File
|
||||
|
||||
class PatchTextDetectionTest : PlatformTestCase() {
|
||||
|
||||
fun testClassicalContextDiff() {
|
||||
doTest(true)
|
||||
}
|
||||
@@ -48,16 +33,14 @@ class PatchTextDetectionTest : PlatformTestCase() {
|
||||
doTest(false)
|
||||
}
|
||||
|
||||
|
||||
private fun doTest(expected: Boolean) {
|
||||
val testDataPath = PlatformTestUtil.getPlatformTestDataPath() + "diff/patchTextDetection/" + getTestName(true)
|
||||
PsiTestUtil.createTestProjectStructure(myProject, myModule, testDataPath, PlatformTestCase.myFilesToDelete)
|
||||
val patchPath = testDataPath + "/test.patch"
|
||||
PsiTestUtil.createTestProjectStructure(myProject, myModule, testDataPath, myFilesToDelete)
|
||||
val patchPath = "$testDataPath/test.patch"
|
||||
val patchFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(patchPath.replace(File.separatorChar, '/'))
|
||||
|
||||
val patchContents = patchFile!!.contentsToByteArray()
|
||||
val patchText = LoadTextUtil.getTextByBinaryPresentation(patchContents, patchFile);
|
||||
assertEquals(expected, PatchReader.isPatchContent((patchText.toString())));
|
||||
}
|
||||
|
||||
}
|
||||
+3
-17
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.project.impl;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
@@ -40,7 +26,7 @@ import static com.intellij.openapi.startup.StartupActivity.POST_STARTUP_ACTIVITY
|
||||
public class ProjectOpeningTest extends PlatformTestCase {
|
||||
|
||||
public void testOpenProjectCancelling() throws Exception {
|
||||
File foo = PlatformTestCase.createTempDir("foo");
|
||||
File foo = createTempDir("foo");
|
||||
Project project = null;
|
||||
MyStartupActivity activity = new MyStartupActivity();
|
||||
PlatformTestUtil.registerExtension(POST_STARTUP_ACTIVITY, activity, getTestRootDisposable());
|
||||
@@ -58,7 +44,7 @@ public class ProjectOpeningTest extends PlatformTestCase {
|
||||
}
|
||||
|
||||
public void testCancelOnLoadingModules() throws Exception {
|
||||
File foo = PlatformTestCase.createTempDir("foo");
|
||||
File foo = createTempDir("foo");
|
||||
Project project = null;
|
||||
try {
|
||||
ProjectManagerEx manager = ProjectManagerEx.getInstanceEx();
|
||||
|
||||
+4
-18
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.project.impl;
|
||||
|
||||
import com.intellij.ide.ProjectGroup;
|
||||
@@ -76,7 +62,7 @@ public class RecentProjectsTest extends PlatformTestCase {
|
||||
public void testTimestampForOpenProjectUpdatesWhenGetStateCalled() throws Exception {
|
||||
Project project = null;
|
||||
try {
|
||||
File path = PlatformTestCase.createTempDir("z1");
|
||||
File path = createTempDir("z1");
|
||||
ProjectManagerEx manager = ProjectManagerEx.getInstanceEx();
|
||||
project = manager.createProject(null, path.getPath());
|
||||
project.save();
|
||||
@@ -129,10 +115,10 @@ public class RecentProjectsTest extends PlatformTestCase {
|
||||
Assert.assertEquals(Arrays.toString(groups), Arrays.toString(recentGroups.toArray()));
|
||||
}
|
||||
|
||||
private static String createAndOpenProject(String name) throws IOException, JDOMException {
|
||||
private String createAndOpenProject(String name) throws IOException, JDOMException {
|
||||
Project project = null;
|
||||
try {
|
||||
File path = PlatformTestCase.createTempDir(name);
|
||||
File path = createTempDir(name);
|
||||
ProjectManagerEx manager = ProjectManagerEx.getInstanceEx();
|
||||
project = manager.createProject(null, path.getPath());
|
||||
project.save();
|
||||
|
||||
+3
-2
@@ -46,6 +46,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -159,7 +160,7 @@ public class FileEncodingTest extends PlatformTestCase implements TestDialog {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
|
||||
byte[] savedBytes = FileUtil.loadFileBytes(file);
|
||||
String saved = new String(savedBytes, CharsetToolkit.UTF8).replace("\r\n", "\n");
|
||||
String saved = new String(savedBytes, StandardCharsets.UTF_8).replace("\r\n", "\n");
|
||||
String expected = (UTF8_XML_PROLOG + XML_TEST_BODY).replace("\r\n", "\n");
|
||||
|
||||
assertEquals(expected, saved);
|
||||
@@ -238,7 +239,7 @@ public class FileEncodingTest extends PlatformTestCase implements TestDialog {
|
||||
"<meta charset =\"utf-8\">");
|
||||
}
|
||||
|
||||
private static void doHtmlTest(final String metaWithWindowsEncoding, final String metaWithUtf8Encoding) throws IOException {
|
||||
private void doHtmlTest(final String metaWithWindowsEncoding, final String metaWithUtf8Encoding) throws IOException {
|
||||
File temp = FileUtil.createTempFile("copy", ".html");
|
||||
setContentOnDisk(temp, NO_BOM,
|
||||
"<html><head>" + metaWithWindowsEncoding + "</head>" +
|
||||
|
||||
@@ -101,7 +101,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
|
||||
protected ProjectManagerEx myProjectManager;
|
||||
protected Project myProject;
|
||||
protected Module myModule;
|
||||
protected static final Collection<File> myFilesToDelete = new THashSet<>();
|
||||
protected final Collection<File> myFilesToDelete = new THashSet<>();
|
||||
protected boolean myAssertionsInTestDetected;
|
||||
public static Thread ourTestThread;
|
||||
private static TestCase ourTestCase;
|
||||
@@ -745,12 +745,12 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File createTempDir(@NonNls final String prefix) throws IOException {
|
||||
public File createTempDir(@NonNls @NotNull String prefix) throws IOException {
|
||||
return createTempDir(prefix, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File createTempDir(@NonNls final String prefix, final boolean refresh) throws IOException {
|
||||
public File createTempDir(@NonNls @NotNull String prefix, final boolean refresh) throws IOException {
|
||||
final File tempDirectory = FileUtilRt.createTempDirectory("idea_test_" + prefix, null, false);
|
||||
myFilesToDelete.add(tempDirectory);
|
||||
if (refresh) {
|
||||
@@ -797,7 +797,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static VirtualFile createTempFile(@NonNls @NotNull String ext, @Nullable byte[] bom, @NonNls @NotNull String content, @NotNull Charset charset) throws IOException {
|
||||
public VirtualFile createTempFile(@NonNls @NotNull String ext, @Nullable byte[] bom, @NonNls @NotNull String content, @NotNull Charset charset) throws IOException {
|
||||
File temp = FileUtil.createTempFile("copy", "." + ext);
|
||||
setContentOnDisk(temp, bom, content, charset);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
@@ -771,27 +772,33 @@ public class PlatformTestUtil {
|
||||
}
|
||||
|
||||
public static void assertJarFilesEqual(File file1, File file2) throws IOException {
|
||||
final File tempDirectory1;
|
||||
final File tempDirectory2;
|
||||
final File tempDir = FileUtilRt.createTempDirectory("assert_jar_tmp", null, false);
|
||||
try {
|
||||
final File tempDirectory1 = new File(tempDir, "tmp1");
|
||||
final File tempDirectory2 = new File(tempDir, "tmp2");
|
||||
FileUtilRt.createDirectory(tempDirectory1);
|
||||
FileUtilRt.createDirectory(tempDirectory2);
|
||||
|
||||
try (JarFile jarFile1 = new JarFile(file1)) {
|
||||
try (JarFile jarFile2 = new JarFile(file2)) {
|
||||
tempDirectory1 = PlatformTestCase.createTempDir("tmp1");
|
||||
tempDirectory2 = PlatformTestCase.createTempDir("tmp2");
|
||||
ZipUtil.extract(jarFile1, tempDirectory1, null);
|
||||
ZipUtil.extract(jarFile2, tempDirectory2, null);
|
||||
try (JarFile jarFile1 = new JarFile(file1)) {
|
||||
try (JarFile jarFile2 = new JarFile(file2)) {
|
||||
ZipUtil.extract(jarFile1, tempDirectory1, null);
|
||||
ZipUtil.extract(jarFile2, tempDirectory2, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final VirtualFile dirAfter = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDirectory1);
|
||||
Assert.assertNotNull(tempDirectory1.toString(), dirAfter);
|
||||
final VirtualFile dirBefore = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDirectory2);
|
||||
Assert.assertNotNull(tempDirectory2.toString(), dirBefore);
|
||||
getApplication().runWriteAction(() -> {
|
||||
dirAfter.refresh(false, true);
|
||||
dirBefore.refresh(false, true);
|
||||
});
|
||||
assertDirectoriesEqual(dirAfter, dirBefore);
|
||||
final VirtualFile dirAfter = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDirectory1);
|
||||
Assert.assertNotNull(tempDirectory1.toString(), dirAfter);
|
||||
final VirtualFile dirBefore = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDirectory2);
|
||||
Assert.assertNotNull(tempDirectory2.toString(), dirBefore);
|
||||
getApplication().runWriteAction(() -> {
|
||||
dirAfter.refresh(false, true);
|
||||
dirBefore.refresh(false, true);
|
||||
});
|
||||
assertDirectoriesEqual(dirAfter, dirBefore);
|
||||
}
|
||||
finally {
|
||||
FileUtilRt.delete(tempDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.vcs;
|
||||
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||
@@ -31,7 +17,6 @@ import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.File;
|
||||
@@ -73,10 +58,13 @@ public class DirectoryMappingListTest extends PlatformTestCase {
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myMappings.disposeMe();
|
||||
((AllVcses) myVcses).dispose();
|
||||
|
||||
super.tearDown();
|
||||
try {
|
||||
myMappings.disposeMe();
|
||||
((AllVcses)myVcses).dispose();
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
public void testMappingsFilter() {
|
||||
@@ -139,12 +127,12 @@ public class DirectoryMappingListTest extends PlatformTestCase {
|
||||
for (String child : children) {
|
||||
myMappings.setMapping(child, "CVS");
|
||||
myMappings.cleanupMappings();
|
||||
Assert.assertEquals("cleanup failed: " + child, 1, myMappings.getDirectoryMappings().size());
|
||||
assertEquals("cleanup failed: " + child, 1, myMappings.getDirectoryMappings().size());
|
||||
}
|
||||
|
||||
for (String child : children) {
|
||||
myMappings.setMapping(child, "CVS");
|
||||
Assert.assertEquals("cleanup failed: " + child, 1, myMappings.getDirectoryMappings().size());
|
||||
assertEquals("cleanup failed: " + child, 1, myMappings.getDirectoryMappings().size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +148,7 @@ public class DirectoryMappingListTest extends PlatformTestCase {
|
||||
for (String child : children) {
|
||||
myMappings.setMapping(child, "CVS");
|
||||
myMappings.cleanupMappings();
|
||||
Assert.assertEquals("cleanup failed: " + child, 1, myMappings.getDirectoryMappings().size());
|
||||
assertEquals("cleanup failed: " + child, 1, myMappings.getDirectoryMappings().size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,14 +168,14 @@ public class DirectoryMappingListTest extends PlatformTestCase {
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
String child = children[i];
|
||||
final VirtualFile vf = lfs.refreshAndFindFileByIoFile(new File(child));
|
||||
Assert.assertNotNull(vf);
|
||||
assertNotNull(vf);
|
||||
final VcsDirectoryMapping mapping = myMappings.getMappingFor(vf);
|
||||
Assert.assertNotNull(mapping);
|
||||
Assert.assertEquals(awaitedVcsNames[i], mapping.getVcs());
|
||||
assertNotNull(mapping);
|
||||
assertEquals(awaitedVcsNames[i], mapping.getVcs());
|
||||
}
|
||||
}
|
||||
|
||||
private static void createFiles(final String[] paths) {
|
||||
private void createFiles(final String[] paths) {
|
||||
for (String path : paths) {
|
||||
final File file = new File(FileUtil.toSystemDependentName(path));
|
||||
assert file.mkdirs() || file.isDirectory() : file;
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.util.concurrent.Future
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
abstract class VcsPlatformTest : PlatformTestCase() {
|
||||
|
||||
protected lateinit var testRoot: File
|
||||
protected lateinit var testRootFile: VirtualFile
|
||||
protected lateinit var projectRoot: VirtualFile
|
||||
@@ -50,8 +49,7 @@ abstract class VcsPlatformTest : PlatformTestCase() {
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
testRoot = File(FileUtil.getTempDirectory(), "root-${Integer.toHexString(Random().nextInt())}")
|
||||
PlatformTestCase.myFilesToDelete.add(testRoot)
|
||||
testRoot = createTempDir("root-${Integer.toHexString(Random().nextInt())}", false)
|
||||
checkTestRootIsEmpty(testRoot)
|
||||
|
||||
runInEdtAndWait { super@VcsPlatformTest.setUp() }
|
||||
|
||||
Reference in New Issue
Block a user