/** * Locate a file by name. */ @Override public FileObject resolveFile(final String name, final FileSystemOptions fileSystemOptions) throws FileSystemException { return manager.resolveFile(name, fileSystemOptions); }
/** * Locate a file by name. */ @Override public FileObject resolveFile(final String name, final FileSystemOptions fileSystemOptions) throws FileSystemException { return manager.resolveFile(name, fileSystemOptions); }
/** * Locate a file by name. */ @Override public FileObject resolveFile(final FileObject baseFile, final String name, final FileSystemOptions fileSystemOptions) throws FileSystemException { return manager.resolveFile(baseFile, name, fileSystemOptions); }
/** * Locate a file by name. */ @Override public FileObject resolveFile(final FileObject baseFile, final String name, final FileSystemOptions fileSystemOptions) throws FileSystemException { return manager.resolveFile(baseFile, name, fileSystemOptions); }
/** * Locates a file by URI. * * @param uri The URI of the file to locate. * @return The FileObject for the located file. * @throws FileSystemException if the file cannot be located or an error occurs. */ @Override public FileObject resolveFile(final String uri) throws FileSystemException { return resolveFile(getBaseFile(), uri); }
/** * Resolves a URI, relative to a base file. * * @param baseFile The base FileOjbect to use to locate the file. * @param uri The URI of the file to locate. * @return The FileObject for the located file. * @throws FileSystemException if the file cannot be located or an error occurs. */ @Override public FileObject resolveFile(final FileObject baseFile, final String uri) throws FileSystemException { return resolveFile(baseFile, uri, baseFile == null ? null : baseFile.getFileSystem().getFileSystemOptions()); }
DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(currSchemeStr, new AzFileProvider()); currMan.addProvider("file", new DefaultLocalFileProvider()); currMan.init(); currMan.resolveFile("file:///tmp" + + file.getAbsolutePath());
private InputStream createNonEmptyFile() throws FileSystemException, IOException { final FileObject root = manager.resolveFile("ram://file"); root.createFile(); final FileContent content = root.getContent(); final OutputStream output = this.closeOnTearDown(content.getOutputStream()); output.write(1); output.write(2); output.write(3); output.flush(); output.close(); return this.closeOnTearDown(content.getInputStream()); }
@Test public void testLargeFile() throws Exception { final File realFile = new File(largeFilePath + largeFileName + ".tar.gz"); final FileObject file = manager.resolveFile("tgz:file://" + realFile.getCanonicalPath() + "!/"); assertNotNull(file); final List<FileObject> files = Arrays.asList(file.getChildren()); assertNotNull(files); assertEquals(1, files.size()); final FileObject f = files.get(0); assertTrue("Expected file not found: " + largeFileName + ".txt", f.getName().getBaseName().equals(largeFileName + ".txt")); }
private InputStream createEmptyFile() throws FileSystemException, IOException { final FileObject root = manager.resolveFile("ram://file"); root.createFile(); return this.closeOnTearDown(root.getContent().getInputStream()); }
public void testWindowsWrongRoots() throws Exception { final String[] tests = new String[] { "file:///C:", "file://C:", "file:/C:", "file:C:" }; for (final String name : tests) { try { final FileName fn = getManager().resolveFile(name).getName(); fail("should not accept root " + name); } catch (final FileSystemException ex) { assertEquals("vfs.provider/invalid-absolute-uri.error", ex.getCode()); assertTrue(ex.toString().indexOf(name) >= 0); } } }
@Test public void testGetInputStream() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); file.getContent().getInputStream().close(); }
/** * Tests root of file system exists. */ public void testRootURI() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } final FileSystem fileSystem = getFileSystem(); final String uri = fileSystem.getRootURI(); testRoot(getManager().resolveFile(uri, fileSystem.getFileSystemOptions())); }
public void testWindowsFilenameUNCStartError() throws Exception { try { final String FILE = "file://///"; final FileObject fo = getManager().resolveFile(FILE); fail("Windows File Parser should not allow " + FILE + " " + fo); } catch (FileSystemException ex) { assertEquals("Exception code", "vfs.provider/invalid-absolute-uri.error", ex.getCode()); ex = (FileSystemException) ex.getCause(); assertEquals("Exception code", "vfs.provider.local/missing-share-name.error", ex.getCode()); } }
@Test public void testIsWritable() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); Assert.assertFalse(file.isWriteable()); }
@Test public void testIsHidden() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); Assert.assertFalse(file.isHidden()); }
@Test public void testIsReadable() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); Assert.assertTrue(file.isReadable()); }
@Test public void testGetContentSize() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); Assert.assertEquals(0, file.getContent().getSize()); }
@Test public void testRandomAccessContent2() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); file.getContent().getRandomAccessContent(RandomAccessMode.READ).close(); }
@Test public void testLastModificationTime() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); Assert.assertFalse(-1 == file.getContent().getLastModifiedTime()); }