1 19 20 package org.netbeans.modules.masterfs; 21 22 import java.io.File ; 23 import org.netbeans.junit.NbTestCase; 24 import org.netbeans.modules.masterfs.providers.AnnotationProvider; 25 import org.openide.filesystems.FileLock; 26 import org.openide.filesystems.FileObject; 27 import org.openide.filesystems.FileUtil; 28 import org.openide.util.Lookup; 29 import org.openide.util.RequestProcessor; 30 import org.openide.util.lookup.Lookups; 31 import org.openide.util.lookup.ProxyLookup; 32 33 36 public class Deadlock73332 extends NbTestCase { 37 private static FileObject folder; 38 static { 39 System.setProperty("org.openide.util.Lookup", Deadlock73332.TestLookup.class.getName()); 40 assertTrue(Lookup.getDefault().getClass().getName(),Lookup.getDefault() instanceof Deadlock73332.TestLookup); 41 } 42 43 44 public Deadlock73332(String testName) { 45 super(testName); 46 } 47 48 public void testDeadLock() throws Exception { 49 assertNotNull(folder); 50 assertTrue(folder instanceof MasterFileObject); 51 FileObject data = FileUtil.createData(folder, "/a/b/c/data.txt"); 52 assertNotNull(data); 53 FileLock lock = data.lock(); 54 try { 55 data.move(lock,folder, data.getName(), data.getExt()); 56 } finally { 57 lock.releaseLock(); 58 } 59 } 60 61 protected void setUp() throws Exception { 62 super.setUp(); 63 clearWorkDir(); 64 File f = this.getWorkDir(); 65 folder = FileUtil.toFileObject(f); 66 } 67 68 public static class TestLookup extends ProxyLookup { 69 public TestLookup() { 70 super(); 71 setLookups(new Lookup[] {getMetaInfLookup()}); 72 } 73 74 private Lookup getMetaInfLookup() { 75 return Lookups.metaInfServices(Thread.currentThread().getContextClassLoader()); 76 } 77 78 protected void beforeLookup(Lookup.Template template) { 79 if (template.getType().isAssignableFrom(AnnotationProvider.class)) { 80 RequestProcessor.Task task = RequestProcessor.getDefault().post(new Runnable () { 81 public void run() { 82 folder.getChildren(true); 83 } 84 }); 85 task.waitFinished(); 86 } 87 } 88 } 89 90 } 91 | Popular Tags |