1 19 20 package org.openide.filesystems; 21 22 import java.io.IOException ; 23 24 public class MultiFileObjectTestHid extends TestBaseHid { 25 private static String [] resources = new String [] { 26 "/fold10/fold11/fold12", 27 "/fold20/fold21/fold22", 28 "/fold20/fold23.txt" 29 }; 30 31 public MultiFileObjectTestHid(String testName) { 32 super(testName); 33 } 34 35 36 protected String [] getResources (String testName) { 37 return resources; 38 } 39 40 41 public void testDeleteMask() throws IOException { 42 FileSystem mfs = new MultiFileSystem (new FileSystem[] {this.testedFS}); 43 FileSystem wfs; 44 FileSystem [] allFs = this.allTestedFS; 45 if (allFs.length > 1 && !allFs[1].isReadOnly()) 46 wfs = allFs[1]; 47 else return; 48 String resource = "/fold20/fold23.txt"; 49 String resource_hidden = "/fold20/fold23.txt_hidden"; 50 51 FileObject fo = mfs.findResource(resource); 52 fo.delete(); 53 54 FileObject hidd = wfs.findResource(resource_hidden); 55 if (hidd == null) return; 56 57 hidd.delete(); 58 59 fo = mfs.findResource(resource); 60 fsAssert(resource+" should be present after deleting mask",fo != null); 61 } 62 63 64 65 public void testDeleteFolder() throws IOException { 66 FileSystem mfs = this.testedFS; 67 68 FileObject testFo = mfs.findResource("/fold20/fold21/fold22"); 69 fsAssert("/fold20/fold21/fold22 should be present",testFo != null); 70 71 FileObject toDel = mfs.findResource("/fold20"); 72 fsAssert("/fold20 should be present",toDel != null); 73 74 FileObject parent = toDel.getParent(); 75 76 toDel.delete(); 77 78 toDel = mfs.findResource("/fold20"); 79 fsAssert("/fold20 should not be present",toDel == null); 80 81 82 parent.createFolder("fold20"); 83 toDel = mfs.findResource("/fold20"); 84 fsAssert("/fold20 should be present",toDel != null); 85 86 87 90 testFo = mfs.findResource("/fold20/fold21/fold22"); 91 fsAssert("/fold20/fold21/fold22 should not be present",testFo == null); 92 } 93 94 public void testBug19425 () throws IOException { 95 String whereRes = "/fold10"; 96 String whatRes = "/fold20/fold23.txt"; 97 98 FileSystem mfs = this.allTestedFS[0]; 99 FileSystem lfsLayer = this.allTestedFS[1]; 100 FileSystem xfsLayer = this.allTestedFS[2]; 101 102 boolean needsMask = (xfsLayer.findResource (whatRes) != null); 103 104 105 FileObject where = mfs.findResource (whereRes); 106 FileObject what = mfs.findResource (whatRes); 107 108 fsAssert ("Expected resource: " + whereRes, whereRes != null); 109 fsAssert ("Expected resource: " + whatRes, whatRes != null); 110 111 FileLock fLock = what.lock(); 112 try { 113 what.move (fLock,where,what.getName(),what.getExt()); 114 if (needsMask) 115 fsAssert ("Must exist mask", lfsLayer.findResource(whatRes+"_hidden") != null); 116 else 117 fsAssert ("Mustn`t exist mask", lfsLayer.findResource(whatRes+"_hidden") == null); 118 119 } finally { 120 fLock.releaseLock(); 121 } 122 } 123 124 125 public void testSetDelegates() throws IOException { 126 FileSystem mfs = this.testedFS; 127 MultiFileSystem mfs2 = new MultiFileSystem (new FileSystem[] {mfs}); 128 129 try { 130 mfs2.setDelegates(new FileSystem[] {mfs,null}); 131 } catch (NullPointerException npe) { 132 fsFail ("Null delegates should be supported"); 133 } 134 } 135 136 } 137 | Popular Tags |