1 19 20 package org.openide.filesystems; 21 22 import org.netbeans.junit.MockServices; 23 import org.netbeans.junit.NbTestCase; 24 import org.openide.util.Lookup; 25 import org.openide.util.RequestProcessor; 26 27 32 public class MIMESupport48486Test extends NbTestCase { 33 36 private FileSystem lfs; 37 private FileObject mimeFo; 38 39 42 public MIMESupport48486Test(String name) { 43 super(name); 44 } 45 46 49 protected void setUp() throws Exception { 50 TestUtilHid.destroyLocalFileSystem(getName()); 51 lfs = TestUtilHid.createLocalFileSystem(getName(), new String []{"A.opqr", }); 52 mimeFo = lfs.findResource("A.opqr"); 53 assertNotNull(mimeFo); 54 MockServices.setServices(MamaResolver.class); 55 Lookup.getDefault().lookup(MamaResolver.class).fo = mimeFo; 56 } 57 58 public void testMimeResolverDeadlock() throws Exception { 59 mimeFo.getMIMEType(); 60 } 61 62 public static final class MamaResolver extends MIMEResolver implements Runnable { 63 boolean isRecursiveCall = false; 64 FileObject fo = null; 65 66 public void run() { 67 assert this.fo != null; 68 isRecursiveCall = true; 69 fo.getMIMEType(); 70 } 71 72 public String findMIMEType(FileObject fo) { 73 if (!isRecursiveCall) { 74 RequestProcessor.getDefault().post(this).waitFinished(); 75 } 76 return null; 77 } 78 } 79 80 } 81 | Popular Tags |