1 19 20 package org.netbeans.modules.masterfs.filebasedfs.fileobjects; 21 22 import java.io.IOException ; 23 import org.netbeans.junit.NbTestCase; 24 25 31 public class MutualExclusionSupportTest extends NbTestCase { 32 33 public MutualExclusionSupportTest(String testName) { 34 super(testName); 35 } 36 37 40 public void testAddResource() throws Exception { 41 Object key = new String ("key"); 42 43 MutualExclusionSupport.Closeable rem1 = MutualExclusionSupport.getDefault().addResource(key, true); 44 MutualExclusionSupport.Closeable rem2 = MutualExclusionSupport.getDefault().addResource(key, true); 45 46 try { 47 MutualExclusionSupport.Closeable rem3 = MutualExclusionSupport.getDefault().addResource(key, false); 48 fail (); 49 } catch (IOException iox) {} 50 51 rem1.close(); 52 53 try { 54 MutualExclusionSupport.Closeable rem3 = MutualExclusionSupport.getDefault().addResource(key, false); 55 fail (); 56 } catch (IOException iox) {} 57 58 rem2.close(); 59 60 try { 61 MutualExclusionSupport.Closeable rem3 = MutualExclusionSupport.getDefault().addResource(key, false); 62 rem3.close(); 63 } catch (IOException iox) { 64 fail (); 65 } 66 67 MutualExclusionSupport.Closeable rem4 = MutualExclusionSupport.getDefault().addResource(key, false); 68 69 try { 70 rem1 = MutualExclusionSupport.getDefault().addResource(key, true); 71 fail (); 72 } catch (IOException iox) { 73 } 74 75 try { 76 MutualExclusionSupport.Closeable rem3 = MutualExclusionSupport.getDefault().addResource(key, false); 77 fail (); 78 } catch (IOException iox) { 79 } 80 81 rem4.close(); 82 rem1 = MutualExclusionSupport.getDefault().addResource(key, true); 83 rem1.close(); 84 MutualExclusionSupport.Closeable rem3 = MutualExclusionSupport.getDefault().addResource(key, false); 85 rem3.close(); 86 } 87 88 91 } 92 | Popular Tags |