mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[test framework] rename TempDirectory::newFolder to newDirectory for consistency
We use 'directory' term instead of 'folder' in API. GitOrigin-RevId: a3b8449a406e09dd93c15bfcce159a66de58ee3b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
32f220ab50
commit
b320836ff5
+1
-1
@@ -430,7 +430,7 @@ public abstract class NotNullVerifyingInstrumenterTest {
|
||||
protected Class<?> prepareTest(boolean withDebugInfo, boolean expectInstrumented, String... notNullAnnotations) throws IOException {
|
||||
String testName = PlatformTestUtil.getTestName(this.testName.getMethodName(), false);
|
||||
File testFile = IdeaTestUtil.findSourceFile((JavaTestUtil.getJavaTestDataPath() + TEST_DATA_PATH) + testName);
|
||||
File classesDir = tempDir.newFolder("output");
|
||||
File classesDir = tempDir.newDirectory("output");
|
||||
List<String> args = ContainerUtil.newArrayList("-cp", annotation.classes.getPath());
|
||||
if (withDebugInfo) args.add("-g");
|
||||
IdeaTestUtil.compileFile(testFile, classesDir, ArrayUtil.toStringArray(args));
|
||||
|
||||
@@ -47,7 +47,7 @@ public class JrtFileSystemTest extends BareTestFixtureTestCase {
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
myTestData = Paths.get(JavaTestUtil.getJavaTestDataPath(), "jrt");
|
||||
myJrtPath = tempDir.newFolder("jrt").toPath();
|
||||
myJrtPath = tempDir.newDirectory("jrt").toPath();
|
||||
|
||||
setupJrtFileSystem();
|
||||
myRoot = findRoot(myJrtPath.toString());
|
||||
|
||||
@@ -176,7 +176,7 @@ public class GeneralCommandLineTest {
|
||||
assumeTrue(uni != null);
|
||||
assumeTrue(SystemInfo.isWindows || Objects.equals(System.getProperty("sun.jnu.encoding"), System.getProperty("file.encoding")));
|
||||
|
||||
File dir = tempDir.newFolder("spaces 'and quotes' and " + uni);
|
||||
File dir = tempDir.newDirectory("spaces 'and quotes' and " + uni);
|
||||
Pair<GeneralCommandLine, File> command = makeHelperCommand(dir, CommandTestHelper.ARG, "test");
|
||||
String output = execHelper(command);
|
||||
assertEquals("test\n", StringUtil.convertLineSeparators(output));
|
||||
|
||||
+3
-3
@@ -63,7 +63,7 @@ class StartupActionScriptManagerTest : BareTestFixtureTestCase() {
|
||||
|
||||
@Test fun `executing "unzip" command`() {
|
||||
val source = IoTestUtil.createTestJar(tempDir.newFile("source.zip"), "zip/file.txt", "")
|
||||
val destination = tempDir.newFolder("dir")
|
||||
val destination = tempDir.newDirectory("dir")
|
||||
val unpacked = File(destination, "zip/file.txt")
|
||||
assertTrue(source.exists())
|
||||
assertFalse(unpacked.exists())
|
||||
@@ -84,8 +84,8 @@ class StartupActionScriptManagerTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun `executing commands with path mapping`() {
|
||||
val oldTarget = tempDir.newFolder("old/plugins")
|
||||
val newTarget = tempDir.newFolder("new/plugins")
|
||||
val oldTarget = tempDir.newDirectory("old/plugins")
|
||||
val newTarget = tempDir.newDirectory("new/plugins")
|
||||
val copySource = tempDir.newFile("source.txt")
|
||||
val copyDestinationInOld = File(oldTarget, "destination.txt")
|
||||
val copyDestinationInNew = File(newTarget, "destination.txt")
|
||||
|
||||
+4
-6
@@ -2,7 +2,6 @@
|
||||
package com.intellij.openapi.application
|
||||
|
||||
import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.openapi.application.ConfigImportHelper.PathAndFileTime
|
||||
import com.intellij.openapi.components.StoragePathMacros
|
||||
import com.intellij.openapi.components.stateStore
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
@@ -15,7 +14,6 @@ import com.intellij.util.SystemProperties
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Condition
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.junit.Assume.assumeTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -137,11 +135,11 @@ class ConfigImportHelperTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun `migrate plugins to empty directory`() {
|
||||
val oldConfigDir = localTempDir.newFolder("oldConfig").toPath()
|
||||
val oldConfigDir = localTempDir.newDirectory("oldConfig").toPath()
|
||||
val oldPluginsDir = Files.createDirectories(oldConfigDir.resolve("plugins"))
|
||||
val oldPluginZip = Files.createFile(oldPluginsDir.resolve("my-plugin.zip"))
|
||||
|
||||
val newConfigDir = localTempDir.newFolder("newConfig").toPath()
|
||||
val newConfigDir = localTempDir.newDirectory("newConfig").toPath()
|
||||
val newPluginsDir = newConfigDir.resolve("plugins")
|
||||
|
||||
ConfigImportHelper.doImport(oldConfigDir, newConfigDir, null, oldPluginsDir, newPluginsDir, LOG)
|
||||
@@ -149,11 +147,11 @@ class ConfigImportHelperTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun `do not migrate plugins to existing directory`() {
|
||||
val oldConfigDir = localTempDir.newFolder("oldConfig").toPath()
|
||||
val oldConfigDir = localTempDir.newDirectory("oldConfig").toPath()
|
||||
val oldPluginsDir = Files.createDirectories(oldConfigDir.resolve("plugins"))
|
||||
val oldPluginZip = Files.createFile(oldPluginsDir.resolve("old-plugin.zip"))
|
||||
|
||||
val newConfigDir = localTempDir.newFolder("newConfig").toPath()
|
||||
val newConfigDir = localTempDir.newDirectory("newConfig").toPath()
|
||||
val newPluginsDir = Files.createDirectories(newConfigDir.resolve("plugins"))
|
||||
val newPluginZip = Files.createFile(newPluginsDir.resolve("new-plugin.zip"))
|
||||
|
||||
|
||||
+3
-3
@@ -53,7 +53,7 @@ public class VfsUtilPerformanceTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testFindChildByNamePerformance() throws IOException {
|
||||
File tempDir = myTempDir.newFolder();
|
||||
File tempDir = myTempDir.newDirectory();
|
||||
VirtualFile vDir = LocalFileSystem.getInstance().findFileByIoFile(tempDir);
|
||||
assertNotNull(vDir);
|
||||
assertTrue(vDir.isDirectory());
|
||||
@@ -109,7 +109,7 @@ public class VfsUtilPerformanceTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testGetParentPerformance() throws IOException {
|
||||
File tempDir = myTempDir.newFolder();
|
||||
File tempDir = myTempDir.newDirectory();
|
||||
VirtualFile vDir = LocalFileSystem.getInstance().findFileByIoFile(tempDir);
|
||||
assertNotNull(vDir);
|
||||
assertTrue(vDir.isDirectory());
|
||||
@@ -203,7 +203,7 @@ public class VfsUtilPerformanceTest extends BareTestFixtureTestCase {
|
||||
private void doAsyncRefreshTest() throws Exception {
|
||||
byte[] xxx = "xxx".getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
File temp = myTempDir.newFolder();
|
||||
File temp = myTempDir.newDirectory();
|
||||
LocalFileSystem fs = LocalFileSystem.getInstance();
|
||||
VirtualFile vTemp = fs.findFileByIoFile(temp);
|
||||
assertNotNull(vTemp);
|
||||
|
||||
@@ -101,7 +101,7 @@ public class VfsUtilTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testFindChildWithTrailingSpace() throws IOException {
|
||||
File tempDir = myTempDir.newFolder();
|
||||
File tempDir = myTempDir.newDirectory();
|
||||
VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir);
|
||||
assertNotNull(vDir);
|
||||
assertTrue(vDir.isDirectory());
|
||||
@@ -232,7 +232,7 @@ public class VfsUtilTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testNotCanonicallyNamedChild() throws IOException {
|
||||
File tempDir = myTempDir.newFolder();
|
||||
File tempDir = myTempDir.newDirectory();
|
||||
assertTrue(new File(tempDir, "libFiles").createNewFile());
|
||||
assertTrue(new File(tempDir, "CssInvalidElement").createNewFile());
|
||||
assertTrue(new File(tempDir, "extFiles").createNewFile());
|
||||
@@ -267,7 +267,7 @@ public class VfsUtilTest extends BareTestFixtureTestCase {
|
||||
private void doRenameAndRefreshTest(boolean full) throws IOException {
|
||||
assertFalse(ApplicationManager.getApplication().isDispatchThread());
|
||||
|
||||
File tempDir = myTempDir.newFolder();
|
||||
File tempDir = myTempDir.newDirectory();
|
||||
assertTrue(new File(tempDir, "child").createNewFile());
|
||||
|
||||
VirtualFile parent = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir);
|
||||
@@ -338,7 +338,7 @@ public class VfsUtilTest extends BareTestFixtureTestCase {
|
||||
assertSame(test, ProjectManager.getInstance());
|
||||
|
||||
try {
|
||||
final File temp = myTempDir.newFolder();
|
||||
final File temp = myTempDir.newDirectory();
|
||||
VirtualDirectoryImpl vTemp = (VirtualDirectoryImpl)LocalFileSystem.getInstance().refreshAndFindFileByIoFile(temp);
|
||||
assertNotNull(vTemp);
|
||||
vTemp.getChildren(); //to force full dir refresh?!
|
||||
@@ -399,8 +399,8 @@ public class VfsUtilTest extends BareTestFixtureTestCase {
|
||||
|
||||
private void checkNonModalThenModalRefresh(boolean waitForDiskRefreshCompletionBeforeStartingModality) {
|
||||
EdtTestUtil.runInEdtAndWait(() -> {
|
||||
File dir1 = myTempDir.newFolder("dir1");
|
||||
File dir2 = myTempDir.newFolder("dir2");
|
||||
File dir1 = myTempDir.newDirectory("dir1");
|
||||
File dir2 = myTempDir.newDirectory("dir2");
|
||||
VirtualFile vDir = VfsUtil.findFileByIoFile(myTempDir.getRoot(), true);
|
||||
assertThat(Stream.of(vDir.getChildren()).map(VirtualFile::getName)).containsExactly(dir1.getName(), dir2.getName());
|
||||
VirtualFile vDir1 = vDir.getChildren()[0];
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public class VirtualFileListenerTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testFireEvent() throws IOException {
|
||||
VirtualFile dir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(myTempDir.newFolder("vDir"));
|
||||
VirtualFile dir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(myTempDir.newDirectory("vDir"));
|
||||
assertNotNull(dir);
|
||||
dir.getChildren();
|
||||
|
||||
|
||||
+4
-4
@@ -218,7 +218,7 @@ public class VirtualFilePointerTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testMovePointedFile() throws IOException {
|
||||
File moveTarget = tempDir.newFolder("moveTarget");
|
||||
File moveTarget = tempDir.newDirectory("moveTarget");
|
||||
File fileToMove = tempDir.newFile("toMove.txt");
|
||||
|
||||
LoggingListener fileToMoveListener = new LoggingListener();
|
||||
@@ -231,7 +231,7 @@ public class VirtualFilePointerTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testMoveFileUnderExistingPointer() throws IOException {
|
||||
File moveTarget = tempDir.newFolder("moveTarget");
|
||||
File moveTarget = tempDir.newDirectory("moveTarget");
|
||||
File fileToMove = tempDir.newFile("toMove.txt");
|
||||
|
||||
LoggingListener listener = new LoggingListener();
|
||||
@@ -244,7 +244,7 @@ public class VirtualFilePointerTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testMoveSrcDirUnderNewRootShouldGenerateRootsChanged() throws IOException {
|
||||
File moveTarget = tempDir.newFolder("moveTarget");
|
||||
File moveTarget = tempDir.newDirectory("moveTarget");
|
||||
File dirToMove = tempDir.newFile("dirToMove");
|
||||
|
||||
LoggingListener listener = new LoggingListener();
|
||||
@@ -257,7 +257,7 @@ public class VirtualFilePointerTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testMovePointedFileUnderAnotherPointer() throws IOException {
|
||||
File moveTarget = tempDir.newFolder("moveTarget");
|
||||
File moveTarget = tempDir.newDirectory("moveTarget");
|
||||
File fileToMove = tempDir.newFile("toMove.txt");
|
||||
|
||||
LoggingListener listener = new LoggingListener();
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ public class CanonicalPathMapTest {
|
||||
IoTestUtil.assumeSymLinkCreationIsSupported();
|
||||
|
||||
// Tests the situation where the watch root is a symlink AND REMAPPED by the native file watcher.
|
||||
File realDir = myTempDir.newFolder("real");
|
||||
File realDir = myTempDir.newDirectory("real");
|
||||
File symLink = IoTestUtil.createSymLink(realDir.getPath(), myTempDir.getRoot() + "/link");
|
||||
File mappedDir = new File(myTempDir.getRoot(), "mapped");
|
||||
|
||||
|
||||
+3
-3
@@ -58,17 +58,17 @@ class FileWatcherPerformanceTest : BareTestFixtureTestCase() {
|
||||
var watchedTime = 0L
|
||||
|
||||
for (i in 1..WARM_UPS) {
|
||||
createDeleteFiles(tempDir.newFolder())
|
||||
createDeleteFiles(tempDir.newDirectory())
|
||||
}
|
||||
|
||||
for (i in 1..REPEATS) {
|
||||
TimeoutUtil.sleep(250)
|
||||
|
||||
val unwatchedDir = tempDir.newFolder()
|
||||
val unwatchedDir = tempDir.newDirectory()
|
||||
unwatchedTime += time { createDeleteFiles(unwatchedDir) }
|
||||
TimeoutUtil.sleep(250)
|
||||
|
||||
val watchedDir = tempDir.newFolder()
|
||||
val watchedDir = tempDir.newDirectory()
|
||||
val request = startWatcher(watchedDir)
|
||||
watchedTime += time { createDeleteFiles(watchedDir) }
|
||||
waitForEvents()
|
||||
|
||||
@@ -108,7 +108,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
//</editor-fold>
|
||||
|
||||
@Test fun testWatchRequestConvention() {
|
||||
val dir = tempDir.newFolder("dir")
|
||||
val dir = tempDir.newDirectory("dir")
|
||||
val r1 = watch(dir)
|
||||
val r2 = watch(dir)
|
||||
assertNotSame(r1, r2)
|
||||
@@ -147,7 +147,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testDirectoryRecursive() {
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val sub = File(top, "sub")
|
||||
val file = File(sub, "test.txt")
|
||||
refresh(top)
|
||||
@@ -162,7 +162,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testDirectoryFlat() {
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val watchedFile = tempDir.newFile("top/test.txt")
|
||||
val unwatchedFile = tempDir.newFile("top/sub/test.txt")
|
||||
refresh(top)
|
||||
@@ -173,8 +173,8 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testDirectoryMixed() {
|
||||
val top = tempDir.newFolder("top")
|
||||
val sub = tempDir.newFolder("top/sub2")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val sub = tempDir.newDirectory("top/sub2")
|
||||
val unwatchedFile = tempDir.newFile("top/sub1/test.txt")
|
||||
val watchedFile1 = tempDir.newFile("top/test.txt")
|
||||
val watchedFile2 = tempDir.newFile("top/sub2/sub/test.txt")
|
||||
@@ -188,12 +188,12 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testMove() {
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val srcFile = tempDir.newFile("top/src/f")
|
||||
val srcDir = tempDir.newFolder("top/src/sub")
|
||||
val srcDir = tempDir.newDirectory("top/src/sub")
|
||||
tempDir.newFile("top/src/sub/f1")
|
||||
tempDir.newFile("top/src/sub/f2")
|
||||
val dst = tempDir.newFolder("top/dst")
|
||||
val dst = tempDir.newDirectory("top/dst")
|
||||
val dstFile = File(dst, srcFile.name)
|
||||
val dstDir = File(dst, srcDir.name)
|
||||
refresh(top)
|
||||
@@ -204,7 +204,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testIncorrectPath() {
|
||||
val root = tempDir.newFolder("root")
|
||||
val root = tempDir.newDirectory("root")
|
||||
val file = tempDir.newFile("root/file.zip")
|
||||
val pseudoDir = File(file.parent, "sub/zip")
|
||||
refresh(root)
|
||||
@@ -214,11 +214,11 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testDirectoryOverlapping() {
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val topFile = tempDir.newFile("top/file1.txt")
|
||||
val sub = tempDir.newFolder("top/sub")
|
||||
val sub = tempDir.newDirectory("top/sub")
|
||||
val subFile = tempDir.newFile("top/sub/file2.txt")
|
||||
val side = tempDir.newFolder("side")
|
||||
val side = tempDir.newDirectory("side")
|
||||
val sideFile = tempDir.newFile("side/file3.txt")
|
||||
refresh(top)
|
||||
refresh(side)
|
||||
@@ -252,8 +252,8 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testSymbolicLinkIntoFlatRoot() {
|
||||
assumeSymLinkCreationIsSupported()
|
||||
|
||||
val root = tempDir.newFolder("root")
|
||||
val cDir = tempDir.newFolder("root/A/B/C")
|
||||
val root = tempDir.newDirectory("root")
|
||||
val cDir = tempDir.newDirectory("root/A/B/C")
|
||||
val aLink = File(root, "aLink")
|
||||
Files.createSymbolicLink(aLink.toPath(), Paths.get("${root.path}/A"))
|
||||
val flatWatchedFile = tempDir.newFile("root/aLink/test.txt")
|
||||
@@ -269,7 +269,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testMultipleSymbolicLinkPathsToFile() {
|
||||
assumeSymLinkCreationIsSupported()
|
||||
|
||||
val root = tempDir.newFolder("root")
|
||||
val root = tempDir.newDirectory("root")
|
||||
val file = tempDir.newFile("root/A/B/C/test.txt")
|
||||
val bLink = File(root, "bLink")
|
||||
Files.createSymbolicLink(bLink.toPath(), Paths.get("${root.path}/A/B"))
|
||||
@@ -289,7 +289,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testSymbolicLinkWatchRoot() {
|
||||
assumeSymLinkCreationIsSupported()
|
||||
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt")
|
||||
val link = Files.createSymbolicLink(Paths.get(top.path, "link"), Paths.get("${top.path}/dir1/dir2")).toFile()
|
||||
val fileLink = File(top, "link/dir3/test.txt")
|
||||
@@ -304,7 +304,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testSymbolicLinkAboveWatchRoot() {
|
||||
assumeSymLinkCreationIsSupported()
|
||||
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt")
|
||||
val link = Files.createSymbolicLink(Paths.get(top.path, "link"), Paths.get("${top.path}/dir1/dir2")).toFile()
|
||||
val watchRoot = File(link, "dir3")
|
||||
@@ -320,7 +320,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testJunctionWatchRoot() {
|
||||
assumeWindows()
|
||||
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt")
|
||||
val junctionPath = "${top}/link"
|
||||
val junction = IoTestUtil.createJunction("${top.path}/dir1/dir2", junctionPath)
|
||||
@@ -341,7 +341,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testJunctionAboveWatchRoot() {
|
||||
assumeWindows()
|
||||
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt")
|
||||
val junctionPath = "${top}/link"
|
||||
IoTestUtil.createJunction("${top.path}/dir1/dir2", junctionPath)
|
||||
@@ -364,7 +364,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testSymlinkBelowWatchRoot() {
|
||||
assumeSymLinkCreationIsSupported()
|
||||
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt")
|
||||
val link = Files.createSymbolicLink(Paths.get(top.path, "link"), Paths.get("${top.path}/dir1/dir2")).toFile()
|
||||
val fileLink = File(link, "dir3/" + file.name)
|
||||
@@ -379,8 +379,8 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testCircularSymlinkBelowWatchRoot() {
|
||||
assumeSymLinkCreationIsSupported()
|
||||
|
||||
val top = tempDir.newFolder("top")
|
||||
val topA = tempDir.newFolder("top/a")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val topA = tempDir.newDirectory("top/a")
|
||||
val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt")
|
||||
val link = Files.createSymbolicLink(Paths.get(topA.path, "link"), Paths.get("${top.path}/dir1/dir2")).toFile()
|
||||
val link2 = Files.createSymbolicLink(Paths.get(file.parent, "dir4"), Paths.get(topA.path)).toFile()
|
||||
@@ -403,7 +403,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testSymlinkBelowWatchRootCreation() {
|
||||
assumeSymLinkCreationIsSupported()
|
||||
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt")
|
||||
val link = File(top, "link")
|
||||
val fileLink = File(link, "dir3/" + file.name)
|
||||
@@ -421,7 +421,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testJunctionBelowWatchRoot() {
|
||||
assumeWindows()
|
||||
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt")
|
||||
val link = IoTestUtil.createJunction("${top.path}/dir1/dir2", "${top.path}/link")
|
||||
val fileLink = File(link, "dir3/" + file.name)
|
||||
@@ -436,7 +436,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testJunctionBelowWatchRootCreation() {
|
||||
assumeWindows()
|
||||
|
||||
val top = tempDir.newFolder("top")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt")
|
||||
val link = File(top, "link")
|
||||
val fileLink = File(link, "dir3/" + file.name)
|
||||
@@ -454,7 +454,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testSubst() {
|
||||
assumeWindows()
|
||||
|
||||
val target = tempDir.newFolder("top")
|
||||
val target = tempDir.newDirectory("top")
|
||||
val file = tempDir.newFile("top/sub/test.txt")
|
||||
|
||||
val substRoot = IoTestUtil.createSubst(target.path)
|
||||
@@ -485,8 +485,8 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testDirectoryRecreation() {
|
||||
val root = tempDir.newFolder("root")
|
||||
val dir = tempDir.newFolder("root/dir")
|
||||
val root = tempDir.newDirectory("root")
|
||||
val dir = tempDir.newDirectory("root/dir")
|
||||
val file1 = tempDir.newFile("root/dir/file1.txt")
|
||||
val file2 = tempDir.newFile("root/dir/file2.txt")
|
||||
refresh(root)
|
||||
@@ -501,7 +501,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testWatchRootRecreation() {
|
||||
val root = tempDir.newFolder("root")
|
||||
val root = tempDir.newDirectory("root")
|
||||
val file1 = tempDir.newFile("root/file1.txt")
|
||||
val file2 = tempDir.newFile("root/file2.txt")
|
||||
refresh(root)
|
||||
@@ -527,8 +527,8 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testWatchRootRenameRemove() {
|
||||
val top = tempDir.newFolder("top")
|
||||
val root = tempDir.newFolder("top/d1/d2/d3/root")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val root = tempDir.newDirectory("top/d1/d2/d3/root")
|
||||
val root2 = File(top, "root2")
|
||||
refresh(top)
|
||||
|
||||
@@ -542,8 +542,8 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testSwitchingToFsRoot() {
|
||||
val top = tempDir.newFolder("top")
|
||||
val root = tempDir.newFolder("top/root")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val root = tempDir.newDirectory("top/root")
|
||||
val file1 = tempDir.newFile("top/1.txt")
|
||||
val file2 = tempDir.newFile("top/root/2.txt")
|
||||
refresh(top)
|
||||
@@ -566,7 +566,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testLineBreaksInName() {
|
||||
assumeTrue("Expected Unix but got: " + SystemInfo.getOsNameAndVersion(), SystemInfo.isUnix)
|
||||
|
||||
val root = tempDir.newFolder("root")
|
||||
val root = tempDir.newDirectory("root")
|
||||
val file = tempDir.newFile("root/weird\ndir\nname/weird\nfile\nname")
|
||||
refresh(root)
|
||||
|
||||
@@ -577,7 +577,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testHiddenFiles() {
|
||||
assumeWindows()
|
||||
|
||||
val root = tempDir.newFolder("root")
|
||||
val root = tempDir.newDirectory("root")
|
||||
val file = tempDir.newFile("root/dir/file")
|
||||
refresh(root)
|
||||
|
||||
@@ -588,7 +588,7 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testFileCaseChange() {
|
||||
assumeTrue("case-insensitive FS only", !SystemInfo.isFileSystemCaseSensitive)
|
||||
|
||||
val root = tempDir.newFolder("root")
|
||||
val root = tempDir.newDirectory("root")
|
||||
val file = tempDir.newFile("root/file.txt")
|
||||
val newFile = File(file.parent, StringUtil.capitalize(file.name))
|
||||
refresh(root)
|
||||
@@ -598,16 +598,16 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
// tests the same scenarios with an active file watcher (prevents explicit marking of refreshed paths)
|
||||
@Test fun testPartialRefresh(): Unit = LocalFileSystemTest.doTestPartialRefresh(tempDir.newFolder("top"))
|
||||
@Test fun testInterruptedRefresh(): Unit = LocalFileSystemTest.doTestInterruptedRefresh(tempDir.newFolder("top"))
|
||||
@Test fun testRefreshAndFindFile(): Unit = LocalFileSystemTest.doTestRefreshAndFindFile(tempDir.newFolder("top"))
|
||||
@Test fun testRefreshEquality(): Unit = LocalFileSystemTest.doTestRefreshEquality(tempDir.newFolder("top"))
|
||||
@Test fun testPartialRefresh(): Unit = LocalFileSystemTest.doTestPartialRefresh(tempDir.newDirectory("top"))
|
||||
@Test fun testInterruptedRefresh(): Unit = LocalFileSystemTest.doTestInterruptedRefresh(tempDir.newDirectory("top"))
|
||||
@Test fun testRefreshAndFindFile(): Unit = LocalFileSystemTest.doTestRefreshAndFindFile(tempDir.newDirectory("top"))
|
||||
@Test fun testRefreshEquality(): Unit = LocalFileSystemTest.doTestRefreshEquality(tempDir.newDirectory("top"))
|
||||
|
||||
@Test fun testUnicodePaths() {
|
||||
val name = IoTestUtil.getUnicodeName()
|
||||
assumeTrue("Unicode names not supported", name != null)
|
||||
|
||||
val root = tempDir.newFolder(name!!)
|
||||
val root = tempDir.newDirectory(name!!)
|
||||
val file = tempDir.newFile("${name}/${name}.txt")
|
||||
refresh(root)
|
||||
watch(root)
|
||||
@@ -618,8 +618,8 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
@Test fun testDisplacementByIsomorphicTree() {
|
||||
assumeTrue("Expected not Mac but got: " + SystemInfo.getOsNameAndVersion(), !SystemInfo.isMac)
|
||||
|
||||
val top = tempDir.newFolder("top")
|
||||
val root = tempDir.newFolder("top/root")
|
||||
val top = tempDir.newDirectory("top")
|
||||
val root = tempDir.newDirectory("top/root")
|
||||
val file = tempDir.newFile("top/root/middle/file.txt")
|
||||
file.writeText("original content")
|
||||
val root_copy = File(top, "root_copy")
|
||||
@@ -640,8 +640,8 @@ class FileWatcherTest : BareTestFixtureTestCase() {
|
||||
}
|
||||
|
||||
@Test fun testWatchRootReplacement() {
|
||||
val root1 = tempDir.newFolder("top/root1")
|
||||
val root2 = tempDir.newFolder("top/root2")
|
||||
val root1 = tempDir.newDirectory("top/root1")
|
||||
val root2 = tempDir.newDirectory("top/root2")
|
||||
val file1 = tempDir.newFile("top/root1/file.txt")
|
||||
val file2 = tempDir.newFile("top/root2/file.txt")
|
||||
refresh(file1)
|
||||
|
||||
+1
-1
@@ -277,7 +277,7 @@ public class JarFileSystemTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testEnormousFileInputStream() throws IOException {
|
||||
File root = tempDir.newFolder("out");
|
||||
File root = tempDir.newDirectory("out");
|
||||
FileUtil.writeToFile(new File(root, "small1"), "some text");
|
||||
FileUtil.writeToFile(new File(root, "small2"), "another text");
|
||||
try (InputStream is = new ZeroInputStream(); OutputStream os = new FileOutputStream(new File(root, "large"))) {
|
||||
|
||||
+15
-15
@@ -88,7 +88,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testBasics() throws IOException {
|
||||
VirtualFile dir = PlatformTestUtil.notNull(myFS.refreshAndFindFileByIoFile(tempDir.newFolder("xxx")));
|
||||
VirtualFile dir = PlatformTestUtil.notNull(myFS.refreshAndFindFileByIoFile(tempDir.newDirectory("xxx")));
|
||||
assertTrue(dir.isValid());
|
||||
assertEquals(0, dir.getChildren().length);
|
||||
|
||||
@@ -106,7 +106,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testChildrenAccessedButNotCached() throws IOException {
|
||||
File dir = tempDir.newFolder("xxx");
|
||||
File dir = tempDir.newDirectory("xxx");
|
||||
ManagingFS managingFS = ManagingFS.getInstance();
|
||||
|
||||
VirtualFile vFile = myFS.refreshAndFindFileByPath(dir.getPath());
|
||||
@@ -154,7 +154,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testRefreshAndFindFile() throws IOException {
|
||||
doTestRefreshAndFindFile(tempDir.newFolder("top"));
|
||||
doTestRefreshAndFindFile(tempDir.newDirectory("top"));
|
||||
}
|
||||
|
||||
public static void doTestRefreshAndFindFile(@NotNull File tempDir) throws IOException {
|
||||
@@ -179,7 +179,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testRefreshEquality() throws IOException {
|
||||
doTestRefreshEquality(tempDir.newFolder("top"));
|
||||
doTestRefreshEquality(tempDir.newDirectory("top"));
|
||||
}
|
||||
|
||||
public static void doTestRefreshEquality(@NotNull File tempDir) throws IOException {
|
||||
@@ -213,8 +213,8 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
@Test
|
||||
public void testCopyFile() {
|
||||
runInEdtAndWait(() -> {
|
||||
File fromDir = tempDir.newFolder("from");
|
||||
File toDir = tempDir.newFolder("to");
|
||||
File fromDir = tempDir.newDirectory("from");
|
||||
File toDir = tempDir.newDirectory("to");
|
||||
|
||||
VirtualFile fromVDir = myFS.refreshAndFindFileByIoFile(fromDir);
|
||||
VirtualFile toVDir = myFS.refreshAndFindFileByIoFile(toDir);
|
||||
@@ -233,8 +233,8 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
@Test
|
||||
public void testCopyDir() {
|
||||
runInEdtAndWait(() -> {
|
||||
File fromDir = tempDir.newFolder("from");
|
||||
File toDir = tempDir.newFolder("to");
|
||||
File fromDir = tempDir.newDirectory("from");
|
||||
File toDir = tempDir.newDirectory("to");
|
||||
|
||||
VirtualFile fromVDir = myFS.refreshAndFindFileByIoFile(fromDir);
|
||||
VirtualFile toVDir = myFS.refreshAndFindFileByIoFile(toDir);
|
||||
@@ -499,7 +499,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
@Test
|
||||
public void testFindRootWithDeepNestedFileMustThrow() {
|
||||
try {
|
||||
File d = tempDir.newFolder();
|
||||
File d = tempDir.newDirectory();
|
||||
VirtualFile vDir = Objects.requireNonNull(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(d));
|
||||
ManagingFS.getInstance().findRoot(vDir.getPath(), myFS);
|
||||
fail("should fail by assertion in PersistentFsImpl.findRoot()");
|
||||
@@ -512,7 +512,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testCopyToPointDir() throws IOException {
|
||||
File sub = tempDir.newFolder("sub");
|
||||
File sub = tempDir.newDirectory("sub");
|
||||
File file = tempDir.newFile("file.txt");
|
||||
|
||||
VirtualFile topDir = myFS.refreshAndFindFileByIoFile(tempDir.getRoot());
|
||||
@@ -579,7 +579,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testPartialRefresh() throws IOException {
|
||||
doTestPartialRefresh(tempDir.newFolder("top"));
|
||||
doTestPartialRefresh(tempDir.newDirectory("top"));
|
||||
}
|
||||
|
||||
public static void doTestPartialRefresh(@NotNull File top) throws IOException {
|
||||
@@ -627,7 +627,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
public void testSymlinkTargetBlink() throws IOException {
|
||||
assumeSymLinkCreationIsSupported();
|
||||
|
||||
File target = tempDir.newFolder("target");
|
||||
File target = tempDir.newDirectory("target");
|
||||
File link = new File(tempDir.getRoot(), "link");
|
||||
Files.createSymbolicLink(link.toPath(), target.toPath()).toFile();
|
||||
|
||||
@@ -662,7 +662,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testInterruptedRefresh() throws IOException {
|
||||
doTestInterruptedRefresh(tempDir.newFolder("top"));
|
||||
doTestInterruptedRefresh(tempDir.newDirectory("top"));
|
||||
}
|
||||
|
||||
public static void doTestInterruptedRefresh(@NotNull File top) throws IOException {
|
||||
@@ -761,10 +761,10 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
assumeSymLinkCreationIsSupported();
|
||||
|
||||
runInEdtAndWait(() -> {
|
||||
File srcDir = tempDir.newFolder("src");
|
||||
File srcDir = tempDir.newDirectory("src");
|
||||
File link = new File(tempDir.getRoot(), "link");
|
||||
Files.createSymbolicLink(link.toPath(), new File(tempDir.getRoot(), "missing").toPath());
|
||||
File dstDir = tempDir.newFolder("dst");
|
||||
File dstDir = tempDir.newDirectory("dst");
|
||||
|
||||
VirtualFile file = myFS.refreshAndFindFileByIoFile(link);
|
||||
assertNotNull(file);
|
||||
|
||||
+15
-15
@@ -74,7 +74,7 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testCircularLink() throws Exception {
|
||||
File upDir = myTempDir.newFolder("sub");
|
||||
File upDir = myTempDir.newDirectory("sub");
|
||||
File upLinkFile = createSymLink(upDir.getPath(), upDir.getPath() + "/up_link");
|
||||
VirtualFile upLinkVFile = refreshAndFind(upLinkFile);
|
||||
assertNotNull(upLinkVFile);
|
||||
@@ -95,8 +95,8 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testMutualRecursiveLinks() throws Exception {
|
||||
File circularDir1 = myTempDir.newFolder("dir1");
|
||||
File circularDir2 = myTempDir.newFolder("dir2");
|
||||
File circularDir1 = myTempDir.newDirectory("dir1");
|
||||
File circularDir2 = myTempDir.newDirectory("dir2");
|
||||
File circularLink1 = createSymLink(circularDir2.getPath(), circularDir1 + "/link1");
|
||||
File circularLink2 = createSymLink(circularDir1.getPath(), circularDir2 + "/link2");
|
||||
VirtualFile circularLink1VFile = refreshAndFind(circularLink1);
|
||||
@@ -109,7 +109,7 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testDuplicateLinks() throws Exception {
|
||||
File targetDir = myTempDir.newFolder("target");
|
||||
File targetDir = myTempDir.newDirectory("target");
|
||||
File link1 = createSymLink(targetDir.getPath(), myTempDir.getRoot() + "/link1");
|
||||
File link2 = createSymLink(targetDir.getPath(), myTempDir.getRoot() + "/link2");
|
||||
assertVisitedPaths(targetDir.getPath(), link1.getPath(), link2.getPath());
|
||||
@@ -117,10 +117,10 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testSidewaysRecursiveLink() throws Exception {
|
||||
File a = myTempDir.newFolder("a");
|
||||
File a = myTempDir.newDirectory("a");
|
||||
File b = createTestDir(a, "b");
|
||||
File link1 = createSymLink(SystemInfo.isWindows ? a.getPath() : "../../" + a.getName(), b.getPath() + "/link1");
|
||||
File project = myTempDir.newFolder("project");
|
||||
File project = myTempDir.newDirectory("project");
|
||||
File c = createTestDir(project, "c");
|
||||
File d = createTestDir(c, "d");
|
||||
File link2 = createSymLink(SystemInfo.isWindows ? a.getPath() : "../../../" + a.getName(), d.getPath() + "/link2");
|
||||
@@ -131,7 +131,7 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testVisitAllNonRecursiveLinks() throws Exception {
|
||||
File target = myTempDir.newFolder("target");
|
||||
File target = myTempDir.newDirectory("target");
|
||||
File child = createTestDir(target, "child");
|
||||
File link1 = createSymLink(target.getPath(), myTempDir.getRoot() + "/link1");
|
||||
File link2 = createSymLink(target.getPath(), myTempDir.getRoot() + "/link2");
|
||||
@@ -155,7 +155,7 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
refresh(myTempDir.getRoot());
|
||||
assertFalse(linkVFile.getPath(), linkVFile.isWritable());
|
||||
|
||||
File targetDir = myTempDir.newFolder("target");
|
||||
File targetDir = myTempDir.newDirectory("target");
|
||||
File linkDir = createSymLink(targetDir.getPath(), myTempDir.getRoot() + "/linkDir");
|
||||
VirtualFile linkVDir = refreshAndFind(linkDir);
|
||||
assertTrue("link=" + linkDir + ", vLink=" + linkVDir, linkVDir != null && linkVDir.isDirectory() && linkVDir.is(VFileProperty.SYMLINK));
|
||||
@@ -191,7 +191,7 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
assertFalse(linkFile.exists());
|
||||
assertTrue(targetFile.exists());
|
||||
|
||||
File targetDir = myTempDir.newFolder("targetDir");
|
||||
File targetDir = myTempDir.newDirectory("targetDir");
|
||||
File childFile = new File(targetDir, "child.txt");
|
||||
assertTrue(childFile.getPath(), childFile.exists() || childFile.createNewFile());
|
||||
File linkDir = createSymLink(targetDir.getPath(), myTempDir.getRoot() + "/linkDir");
|
||||
@@ -209,7 +209,7 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
@Test
|
||||
public void testTransGenderRefresh() throws Exception {
|
||||
File targetFile = myTempDir.newFile("target");
|
||||
File targetDir = myTempDir.newFolder("targetDir");
|
||||
File targetDir = myTempDir.newDirectory("targetDir");
|
||||
|
||||
// file link
|
||||
File link = createSymLink(targetFile.getPath(), myTempDir.getRoot() + "/link");
|
||||
@@ -255,8 +255,8 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
}
|
||||
|
||||
private void doTestDirLinkSwitch(String text1, String text2) throws Exception {
|
||||
File targetDir1 = myTempDir.newFolder("target1");
|
||||
File targetDir2 = myTempDir.newFolder("target2");
|
||||
File targetDir1 = myTempDir.newDirectory("target1");
|
||||
File targetDir2 = myTempDir.newDirectory("target2");
|
||||
|
||||
File target1Child = new File(targetDir1, "child1.txt");
|
||||
assertTrue(target1Child.createNewFile());
|
||||
@@ -329,7 +329,7 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testTraversePathBehindLink() throws Exception {
|
||||
File topDir = myTempDir.newFolder("top");
|
||||
File topDir = myTempDir.newDirectory("top");
|
||||
File subDir1 = createTestDir(topDir, "sub1");
|
||||
File link = createSymLink(subDir1.getPath(), myTempDir.getRoot() + "/link");
|
||||
VirtualFile vLink = refreshAndFind(link);
|
||||
@@ -405,7 +405,7 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testCircularSymlinksMustBeDetected() throws IOException {
|
||||
File top = myTempDir.newFolder("top");
|
||||
File top = myTempDir.newDirectory("top");
|
||||
File sub1 = createTestDir(top, "sub1");
|
||||
File link = createSymLink(top.getPath(), sub1.getPath() + "/link");
|
||||
VirtualFile vLink = refreshAndFind(link);
|
||||
@@ -430,7 +430,7 @@ public class SymlinkHandlingTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testCircularSymlinksMustBeDetectedEvenForAsideLinks() throws IOException {
|
||||
File top = myTempDir.newFolder("top");
|
||||
File top = myTempDir.newDirectory("top");
|
||||
File sub1 = createTestDir(top, "s1");
|
||||
File ss1 = createTestDir(sub1, "ss1");
|
||||
File link1 = createSymLink(sub1.getPath(), ss1.getPath() + "/l1");
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* An improved variant of {@link TemporaryFolder} with lazy init, no symlinks in a temporary directory path, better directory name,
|
||||
* and more convenient {@linkplain #newFile(String)} / {@linkplain #newFolder(String)} methods.
|
||||
* and more convenient {@linkplain #newFile(String)} / {@linkplain #newDirectory(String)} methods.
|
||||
*/
|
||||
public class TempDirectory extends ExternalResource {
|
||||
private String myName;
|
||||
@@ -71,7 +71,7 @@ public class TempDirectory extends ExternalResource {
|
||||
/**
|
||||
* Creates a new directory with the given relative path from the root temp directory. Throws an exception if such a directory already exists.
|
||||
*/
|
||||
public @NotNull File newFolder(@NotNull String relativePath) throws IOException {
|
||||
public @NotNull File newDirectory(@NotNull String relativePath) throws IOException {
|
||||
Path dir = Paths.get(getRoot().getPath(), relativePath);
|
||||
if (Files.exists(dir)) throw new IOException("Already exists: " + dir);
|
||||
makeDirectories(dir);
|
||||
@@ -81,7 +81,7 @@ public class TempDirectory extends ExternalResource {
|
||||
/**
|
||||
* Creates a new directory with random name under the root temp directory.
|
||||
*/
|
||||
public @NotNull File newFolder() throws IOException {
|
||||
public @NotNull File newDirectory() throws IOException {
|
||||
return FileUtil.createTempDirectory(getRoot(), "dir" + myNextDirNameSuffix.incrementAndGet(), null);
|
||||
}
|
||||
|
||||
@@ -112,4 +112,20 @@ public class TempDirectory extends ExternalResource {
|
||||
Files.createDirectory(path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #newDirectory(String)}} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public @NotNull File newFolder(@NotNull String relativePath) throws IOException {
|
||||
return newDirectory(relativePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #newDirectory()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public @NotNull File newFolder() throws IOException {
|
||||
return newDirectory();
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public abstract class FileAttributesReadingTest {
|
||||
|
||||
@Test
|
||||
public void directory() throws IOException {
|
||||
File file = tempDir.newFolder("dir");
|
||||
File file = tempDir.newDirectory("dir");
|
||||
|
||||
FileAttributes attributes = getAttributes(file);
|
||||
assertEquals(FileAttributes.Type.DIRECTORY, attributes.type);
|
||||
@@ -115,7 +115,7 @@ public abstract class FileAttributesReadingTest {
|
||||
|
||||
@Test
|
||||
public void readOnlyDirectory() throws IOException {
|
||||
File dir = tempDir.newFolder("dir");
|
||||
File dir = tempDir.newDirectory("dir");
|
||||
|
||||
if (SystemInfo.isWindows) {
|
||||
Files.getFileAttributeView(dir.toPath(), DosFileAttributeView.class).setReadOnly(true);
|
||||
@@ -224,7 +224,7 @@ public abstract class FileAttributesReadingTest {
|
||||
public void linkToDirectory() throws IOException {
|
||||
IoTestUtil.assumeSymLinkCreationIsSupported();
|
||||
|
||||
File dir = tempDir.newFolder("dir");
|
||||
File dir = tempDir.newDirectory("dir");
|
||||
if (SystemInfo.isUnix) assertTrue(dir.setWritable(false, false));
|
||||
assertTrue(dir.setLastModified(dir.lastModified() - 5000));
|
||||
File link = new File(tempDir.getRoot(), "link");
|
||||
@@ -262,7 +262,7 @@ public abstract class FileAttributesReadingTest {
|
||||
public void selfLink() throws IOException {
|
||||
IoTestUtil.assumeSymLinkCreationIsSupported();
|
||||
|
||||
File dir = tempDir.newFolder("dir");
|
||||
File dir = tempDir.newDirectory("dir");
|
||||
File link = new File(dir, "link");
|
||||
Files.createSymbolicLink(link.toPath(), dir.toPath());
|
||||
|
||||
@@ -291,7 +291,7 @@ public abstract class FileAttributesReadingTest {
|
||||
public void junction() throws IOException {
|
||||
assumeTrue("vista-or-newer expected but got: "+SystemInfo.getOsNameAndVersion(), SystemInfo.isWinVistaOrNewer);
|
||||
|
||||
File target = tempDir.newFolder("dir");
|
||||
File target = tempDir.newDirectory("dir");
|
||||
File junction = IoTestUtil.createJunction(target.getPath(), tempDir.getRoot() + "/junction.dir");
|
||||
|
||||
try {
|
||||
@@ -333,7 +333,7 @@ public abstract class FileAttributesReadingTest {
|
||||
@Test
|
||||
public void hiddenDir() throws IOException {
|
||||
IoTestUtil.assumeWindows();
|
||||
File dir = tempDir.newFolder("dir");
|
||||
File dir = tempDir.newDirectory("dir");
|
||||
FileAttributes attributes = getAttributes(dir);
|
||||
assertFalse(attributes.isHidden());
|
||||
Files.getFileAttributeView(dir.toPath(), DosFileAttributeView.class).setHidden(true);
|
||||
|
||||
@@ -145,7 +145,7 @@ public class FileUtilHeavyTest {
|
||||
|
||||
@Test
|
||||
public void testDeleteFail() throws IOException {
|
||||
File targetDir = tempDir.newFolder("dir");
|
||||
File targetDir = tempDir.newDirectory("dir");
|
||||
File file = tempDir.newFile("dir/file");
|
||||
|
||||
if (SystemInfo.isWindows) {
|
||||
@@ -201,13 +201,13 @@ public class FileUtilHeavyTest {
|
||||
public void testSymlinkDeletion() throws IOException {
|
||||
IoTestUtil.assumeSymLinkCreationIsSupported();
|
||||
|
||||
File targetDir = tempDir.newFolder("target");
|
||||
File targetDir = tempDir.newDirectory("target");
|
||||
File targetFile = tempDir.newFile("target/file");
|
||||
File directDirLink = new File(tempDir.getRoot(), "dirLink");
|
||||
Files.createSymbolicLink(directDirLink.toPath(), targetDir.toPath());
|
||||
File directFileLink = new File(tempDir.getRoot(), "fileLink");
|
||||
Files.createSymbolicLink(directFileLink.toPath(), targetFile.toPath());
|
||||
File linkParentDir = tempDir.newFolder("linkParent");
|
||||
File linkParentDir = tempDir.newDirectory("linkParent");
|
||||
Files.createSymbolicLink(new File(linkParentDir, "link").toPath(), targetDir.toPath());
|
||||
|
||||
FileUtil.delete(directFileLink);
|
||||
@@ -224,11 +224,11 @@ public class FileUtilHeavyTest {
|
||||
public void testJunctionDeletion() throws IOException {
|
||||
IoTestUtil.assumeWindows();
|
||||
|
||||
File targetDir = tempDir.newFolder("target");
|
||||
File targetDir = tempDir.newDirectory("target");
|
||||
File targetFile = tempDir.newFile("target/file");
|
||||
File directDirLink = new File(tempDir.getRoot(), "dirLink");
|
||||
IoTestUtil.createJunction(targetDir.getPath(), directDirLink.getPath());
|
||||
File linkParentDir = tempDir.newFolder("linkParent");
|
||||
File linkParentDir = tempDir.newDirectory("linkParent");
|
||||
IoTestUtil.createJunction(targetDir.getPath(), new File(linkParentDir, "link").getPath());
|
||||
|
||||
FileUtil.delete(directDirLink);
|
||||
@@ -243,7 +243,7 @@ public class FileUtilHeavyTest {
|
||||
public void testRecursiveDeletionWithSymlink() throws IOException {
|
||||
IoTestUtil.assumeSymLinkCreationIsSupported();
|
||||
|
||||
File top = tempDir.newFolder("top");
|
||||
File top = tempDir.newDirectory("top");
|
||||
tempDir.newFile("top/a-dir/file");
|
||||
Files.createSymbolicLink(top.toPath().resolve("z-link"), top.toPath().resolve("a-dir"));
|
||||
|
||||
@@ -255,7 +255,7 @@ public class FileUtilHeavyTest {
|
||||
public void testRecursiveDeletionWithJunction() throws IOException {
|
||||
IoTestUtil.assumeWindows();
|
||||
|
||||
File top = tempDir.newFolder("top");
|
||||
File top = tempDir.newDirectory("top");
|
||||
tempDir.newFile("top/a-dir/file");
|
||||
IoTestUtil.createJunction(top + "/a-dir", top + "/z-link");
|
||||
|
||||
@@ -291,8 +291,8 @@ public class FileUtilHeavyTest {
|
||||
public void testToCanonicalPathSymLinksAware() throws IOException {
|
||||
IoTestUtil.assumeSymLinkCreationIsSupported();
|
||||
|
||||
File rootDir = tempDir.newFolder("root");
|
||||
tempDir.newFolder("root/dir1/dir2/dir3/dir4");
|
||||
File rootDir = tempDir.newDirectory("root");
|
||||
tempDir.newDirectory("root/dir1/dir2/dir3/dir4");
|
||||
String root = FileUtil.toSystemIndependentName(FileUtil.resolveShortWindowsName(rootDir.getPath()));
|
||||
|
||||
// non-recursive link
|
||||
|
||||
@@ -41,7 +41,7 @@ class CompressorTest {
|
||||
}
|
||||
|
||||
@Test fun recursiveZip() {
|
||||
val dir = tempDir.newFolder("dir")
|
||||
val dir = tempDir.newDirectory("dir")
|
||||
tempDir.newFile("dir/f1").writeText("1")
|
||||
tempDir.newFile("dir/f2").writeText("2")
|
||||
tempDir.newFile("dir/d1/f11").writeText("11")
|
||||
@@ -63,7 +63,7 @@ class CompressorTest {
|
||||
}
|
||||
|
||||
@Test fun recursiveTarWithPrefix() {
|
||||
val dir = tempDir.newFolder("dir")
|
||||
val dir = tempDir.newDirectory("dir")
|
||||
tempDir.newFile("dir/f1").writeText("1")
|
||||
tempDir.newFile("dir/f2").writeText("2")
|
||||
tempDir.newFile("dir/d1/f11").writeText("11")
|
||||
|
||||
@@ -32,35 +32,35 @@ class DecompressorTest {
|
||||
@Test fun noInternalTraversalInZip() {
|
||||
val zip = tempDir.newFile("test.zip")
|
||||
ZipOutputStream(FileOutputStream(zip)).use { writeEntry(it, "a/../bad.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
testNoTraversal(Decompressor.Zip(zip), dir, File(dir, "bad.txt"))
|
||||
}
|
||||
|
||||
@Test fun noInternalTraversalInCommonsZip() {
|
||||
val zip = tempDir.newFile("test.zip")
|
||||
ZipOutputStream(FileOutputStream(zip)).use { writeEntry(it, "a/../bad.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
testNoTraversal(Decompressor.Zip(zip).withUnixPermissionsAndSymlinks(), dir, File(dir, "bad.txt"))
|
||||
}
|
||||
|
||||
@Test fun noExternalTraversalInZip() {
|
||||
val zip = tempDir.newFile("test.zip")
|
||||
ZipOutputStream(FileOutputStream(zip)).use { writeEntry(it, "../evil.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
testNoTraversal(Decompressor.Zip(zip), dir, File(dir.parent, "evil.txt"))
|
||||
}
|
||||
|
||||
@Test fun noExternalTraversalInCommons() {
|
||||
val zip = tempDir.newFile("test.zip")
|
||||
ZipOutputStream(FileOutputStream(zip)).use { writeEntry(it, "../evil.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
testNoTraversal(Decompressor.Zip(zip).withUnixPermissionsAndSymlinks(), dir, File(dir.parent, "evil.txt"))
|
||||
}
|
||||
|
||||
@Test fun noAbsolutePathsInZip() {
|
||||
val zip = tempDir.newFile("test.zip")
|
||||
ZipOutputStream(FileOutputStream(zip)).use { writeEntry(it, "/root.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).extract(dir)
|
||||
assertThat(File(dir, "root.txt")).exists()
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class DecompressorTest {
|
||||
@Test fun noAbsolutePathsInCommonsZip() {
|
||||
val zip = tempDir.newFile("test.zip")
|
||||
ZipOutputStream(FileOutputStream(zip)).use { writeEntry(it, "/root.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).withUnixPermissionsAndSymlinks().extract(dir)
|
||||
assertThat(File(dir, "root.txt")).exists()
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class DecompressorTest {
|
||||
@Test fun tarDetectionPlain() {
|
||||
val tar = tempDir.newFile("test.tar")
|
||||
TarArchiveOutputStream(FileOutputStream(tar)).use { writeEntry(it, "dir/file.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).extract(dir)
|
||||
assertThat(File(dir, "dir/file.txt")).exists()
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class DecompressorTest {
|
||||
@Test fun tarDetectionGZip() {
|
||||
val tar = tempDir.newFile("test.tgz")
|
||||
TarArchiveOutputStream(GzipCompressorOutputStream(FileOutputStream(tar))).use { writeEntry(it, "dir/file.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).extract(dir)
|
||||
assertThat(File(dir, "dir/file.txt")).exists()
|
||||
}
|
||||
@@ -92,21 +92,21 @@ class DecompressorTest {
|
||||
@Test fun noInternalTraversalInTar() {
|
||||
val tar = tempDir.newFile("test.tar")
|
||||
TarArchiveOutputStream(FileOutputStream(tar)).use { writeEntry(it, "a/../bad.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
testNoTraversal(Decompressor.Tar(tar), dir, File(dir, "bad.txt"))
|
||||
}
|
||||
|
||||
@Test fun noExternalTraversalInTar() {
|
||||
val tar = tempDir.newFile("test.tar")
|
||||
TarArchiveOutputStream(FileOutputStream(tar)).use { writeEntry(it, "../evil.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
testNoTraversal(Decompressor.Tar(tar), dir, File(dir.parent, "evil.txt"))
|
||||
}
|
||||
|
||||
@Test fun noAbsolutePathsInTar() {
|
||||
val tar = tempDir.newFile("test.tar")
|
||||
TarArchiveOutputStream(FileOutputStream(tar)).use { writeEntry(it, "/root.txt") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).extract(dir)
|
||||
assertThat(File(dir, "root.txt")).exists()
|
||||
}
|
||||
@@ -115,7 +115,7 @@ class DecompressorTest {
|
||||
fun failsOnCorruptedZip() {
|
||||
val zip = tempDir.newFile("test.zip")
|
||||
zip.writeText("whatever")
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).extract(dir)
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class DecompressorTest {
|
||||
fun failsOnCorruptedCommonsZip() {
|
||||
val zip = tempDir.newFile("test.zip")
|
||||
zip.writeText("whatever")
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).withUnixPermissionsAndSymlinks().extract(dir)
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "dir/rx", mode = 0b101_000_000)
|
||||
writeEntry(it, "dir/rwx", mode = 0b111_000_000)
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).extract(dir)
|
||||
assertThat(File(dir, "dir/r")).exists().isNot(Writable).let { if (SystemInfo.isUnix) it.isNot(Executable) }
|
||||
assertThat(File(dir, "dir/rw")).exists().`is`(Writable).let { if (SystemInfo.isUnix) it.isNot(Executable) }
|
||||
@@ -151,7 +151,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "dir/rx", mode = 0b101_000_000)
|
||||
writeEntry(it, "dir/rwx", mode = 0b111_000_000)
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).withUnixPermissionsAndSymlinks().extract(dir)
|
||||
assertThat(File(dir, "dir/r")).exists().isNot(Writable).let { if (SystemInfo.isUnix) it.isNot(Executable) }
|
||||
assertThat(File(dir, "dir/rw")).exists().`is`(Writable).let { if (SystemInfo.isUnix) it.isNot(Executable) }
|
||||
@@ -165,7 +165,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "d1/f1.txt")
|
||||
writeEntry(it, "d2/f2.txt")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).filter { !it.startsWith("d2/") }.extract(dir)
|
||||
assertThat(File(dir, "d1/f1.txt")).isFile()
|
||||
assertThat(File(dir, "d2")).doesNotExist()
|
||||
@@ -179,7 +179,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "f")
|
||||
writeEntry(it, "links/ok", link = "../f")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).withSymlinks().extract(dir)
|
||||
assertThat(File(dir, "links/ok").toPath()).isSymbolicLink().hasSameContentAs(File(dir, "f").toPath())
|
||||
}
|
||||
@@ -192,7 +192,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "f")
|
||||
writeEntry(it, "links/ok", link = "../f")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).withUnixPermissionsAndSymlinks().extract(dir)
|
||||
assertThat(File(dir, "links/ok").toPath()).isSymbolicLink().hasSameContentAs(File(dir, "f").toPath())
|
||||
}
|
||||
@@ -202,7 +202,7 @@ class DecompressorTest {
|
||||
|
||||
val tar = tempDir.newFile("test.tar")
|
||||
TarArchiveOutputStream(FileOutputStream(tar)).use { writeEntry(it, "rogue", link = "../f") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
testNoTraversal(Decompressor.Tar(tar).withSymlinks(), dir, File(dir, "rogue"))
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ class DecompressorTest {
|
||||
|
||||
val zip = tempDir.newFile("test.zip")
|
||||
ZipArchiveOutputStream(FileOutputStream(zip)).use { writeEntry(it, "rogue", link = "../f") }
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
testNoTraversal(Decompressor.Zip(zip).withUnixPermissionsAndSymlinks(), dir, File(dir, "rogue"))
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ class DecompressorTest {
|
||||
ZipOutputStream(FileOutputStream(zip)).use {
|
||||
writeEntry(it, "a/b/c.txt")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).removePrefixPath("a/b").extract(dir)
|
||||
|
||||
assertThat(File(dir, "c.txt")).isFile()
|
||||
@@ -234,7 +234,7 @@ class DecompressorTest {
|
||||
ZipOutputStream(FileOutputStream(zip)).use {
|
||||
writeEntry(it, "a/b/c.txt")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).withUnixPermissionsAndSymlinks().removePrefixPath("a/b").extract(dir)
|
||||
|
||||
assertThat(File(dir, "c.txt")).isFile()
|
||||
@@ -249,7 +249,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "a/b/c.txt")
|
||||
writeEntry(it, "skip.txt")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
val filterLog = mutableListOf<String>()
|
||||
Decompressor.Zip(zip).removePrefixPath("a/b").filter { filterLog.add(it) }.extract(dir)
|
||||
|
||||
@@ -270,7 +270,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "a/f")
|
||||
writeEntry(it, "a/links/ok", link = "../f")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).removePrefixPath("a").extract(dir)
|
||||
|
||||
assertThat(File(dir, "f")).isFile()
|
||||
@@ -282,7 +282,7 @@ class DecompressorTest {
|
||||
TarArchiveOutputStream(FileOutputStream(tar)).use {
|
||||
writeEntry(it, "./a/f")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).removePrefixPath("/a/f").extract(dir)
|
||||
|
||||
assertThat(File(dir, "f")).doesNotExist()
|
||||
@@ -295,7 +295,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "/a/g")
|
||||
writeEntry(it, "././././././//a/h")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).removePrefixPath("/a/").extract(dir)
|
||||
|
||||
assertThat(File(dir, "f")).isFile()
|
||||
@@ -310,7 +310,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "/a/b/g")
|
||||
writeEntry(it, "././././././//a/b/h")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).removePrefixPath("./a/b").extract(dir)
|
||||
|
||||
assertThat(File(dir, "f")).isFile()
|
||||
@@ -325,7 +325,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "/a/b/g")
|
||||
writeEntry(it, "././././././//a/b/h")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).withUnixPermissionsAndSymlinks().removePrefixPath("./a/b").extract(dir)
|
||||
|
||||
assertThat(File(dir, "f")).isFile()
|
||||
@@ -341,7 +341,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "./a/b/f")
|
||||
writeEntry(it, "a/b/links/ok", link = "../f")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).removePrefixPath("a/b").extract(dir)
|
||||
|
||||
assertThat(File(dir, "f")).isFile()
|
||||
@@ -356,7 +356,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "./a/b/f")
|
||||
writeEntry(it, "a/b/links/ok", link = "../f")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Zip(zip).withUnixPermissionsAndSymlinks().removePrefixPath("a/b").extract(dir)
|
||||
|
||||
assertThat(File(dir, "f")).isFile()
|
||||
@@ -370,7 +370,7 @@ class DecompressorTest {
|
||||
TarArchiveOutputStream(FileOutputStream(tar)).use {
|
||||
writeEntry(it, "a/b/c/rogue", link = "../f")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
testNoTraversal(Decompressor.Tar(tar).removePrefixPath("a/b/c"), dir, File(dir, "rogue"))
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ class DecompressorTest {
|
||||
writeEntry(it, "missed")
|
||||
writeEntry(it, "a/b/c/file.txt")
|
||||
}
|
||||
val dir = tempDir.newFolder("unpacked")
|
||||
val dir = tempDir.newDirectory("unpacked")
|
||||
Decompressor.Tar(tar).removePrefixPath("a/b").extract(dir)
|
||||
assertThat(File(dir, "c/file.txt")).isFile()
|
||||
assertThat(File(dir, "missed")).doesNotExist()
|
||||
|
||||
@@ -76,7 +76,7 @@ public class SafeFileOutputStreamTest {
|
||||
@Test public void newFileInReadOnlyDirectory() throws IOException {
|
||||
assumeUnix();
|
||||
|
||||
File dir = tempDir.newFolder("dir");
|
||||
File dir = tempDir.newDirectory("dir");
|
||||
Files.setPosixFilePermissions(dir.toPath(), EnumSet.of(OWNER_READ, OWNER_EXECUTE));
|
||||
checkWriteFailed(new File(dir, "test.txt"));
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class UrlClassLoaderTest {
|
||||
int counter = 1;
|
||||
for (String dirName : new String[]{"dir", "dir/", "dir.class", "dir.class/"}) {
|
||||
for (String resourceName : new String[]{"a.class", "a.txt"}) {
|
||||
File root = tempDir.newFolder("testFindDirWhenUsingCache" + (counter++));
|
||||
File root = tempDir.newDirectory("testFindDirWhenUsingCache" + (counter++));
|
||||
File subDir = createTestDir(root, dirName);
|
||||
createTestFile(subDir, resourceName);
|
||||
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ class LegacyBridgeFilePointerProviderTest {
|
||||
fun `cache invalidated on move`() {
|
||||
val provider = LegacyBridgeFilePointerProviderImpl(project).also { Disposer.register(disposable.disposable, it) }
|
||||
|
||||
val targetFolder = tempDir.newFolder("target")
|
||||
val targetFolder = tempDir.newDirectory("target")
|
||||
val targetFolderVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(targetFolder)!!
|
||||
|
||||
val file = tempDir.newFile("x.txt")
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ class PatternInstrumenterTest {
|
||||
val testDir = PluginPathManager.getPluginHomePath("IntelliLang") + "/intellilang-jps-plugin/testData/patternInstrumenter/"
|
||||
val testName = testName.methodName.capitalize()
|
||||
val testFile = IdeaTestUtil.findSourceFile(testDir + testName)
|
||||
val classesDir = tempDir.newFolder("out")
|
||||
val classesDir = tempDir.newDirectory("out")
|
||||
val rootPaths = IntelliJProjectConfiguration.getProjectLibraryClassesRootPaths("jetbrains-annotations")
|
||||
IdeaTestUtil.compileFile(testFile, classesDir, "-cp", rootPaths.joinToString(File.pathSeparator))
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class UtilsTest {
|
||||
|
||||
@Test
|
||||
public void testRecursiveDelete() throws Exception {
|
||||
File topDir = tempDir.newFolder("temp_dir");
|
||||
File topDir = tempDir.newDirectory("temp_dir");
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
File file = new File(topDir, "dir" + i + "/file" + j);
|
||||
@@ -116,7 +116,7 @@ public class UtilsTest {
|
||||
public void testNonRecursiveSymlinkDelete() throws Exception {
|
||||
IoTestUtil.assumeSymLinkCreationIsSupported();
|
||||
|
||||
File dir = tempDir.newFolder("temp_dir");
|
||||
File dir = tempDir.newDirectory("temp_dir");
|
||||
File file = new File(dir, "file");
|
||||
FileUtil.writeToFile(file, "test");
|
||||
assertThat(dir.listFiles()).containsExactly(file);
|
||||
@@ -135,7 +135,7 @@ public class UtilsTest {
|
||||
public void testDeleteDanglingSymlink() throws Exception {
|
||||
IoTestUtil.assumeSymLinkCreationIsSupported();
|
||||
|
||||
File dir = tempDir.newFolder("temp_dir");
|
||||
File dir = tempDir.newDirectory("temp_dir");
|
||||
File link = new File(dir, "link");
|
||||
Utils.createLink("dangling", link);
|
||||
assertThat(dir.listFiles()).containsExactly(link);
|
||||
|
||||
Reference in New Issue
Block a user