diff --git a/java/compiler/tests/com/intellij/compiler/BaseCompilerTestCase.java b/java/compiler/tests/com/intellij/compiler/BaseCompilerTestCase.java index f63247b30d18..f02e916b127b 100644 --- a/java/compiler/tests/com/intellij/compiler/BaseCompilerTestCase.java +++ b/java/compiler/tests/com/intellij/compiler/BaseCompilerTestCase.java @@ -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()); diff --git a/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java b/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java index 53642207de4a..99a155c2f476 100644 --- a/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java +++ b/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java @@ -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(); diff --git a/platform/configuration-store-impl/src/FileBasedStorage.kt b/platform/configuration-store-impl/src/FileBasedStorage.kt index c4c1e2f4f9f2..10584400c14c 100644 --- a/platform/configuration-store-impl/src/FileBasedStorage.kt +++ b/platform/configuration-store-impl/src/FileBasedStorage.kt @@ -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) { diff --git a/platform/platform-tests/testSrc/com/intellij/ide/fileTemplates/impl/LightFileTemplatesTest.java b/platform/platform-tests/testSrc/com/intellij/ide/fileTemplates/impl/LightFileTemplatesTest.java index c118818af7f1..9895ebf2a267 100644 --- a/platform/platform-tests/testSrc/com/intellij/ide/fileTemplates/impl/LightFileTemplatesTest.java +++ b/platform/platform-tests/testSrc/com/intellij/ide/fileTemplates/impl/LightFileTemplatesTest.java @@ -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); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/diff/impl/patch/PatchReaderTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/diff/impl/patch/PatchReaderTest.kt index 20775fef4af6..b6373161b078 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/diff/impl/patch/PatchReaderTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/openapi/diff/impl/patch/PatchReaderTest.kt @@ -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() diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/diff/impl/patch/PatchTextDetectionTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/diff/impl/patch/PatchTextDetectionTest.kt index bdb8e8f2f833..265cc62af3bb 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/diff/impl/patch/PatchTextDetectionTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/openapi/diff/impl/patch/PatchTextDetectionTest.kt @@ -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()))); } - } \ No newline at end of file diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/project/impl/ProjectOpeningTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/project/impl/ProjectOpeningTest.java index 1fb1b71c7eb2..dc371579d92f 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/project/impl/ProjectOpeningTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/project/impl/ProjectOpeningTest.java @@ -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(); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/project/impl/RecentProjectsTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/project/impl/RecentProjectsTest.java index 9977c3560dfa..21648f4fef1c 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/project/impl/RecentProjectsTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/project/impl/RecentProjectsTest.java @@ -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(); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/encoding/FileEncodingTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/encoding/FileEncodingTest.java index 863955449f36..4a360d5d0d21 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/encoding/FileEncodingTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/encoding/FileEncodingTest.java @@ -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 { ""); } - 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, "
" + metaWithWindowsEncoding + "" + diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java index e1c55a55b9f3..423c958a70ac 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java @@ -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