|
31 | 31 |
|
32 | 32 | package org.scijava.test; |
33 | 33 |
|
| 34 | +import static org.junit.Assert.assertEquals; |
34 | 35 | import static org.junit.Assert.assertTrue; |
35 | 36 |
|
36 | 37 | import java.io.File; |
@@ -80,4 +81,33 @@ public void sameDirectoryTwice() throws IOException { |
80 | 81 | if (stream != null) stream.close(); |
81 | 82 | } |
82 | 83 | } |
| 84 | + |
| 85 | + /** Tests {@link TestUtils#createPath(File, String)}. */ |
| 86 | + @Test |
| 87 | + public void testCreatePath() throws IOException { |
| 88 | + final File base = TestUtils.createTemporaryDirectory("create-path-"); |
| 89 | + final String path = "/my/what/a/nested/directory/structure/you/have/gramma"; |
| 90 | + File file = TestUtils.createPath(base, path); |
| 91 | + assertTrue(file.exists()); |
| 92 | + assertEquals("gramma", file.getName()); |
| 93 | + file = file.getParentFile(); |
| 94 | + assertEquals("have", file.getName()); |
| 95 | + file = file.getParentFile(); |
| 96 | + assertEquals("you", file.getName()); |
| 97 | + file = file.getParentFile(); |
| 98 | + assertEquals("structure", file.getName()); |
| 99 | + file = file.getParentFile(); |
| 100 | + assertEquals("directory", file.getName()); |
| 101 | + file = file.getParentFile(); |
| 102 | + assertEquals("nested", file.getName()); |
| 103 | + file = file.getParentFile(); |
| 104 | + assertEquals("a", file.getName()); |
| 105 | + file = file.getParentFile(); |
| 106 | + assertEquals("what", file.getName()); |
| 107 | + file = file.getParentFile(); |
| 108 | + assertEquals("my", file.getName()); |
| 109 | + file = file.getParentFile(); |
| 110 | + assertEquals(base, file); |
| 111 | + } |
| 112 | + |
83 | 113 | } |
0 commit comments