1 19 20 package org.openide.filesystems; 21 22 import org.netbeans.junit.*; 23 import junit.textui.TestRunner; 24 25 31 public class MultiFileSystemRefreshTest extends NbTestCase implements FileChangeListener { 32 33 public MultiFileSystemRefreshTest(String name) { 34 super(name); 35 } 36 37 public static void main(String [] args) { 38 TestRunner.run(new NbTestSuite(MultiFileSystemRefreshTest.class)); 39 } 40 41 private FileSystem fs1, fs2; 42 protected void setUp() throws Exception { 43 super.setUp(); 44 fs1 = TestUtilHid.createLocalFileSystem("mfsrefresh1"+getName() + "1", new String [] { 45 "a/b/c.txt", 46 "a/b/d.txt", 47 "e/f.txt", 48 }); 49 fs2 = TestUtilHid.createLocalFileSystem("mfsrefresh2"+getName() + "2", new String [] { 50 "e/g.txt", 51 }); 52 } 53 protected void tearDown() throws Exception { 54 TestUtilHid.destroyLocalFileSystem(getName() + "1"); 55 TestUtilHid.destroyLocalFileSystem(getName() + "2"); 56 super.tearDown(); 57 } 58 59 private int count; 60 61 public void testSetDelegatesFiring() throws Exception { 62 MultiFileSystem mfs = new MultiFileSystem(new FileSystem[] {fs1, fs2}); 63 FileObject a = mfs.findResource("a"); 65 assertNotNull(a); 66 assertEquals(1, a.getChildren().length); 67 a.addFileChangeListener(this); 68 FileObject e = mfs.findResource("e"); 69 assertNotNull(e); 70 assertEquals(2, e.getChildren().length); 71 e.addFileChangeListener(this); 72 count = 0; 73 mfs.setDelegates(new FileSystem[] {fs1}); 74 System.err.println("setDelegates done"); 75 assertEquals(1, a.getChildren().length); 76 assertEquals(1, e.getChildren().length); 77 assertEquals(1, count); 78 } 79 80 public void fileAttributeChanged(FileAttributeEvent fe) { 81 System.err.println("attr changed: " + fe); 82 count++; 83 } 84 85 public void fileChanged(FileEvent fe) { 86 System.err.println("changed: " + fe); 87 count++; 88 } 89 90 public void fileDataCreated(FileEvent fe) { 91 System.err.println("created: " + fe); 92 count++; 93 } 94 95 public void fileDeleted(FileEvent fe) { 96 System.err.println("deleted: " + fe); 97 count++; 98 } 99 100 public void fileFolderCreated(FileEvent fe) { 101 System.err.println("folder created: " + fe); 102 count++; 103 } 104 105 public void fileRenamed(FileRenameEvent fe) { 106 System.err.println("renamed: " + fe); 107 count++; 108 } 109 110 } 111 | Popular Tags |