Skip to content

Commit 8662f89

Browse files
committed
Rename test method names to be clearer on use of symbolic links
1 parent d7975e6 commit 8662f89

File tree

6 files changed

+39
-39
lines changed

6 files changed

+39
-39
lines changed

src/test/java/org/apache/commons/io/AbstractFileUtilsDeleteDirectoryTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void testDeleteDirectoryNullArgument() {
4242
}
4343

4444
@Test
45-
public void testDeleteDirWithASymlinkDir() throws Exception {
45+
public void testDeleteDirWithASymbolicLinkDir2() throws Exception {
4646

4747
final File realOuter = new File(top, "realouter");
4848
assertTrue(realOuter.mkdirs());
@@ -60,7 +60,7 @@ public void testDeleteDirWithASymlinkDir() throws Exception {
6060
assertEquals(1, randomDirectory.list().length);
6161

6262
final File symlinkDirectory = new File(realOuter, "fakeinner");
63-
assertTrue(setupSymlink(randomDirectory, symlinkDirectory));
63+
Files.createSymbolicLink(symlinkDirectory.toPath(), randomDirectory.toPath());
6464

6565
assertEquals(1, symlinkDirectory.list().length);
6666

@@ -73,7 +73,7 @@ public void testDeleteDirWithASymlinkDir() throws Exception {
7373
}
7474

7575
@Test
76-
public void testDeleteDirWithASymlinkDir2() throws Exception {
76+
public void testDeleteDirWithASymlinkDir() throws Exception {
7777

7878
final File realOuter = new File(top, "realouter");
7979
assertTrue(realOuter.mkdirs());
@@ -91,7 +91,7 @@ public void testDeleteDirWithASymlinkDir2() throws Exception {
9191
assertEquals(1, randomDirectory.list().length);
9292

9393
final File symlinkDirectory = new File(realOuter, "fakeinner");
94-
Files.createSymbolicLink(symlinkDirectory.toPath(), randomDirectory.toPath());
94+
assertTrue(setupSymlink(randomDirectory, symlinkDirectory));
9595

9696
assertEquals(1, symlinkDirectory.list().length);
9797

@@ -135,7 +135,7 @@ public void testDeleteDirWithSymlinkFile() throws Exception {
135135
}
136136

137137
@Test
138-
public void testDeleteInvalidLinks() throws Exception {
138+
public void testDeleteInvalidSymbolicLinks() throws Exception {
139139
final File aFile = new File(top, "realParentDirA");
140140
assertTrue(aFile.mkdir());
141141
final File bFile = new File(aFile, "realChildDirB");
@@ -158,7 +158,7 @@ public void testDeleteInvalidLinks() throws Exception {
158158
}
159159

160160
@Test
161-
public void testDeleteParentSymlink() throws Exception {
161+
public void testDeleteParentSymbolicLink2() throws Exception {
162162
final File realParent = new File(top, "realparent");
163163
assertTrue(realParent.mkdirs());
164164

@@ -175,12 +175,12 @@ public void testDeleteParentSymlink() throws Exception {
175175
assertEquals(1, randomDirectory.list().length);
176176

177177
final File symlinkDirectory = new File(realParent, "fakeinner");
178-
assertTrue(setupSymlink(randomDirectory, symlinkDirectory));
178+
Files.createSymbolicLink(symlinkDirectory.toPath(), randomDirectory.toPath());
179179

180180
assertEquals(1, symlinkDirectory.list().length);
181181

182182
final File symlinkParentDirectory = new File(top, "fakeouter");
183-
assertTrue(setupSymlink(realParent, symlinkParentDirectory));
183+
Files.createSymbolicLink(symlinkParentDirectory.toPath(), realParent.toPath());
184184

185185
// assert only the symlink is deleted, but not followed
186186
FileUtils.deleteDirectory(symlinkParentDirectory);
@@ -191,7 +191,7 @@ public void testDeleteParentSymlink() throws Exception {
191191
}
192192

193193
@Test
194-
public void testDeleteParentSymlink2() throws Exception {
194+
public void testDeleteParentSymlink() throws Exception {
195195
final File realParent = new File(top, "realparent");
196196
assertTrue(realParent.mkdirs());
197197

@@ -208,12 +208,12 @@ public void testDeleteParentSymlink2() throws Exception {
208208
assertEquals(1, randomDirectory.list().length);
209209

210210
final File symlinkDirectory = new File(realParent, "fakeinner");
211-
Files.createSymbolicLink(symlinkDirectory.toPath(), randomDirectory.toPath());
211+
assertTrue(setupSymlink(randomDirectory, symlinkDirectory));
212212

213213
assertEquals(1, symlinkDirectory.list().length);
214214

215215
final File symlinkParentDirectory = new File(top, "fakeouter");
216-
Files.createSymbolicLink(symlinkParentDirectory.toPath(), realParent.toPath());
216+
assertTrue(setupSymlink(realParent, symlinkParentDirectory));
217217

218218
// assert only the symlink is deleted, but not followed
219219
FileUtils.deleteDirectory(symlinkParentDirectory);

src/test/java/org/apache/commons/io/FileUtilsTest.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ private void consumeRemaining(final Iterator<File> iterator) {
196196
}
197197
}
198198

199-
private Path createCircularOsSymLink(final String linkName, final String targetName) throws IOException {
199+
private Path createCircularOsSymbolicLink(final String linkName, final String targetName) throws IOException {
200200
return Files.createSymbolicLink(Paths.get(linkName), Paths.get(targetName));
201201
}
202202

203203
/**
204204
* May throw java.nio.file.FileSystemException: C:\Users\...\FileUtilsTestCase\cycle: A required privilege is not held
205205
* by the client. On Windows, you are fine if you run a terminal with admin karma.
206206
*/
207-
private void createCircularSymLink(final File file) throws IOException {
207+
private void createCircularSymbolicLink(final File file) throws IOException {
208208
assertTrue(file.exists());
209209
final String linkName = file + "/cycle";
210210
final String targetName = file + "/..";
@@ -218,7 +218,7 @@ private void createCircularSymLink(final File file) throws IOException {
218218
// On Windows, you are fine if you run a terminal with admin karma.
219219
Files.createSymbolicLink(linkPath, targetPath);
220220
} catch (final UnsupportedOperationException e) {
221-
createCircularOsSymLink(linkName, targetName);
221+
createCircularOsSymbolicLink(linkName, targetName);
222222
}
223223
// Sanity check:
224224
assertTrue(Files.isSymbolicLink(linkPath), () -> "Expected a sym link here: " + linkName);
@@ -245,7 +245,7 @@ private void createFilesForTestCopyDirectory(final File grandParentDir, final Fi
245245
FileUtils.writeStringToFile(file6, "File 6 in grandChild2", "UTF8");
246246
}
247247

248-
private Path createTempSymlinkedRelativeDir() throws IOException {
248+
private Path createTempSymbolicLinkedRelativeDir() throws IOException {
249249
final Path targetDir = tempDirPath.resolve("subdir");
250250
final Path symlinkDir = tempDirPath.resolve("symlinked-dir");
251251
Files.createDirectory(targetDir);
@@ -404,7 +404,7 @@ public void test_openOutputStream_existsButIsDirectory() {
404404
*/
405405
@Test
406406
public void test_openOutputStream_intoExistingSymlinkedDir() throws Exception {
407-
final Path symlinkedDir = createTempSymlinkedRelativeDir();
407+
final Path symlinkedDir = createTempSymbolicLinkedRelativeDir();
408408

409409
final File file = symlinkedDir.resolve("test.txt").toFile();
410410
try (FileOutputStream out = FileUtils.openOutputStream(file)) {
@@ -762,7 +762,7 @@ public void testContentEqualsIgnoreEOL() throws Exception {
762762
* and should not be relied on.
763763
*/
764764
@Test
765-
public void testCopyDir_symLink() throws Exception {
765+
public void testCopyDir_SymbolicLink() throws Exception {
766766
// Make a directory
767767
final File realDirectory = new File(tempDirFile, "real_directory");
768768
realDirectory.mkdir();
@@ -790,7 +790,7 @@ public void testCopyDir_symLink() throws Exception {
790790
}
791791

792792
@Test
793-
public void testCopyDir_symLinkCycle() throws Exception {
793+
public void testCopyDir_SymbolicLinkCycle() throws Exception {
794794
// Make a directory
795795
final File topDirectory = new File(tempDirFile, "topDirectory");
796796
topDirectory.mkdir();
@@ -824,7 +824,7 @@ public void testCopyDir_symLinkCycle() throws Exception {
824824
* Tests IO-807.
825825
*/
826826
@Test
827-
public void testCopyDirectory_brokenSymLink() throws IOException {
827+
public void testCopyDirectory_brokenSymbolicLink() throws IOException {
828828
// Make a file
829829
final File sourceDirectory = new File(tempDirFile, "source_directory");
830830
sourceDirectory.mkdir();
@@ -859,7 +859,7 @@ public void testCopyDirectory_brokenSymLink() throws IOException {
859859
}
860860

861861
@Test
862-
public void testCopyDirectory_symLink() throws IOException {
862+
public void testCopyDirectory_SymbolicLink() throws IOException {
863863
// Make a file
864864
final File sourceDirectory = new File(tempDirFile, "source_directory");
865865
sourceDirectory.mkdir();
@@ -890,7 +890,7 @@ public void testCopyDirectory_symLink() throws IOException {
890890
* to a file outside the copied directory.
891891
*/
892892
@Test
893-
public void testCopyDirectory_symLinkExternalFile() throws Exception {
893+
public void testCopyDirectory_SymbolicLinkExternalFile() throws Exception {
894894
// make a file
895895
final File content = new File(tempDirFile, "hello.txt");
896896
FileUtils.writeStringToFile(content, "HELLO WORLD", "UTF8");
@@ -1195,7 +1195,7 @@ public void testCopyDirectoryWithPotentialFalsePartialMatch() throws IOException
11951195
}
11961196

11971197
@Test
1198-
public void testCopyFile_symLink() throws Exception {
1198+
public void testCopyFile_SymbolicLink() throws Exception {
11991199
// Make a file
12001200
final File sourceDirectory = new File(tempDirFile, "source_directory");
12011201
sourceDirectory.mkdir();
@@ -1553,19 +1553,19 @@ public void testDeleteDirectoryFailsOnFile() {
15531553
assertThrows(IllegalArgumentException.class, () -> FileUtils.deleteDirectory(testFile1));
15541554
}
15551555

1556-
@Test
1557-
public void testDeleteDirectoryNoopIfAbsent() {
1558-
// Noop on non-existent entry
1559-
assertDoesNotThrow(() -> FileUtils.deleteDirectory(new File("does not exist.nope")));
1560-
}
1561-
15621556
@Test
15631557
public void testDeleteDirectoryIsSymLink() throws IOException {
1564-
final Path symlinkedDir = createTempSymlinkedRelativeDir();
1558+
final Path symlinkedDir = createTempSymbolicLinkedRelativeDir();
15651559
FileUtils.deleteDirectory(symlinkedDir.toFile());
15661560
assertFalse(Files.exists(symlinkedDir));
15671561
}
15681562

1563+
@Test
1564+
public void testDeleteDirectoryNoopIfAbsent() {
1565+
// Noop on non-existent entry
1566+
assertDoesNotThrow(() -> FileUtils.deleteDirectory(new File("does not exist.nope")));
1567+
}
1568+
15691569
@Test
15701570
public void testDeleteQuietlyDir() throws IOException {
15711571
final File testDirectory = new File(tempDirFile, "testDeleteQuietlyDir");
@@ -2889,7 +2889,7 @@ public void testSizeOfDirectory() throws Exception {
28892889
file.mkdir();
28902890

28912891
// Create a cyclic symlink
2892-
createCircularSymLink(file);
2892+
createCircularSymbolicLink(file);
28932893

28942894
assertEquals(TEST_DIRECTORY_SIZE, FileUtils.sizeOfDirectory(file), "Unexpected directory size");
28952895
}
@@ -2920,7 +2920,7 @@ public void testSizeOfDirectoryAsBigInteger() throws Exception {
29202920
file.delete();
29212921
file.mkdir();
29222922

2923-
createCircularSymLink(file);
2923+
createCircularSymbolicLink(file);
29242924

29252925
assertEquals(TEST_DIRECTORY_SIZE_BI, FileUtils.sizeOfDirectoryAsBigInteger(file), "Unexpected directory size");
29262926

@@ -3453,7 +3453,7 @@ public void testWriteStringToFileIntoNonExistentSubdir() throws Exception {
34533453
*/
34543454
@Test
34553455
public void testWriteStringToFileIntoSymlinkedDir() throws Exception {
3456-
final Path symlinkDir = createTempSymlinkedRelativeDir();
3456+
final Path symlinkDir = createTempSymbolicLinkedRelativeDir();
34573457

34583458
final File file = symlinkDir.resolve("file").toFile();
34593459
FileUtils.writeStringToFile(file, "Hello /u1234", StandardCharsets.UTF_8);

src/test/java/org/apache/commons/io/file/AbstractTempDirTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public abstract class AbstractTempDirTest {
4444
* @return Path for {@code tempDirPath/subdir}.
4545
* @throws IOException if an I/O error occurs or the parent directory does not exist.
4646
*/
47-
protected static Path createTempSymlinkedRelativeDir(final Path rootDir) throws IOException {
47+
protected static Path createTempSymbolicLinkedRelativeDir(final Path rootDir) throws IOException {
4848
final Path targetDir = rootDir.resolve(SUB_DIR);
4949
final Path symlinkDir = rootDir.resolve(SYMLINKED_DIR);
5050
Files.createDirectory(targetDir);

src/test/java/org/apache/commons/io/file/DeletingPathVisitorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void testEqualsHashCode() {
145145
@Test
146146
public void testIO850DirectoriesAndFiles() throws IOException {
147147
final Path rootDir = Files.createDirectory(managedTempDirPath.resolve("IO850"));
148-
createTempSymlinkedRelativeDir(rootDir);
148+
createTempSymbolicLinkedRelativeDir(rootDir);
149149
final Path targetDir = rootDir.resolve(SUB_DIR);
150150
final Path symlinkDir = rootDir.resolve(SYMLINKED_DIR);
151151
Files.write(targetDir.resolve("file0.txt"), "Hello".getBytes(StandardCharsets.UTF_8));
@@ -166,7 +166,7 @@ public void testIO850DirectoriesAndFiles() throws IOException {
166166
@Test
167167
public void testIO850DirectoriesOnly() throws IOException {
168168
final Path rootDir = Files.createDirectory(managedTempDirPath.resolve("IO850"));
169-
createTempSymlinkedRelativeDir(rootDir);
169+
createTempSymbolicLinkedRelativeDir(rootDir);
170170
final Path targetDir = rootDir.resolve(SUB_DIR);
171171
final Path symlinkDir = rootDir.resolve(SYMLINKED_DIR);
172172
final DeletingPathVisitor visitor = DeletingPathVisitor.withLongCounters();

src/test/java/org/apache/commons/io/file/PathUtilsDeleteFileTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
public class PathUtilsDeleteFileTest extends AbstractTempDirTest {
4242

4343
@Test
44-
public void testDeleteBrokenLink() throws IOException {
44+
public void testDeleteBrokenSymbolicLink() throws IOException {
4545
assumeFalse(SystemUtils.IS_OS_WINDOWS);
4646
final Path missingFile = tempDirPath.resolve("missing.txt");
4747
final Path brokenLink = tempDirPath.resolve("broken.txt");

src/test/java/org/apache/commons/io/file/PathUtilsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ public void testCreateDirectoriesNew() throws IOException {
217217

218218
@Test
219219
public void testCreateDirectoriesSymlink() throws IOException {
220-
final Path symlinkedDir = createTempSymlinkedRelativeDir(tempDirPath);
220+
final Path symlinkedDir = createTempSymbolicLinkedRelativeDir(tempDirPath);
221221
final String leafDirName = "child";
222222
final Path newDirFollowed = PathUtils.createParentDirectories(symlinkedDir.resolve(leafDirName), PathUtils.NULL_LINK_OPTION);
223223
assertEquals(Files.readSymbolicLink(symlinkedDir), newDirFollowed);
224224
}
225225

226226
@Test
227227
public void testCreateDirectoriesSymlinkClashing() throws IOException {
228-
final Path symlinkedDir = createTempSymlinkedRelativeDir(tempDirPath);
228+
final Path symlinkedDir = createTempSymbolicLinkedRelativeDir(tempDirPath);
229229
assertEquals(symlinkedDir, PathUtils.createParentDirectories(symlinkedDir.resolve("child")));
230230
}
231231

@@ -436,7 +436,7 @@ public void testNewOutputStreamNewFileAppendTrue() throws IOException {
436436

437437
@Test
438438
public void testNewOutputStreamNewFileInsideExistingSymlinkedDir() throws IOException {
439-
final Path symlinkDir = createTempSymlinkedRelativeDir(tempDirPath);
439+
final Path symlinkDir = createTempSymbolicLinkedRelativeDir(tempDirPath);
440440
final Path file = symlinkDir.resolve("test.txt");
441441
try (OutputStream outputStream = PathUtils.newOutputStream(file, new LinkOption[] {})) {
442442
// empty

0 commit comments

Comments
 (0)