1 16 package org.apache.commons.vfs.provider.test; 17 18 import org.apache.commons.AbstractVfsTestCase; 19 import org.apache.commons.vfs.FileObject; 20 import org.apache.commons.vfs.FileSystem; 21 import org.apache.commons.vfs.FileSystemException; 22 import org.apache.commons.vfs.test.AbstractProviderTestCase; 23 24 import java.io.File ; 25 26 31 public class JunctionTests 32 extends AbstractProviderTestCase 33 { 34 private FileObject getBaseDir() throws FileSystemException 35 { 36 final File file = AbstractVfsTestCase.getTestDirectoryFile(); 37 assertTrue(file.exists()); 38 return getManager().toFileObject(file); 39 } 40 41 44 public void testNestedJunction() throws Exception 45 { 46 final FileSystem fs = getManager().createVirtualFileSystem("vfs:").getFileSystem(); 47 final FileObject baseDir = getBaseDir(); 48 fs.addJunction("/a", baseDir); 49 50 try 52 { 53 fs.addJunction("/a/b", baseDir); 54 fail(); 55 } 56 catch (final Exception e) 57 { 58 assertSameMessage("vfs.impl/nested-junction.error", "vfs:/a/b", e); 59 } 60 61 try 63 { 64 fs.addJunction("/a", baseDir); 65 fail(); 66 } 67 catch (final Exception e) 68 { 69 assertSameMessage("vfs.impl/nested-junction.error", "vfs:/a", e); 70 } 71 } 72 73 76 public void testAncestors() throws Exception 77 { 78 final FileSystem fs = getManager().createVirtualFileSystem("vfs://").getFileSystem(); 79 final FileObject baseDir = getBaseDir(); 80 81 FileObject file = fs.resolveFile("/a/b"); 83 assertFalse(file.exists()); 84 file = file.getParent(); 85 assertFalse(file.exists()); 86 file = file.getParent(); 87 assertFalse(file.exists()); 88 89 fs.addJunction("/a/b", baseDir); 91 92 file = fs.resolveFile("/a/b"); 94 assertTrue("Does not exist", file.exists()); 95 file = file.getParent(); 96 assertTrue("Does not exist", file.exists()); 97 file = file.getParent(); 98 assertTrue("Does not exist", file.exists()); 99 } 100 101 107 } 108 | Popular Tags |