public void testCreateParentDirectories_noParentsNeeded() throws IOException { Path path = tempDir.resolve("nonexistent.file"); assertTrue(Files.exists(path.getParent())); MoreFiles.createParentDirectories(path); // test that there's no exception }
public void testCreateParentDirectories_relativePath() throws IOException { Path path = FS.getPath("nonexistent.file"); assertNull(path.getParent()); assertNotNull(path.toAbsolutePath().getParent()); MoreFiles.createParentDirectories(path); // test that there's no exception }
public void testCreateParentDirectories_oneParentNeeded() throws IOException { Path path = tempDir.resolve("parent/nonexistent.file"); Path parent = path.getParent(); assertFalse(Files.exists(parent)); MoreFiles.createParentDirectories(path); assertTrue(Files.exists(parent)); }
public void testCreateParentDirectories_symlinkParentExists() throws IOException { Path symlink = tempDir.resolve("linkToDir"); Files.createSymbolicLink(symlink, root()); Path file = symlink.resolve("foo"); MoreFiles.createParentDirectories(file); }
public void testCreateParentDirectories_multipleParentsNeeded() throws IOException { Path path = tempDir.resolve("grandparent/parent/nonexistent.file"); Path parent = path.getParent(); Path grandparent = parent.getParent(); assertFalse(Files.exists(grandparent)); assertFalse(Files.exists(parent)); MoreFiles.createParentDirectories(path); assertTrue(Files.exists(parent)); assertTrue(Files.exists(grandparent)); }
public void testCreateParentDirectories_noPermission() { Path file = root().resolve("parent/nonexistent.file"); Path parent = file.getParent(); assertFalse(Files.exists(parent)); try { MoreFiles.createParentDirectories(file); // Cleanup in case parent creation was [erroneously] successful. Files.delete(parent); fail("expected exception"); } catch (IOException expected) { } }
public void testCreateParentDirectories_root() throws IOException { Path root = root(); assertNull(root.getParent()); assertNull(root.toRealPath().getParent()); MoreFiles.createParentDirectories(root); // test that there's no exception }
public void testCreateParentDirectories_nonDirectoryParentExists() throws IOException { Path parent = createTempFile(); assertTrue(Files.isRegularFile(parent)); Path file = parent.resolve("foo"); try { MoreFiles.createParentDirectories(file); fail(); } catch (IOException expected) { } }
public void testCreateParentDirectories_noParentsNeeded() throws IOException { Path path = tempDir.resolve("nonexistent.file"); assertTrue(Files.exists(path.getParent())); MoreFiles.createParentDirectories(path); // test that there's no exception }
public void testCreateParentDirectories_oneParentNeeded() throws IOException { Path path = tempDir.resolve("parent/nonexistent.file"); Path parent = path.getParent(); assertFalse(Files.exists(parent)); MoreFiles.createParentDirectories(path); assertTrue(Files.exists(parent)); }
public void testCreateParentDirectories_relativePath() throws IOException { Path path = FS.getPath("nonexistent.file"); assertNull(path.getParent()); assertNotNull(path.toAbsolutePath().getParent()); MoreFiles.createParentDirectories(path); // test that there's no exception }
public void testCreateParentDirectories_symlinkParentExists() throws IOException { Path symlink = tempDir.resolve("linkToDir"); Files.createSymbolicLink(symlink, root()); Path file = symlink.resolve("foo"); MoreFiles.createParentDirectories(file); }
public void testCreateParentDirectories_multipleParentsNeeded() throws IOException { Path path = tempDir.resolve("grandparent/parent/nonexistent.file"); Path parent = path.getParent(); Path grandparent = parent.getParent(); assertFalse(Files.exists(grandparent)); assertFalse(Files.exists(parent)); MoreFiles.createParentDirectories(path); assertTrue(Files.exists(parent)); assertTrue(Files.exists(grandparent)); }
public void testCreateParentDirectories_noPermission() { Path file = root().resolve("parent/nonexistent.file"); Path parent = file.getParent(); assertFalse(Files.exists(parent)); try { MoreFiles.createParentDirectories(file); // Cleanup in case parent creation was [erroneously] successful. Files.delete(parent); fail("expected exception"); } catch (IOException expected) { } }
public void testCreateParentDirectories_root() throws IOException { Path root = root(); assertNull(root.getParent()); assertNull(root.toRealPath().getParent()); MoreFiles.createParentDirectories(root); // test that there's no exception }
public void testCreateParentDirectories_nonDirectoryParentExists() throws IOException { Path parent = createTempFile(); assertTrue(Files.isRegularFile(parent)); Path file = parent.resolve("foo"); try { MoreFiles.createParentDirectories(file); fail(); } catch (IOException expected) { } }