diff --git a/platform/platform-tests/testSrc/com/intellij/ide/updates/StartupActionScriptManagerTest.kt b/platform/platform-tests/testSrc/com/intellij/ide/updates/StartupActionScriptManagerTest.kt index 445a36a3c1e1..a52334b56f72 100644 --- a/platform/platform-tests/testSrc/com/intellij/ide/updates/StartupActionScriptManagerTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/ide/updates/StartupActionScriptManagerTest.kt @@ -5,10 +5,8 @@ import com.intellij.ide.startup.StartupActionScriptManager import com.intellij.openapi.application.PathManager import com.intellij.testFramework.PlatformTestUtil import com.intellij.testFramework.rules.TempDirectory -import com.intellij.testFramework.utils.io.deleteRecursively import com.intellij.util.io.Compressor import com.intellij.util.io.createDirectories -import com.intellij.util.io.createParentDirectories import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatCode import org.junit.After @@ -151,11 +149,10 @@ class StartupActionScriptManagerTest { assertThat(scriptFile).doesNotExist() } - @Test fun `executing marketplace commands only`() { - val tempDir = Files.createTempDirectory("test") // tempDir from class has 'marketplace' in path due to test name - val marketplaceSource = tempDir.resolve("marketplace/plugin.zip").createParentDirectories() + @Test fun `executing MP commands only`() { + val marketplaceSource = tempDir.newFileNio("marketplace/plugin.zip") Compressor.Zip(marketplaceSource).use { it.addFile("plugin/content.txt", byteArrayOf()) } - val marketplaceDestination = tempDir.resolve("plugins") + val marketplaceDestination = tempDir.newDirectoryPath("plugins") val unpacked = marketplaceDestination.resolve("plugin/content.txt") StartupActionScriptManager.addActionCommand(StartupActionScriptManager.UnzipCommand(marketplaceSource, marketplaceDestination)) @@ -163,13 +160,10 @@ class StartupActionScriptManagerTest { assertThat(unpacked).exists() assertThat(scriptFile).doesNotExist() - tempDir.deleteRecursively() } - @Test fun `preserving non-marketplace commands`() { - val tempDir = Files.createTempDirectory("test") // tempDir from class has 'marketplace' in path due to test name - val regularFile = tempDir.resolve("temp.txt").createParentDirectories() - Files.writeString(regularFile, "content") + @Test fun `preserving non-MP commands`() { + val regularFile = tempDir.newFileNio("temp.txt") assertThat(regularFile).exists() StartupActionScriptManager.addActionCommand(StartupActionScriptManager.DeleteCommand(regularFile)) @@ -178,18 +172,13 @@ class StartupActionScriptManagerTest { assertThat(regularFile).exists() assertThat(scriptFile).exists() assertThat(StartupActionScriptManager.loadActionScript(scriptFile)).hasSize(1) - tempDir.deleteRecursively() } - @Test fun `executing mixed marketplace and non-marketplace commands`() { - val tempDir = Files.createTempDirectory("test") // tempDir from class has 'marketplace' in path due to test name - val marketplaceCopySource = tempDir.resolve("marketplace/file.txt").createParentDirectories() - Files.writeString(marketplaceCopySource, "content") + @Test fun `executing mixed MP and non-MP commands`() { + val marketplaceCopySource = tempDir.newFileNio("marketplace/file.txt") val marketplaceCopyDest = marketplaceCopySource.resolveSibling("destination.txt") - val regularFile = tempDir.resolve("regular/temp.txt").createParentDirectories() - Files.writeString(regularFile, "content") - val marketplaceDeleteFile = tempDir.resolve("marketplace/old.txt").createParentDirectories() - Files.writeString(marketplaceDeleteFile, "old") + val regularFile = tempDir.newFileNio("regular/temp.txt") + val marketplaceDeleteFile = tempDir.newFileNio("marketplace/old.txt") assertThat(marketplaceCopySource).exists() assertThat(marketplaceCopyDest).doesNotExist() @@ -209,23 +198,21 @@ class StartupActionScriptManagerTest { assertThat(regularFile).exists() assertThat(scriptFile).exists() assertThat(StartupActionScriptManager.loadActionScript(scriptFile)).hasSize(1) - tempDir.deleteRecursively() } - @Test fun `executing marketplace commands from empty script`() { + @Test fun `executing MP commands from empty script`() { assertThatCode { StartupActionScriptManager.executeMarketplaceCommandsFromActionScript() }.doesNotThrowAnyException() assertThat(scriptFile).doesNotExist() } - @Test fun `updating marketplace plugin`() { - val tempDir = Files.createTempDirectory("test") // tempDir from class has 'marketplace' in path due to test name - val pluginsDir = tempDir.resolve("plugins") + @Test fun `updating MP plugin`() { + val pluginsDir = tempDir.newDirectoryPath("plugins") val oldMarketplaceDir = pluginsDir.resolve("marketplace") val oldFile = oldMarketplaceDir.resolve("old-version.txt") oldFile.parent.createDirectories() Files.writeString(oldFile, "old content") - val marketplaceZip = tempDir.resolve("marketplace-1.2.3.zip").createParentDirectories() + val marketplaceZip = tempDir.newFileNio("marketplace-1.2.3.zip") Compressor.Zip(marketplaceZip).use { zip -> zip.addFile("marketplace/new-version.txt", "new content".toByteArray()) zip.addFile("marketplace/plugin.xml", "".toByteArray()) @@ -252,7 +239,6 @@ class StartupActionScriptManagerTest { assertThat(pluginXml).exists() assertThat(marketplaceZip).doesNotExist() assertThat(scriptFile).doesNotExist() - tempDir.deleteRecursively() } }