public static GeneralPathImpl create(final FileSystem fs, final String path, boolean isRealPath) { return create(fs, path, isRealPath, false); }
public SimpleWindowsFileStore(final File[] roots, final FileSystem fs, final String path) { this(roots, GeneralPathImpl.create(fs, path, false)); }
private String validateDefaultDir(final String path) throws IllegalArgumentException { checkNotEmpty("path", path); if (!GeneralPathImpl.create(this, path, false).isAbsolute()) { throw new IllegalArgumentException("Path needs to be absolute, got: " + path); } return path; }
@Test public void simpleStateTest() { assertThat(fsProvider).isNotNull(); assertThat(fsProvider.getScheme()).isEqualTo("file"); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "c:\\path\\to\\file.txt", false); assertThat(path.getFileSystem()).isInstanceOf(SimpleWindowsFileSystem.class); }
@Test public void readAttributesNull2() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); assertThatThrownBy(() -> fsProvider.readAttributes(path, (Class<MyAttrs>) null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Parameter named 'type' should be not null!"); }
@Test public void checkAccessNull2() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); assertThatThrownBy(() -> fsProvider.checkAccess(path, null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Parameter named 'modes' should be not null!"); }
@Test(expected = FileSystemAlreadyExistsException.class) public void newFileSystemCantCreatePath() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final URI uri = URI.create("file:///"); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(uri), uri.getPath(), false); fsProvider.newFileSystem(path, Collections.emptyMap()); }
@Test(expected = IllegalArgumentException.class) public void copyFileNull1() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final String userPath = System.getProperty("user.dir") + "/temp"; final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), userPath, false); fsProvider.copy(path, null); }
@Test(expected = IllegalArgumentException.class) public void newDirectoryStreamNull2() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final String userSourcePath = System.getProperty("user.dir") + "/xxxxxx"; final Path dir = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), userSourcePath, false); fsProvider.newDirectoryStream(dir, null); }
@Test(expected = IllegalArgumentException.class) public void copyFileNull2() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final String userPath = System.getProperty("user.dir") + "/temp"; final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), userPath, false); fsProvider.copy(null, path); }
@Test(expected = NotDirectoryException.class) public void newDirectoryStreamInvalidDir() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final String userSourcePath = System.getProperty("user.dir") + "/xxxxxx"; final Path dir = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), userSourcePath, false); fsProvider.newDirectoryStream(dir, entry -> true); }
@Test(expected = org.uberfire.java.nio.IOException.class) public void outputStreamOnDirectory() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/", false); fsProvider.newOutputStream(path); }
@Test(expected = org.uberfire.java.nio.IOException.class) public void newByteChannelInvalidPath() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final String userBasedPath = System.getProperty("user.dir") + "path/to/some_file_here.txt"; final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), userBasedPath, false); assertThat(path.toFile()).doesNotExist(); fsProvider.newByteChannel(path, null); }
@Test(expected = UnsupportedOperationException.class) public void newAsynchronousFileChannelUnsupportedOp() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); fsProvider.newAsynchronousFileChannel(path, null, null); }
@Test(expected = IllegalArgumentException.class) public void sameFileNull2() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); fsProvider.isSameFile(path, null); }
@Test(expected = NoSuchFileException.class) public void inputStreamFileDoesntExists() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); fsProvider.newInputStream(path); }
@Test(expected = IllegalStateException.class) public void createSymbolicLinkSame() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); fsProvider.createSymbolicLink(path, path); }
@Test(expected = IllegalArgumentException.class) public void createLinkNull2() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); fsProvider.createLink(path, null); }
@Test(expected = IllegalArgumentException.class) public void createLinkNull3() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); fsProvider.createLink(null, path); }
@Test public void checkGetFileStore() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); assertThat(fsProvider.getFileStore(path)).isNotNull(); assertThat(fsProvider.getFileSystem(path.toUri()).getFileStores()).isNotNull().contains(fsProvider.getFileStore(path)); }