Lines 51-57
Link Here
|
51 |
import java.util.logging.Level; |
51 |
import java.util.logging.Level; |
52 |
import org.netbeans.junit.NbTestCase; |
52 |
import org.netbeans.junit.NbTestCase; |
53 |
import org.netbeans.modules.projectapi.TimedWeakReference; |
53 |
import org.netbeans.modules.projectapi.TimedWeakReference; |
|
|
54 |
import org.openide.filesystems.FileAttributeEvent; |
55 |
import org.openide.filesystems.FileChangeListener; |
56 |
import org.openide.filesystems.FileEvent; |
54 |
import org.openide.filesystems.FileObject; |
57 |
import org.openide.filesystems.FileObject; |
|
|
58 |
import org.openide.filesystems.FileRenameEvent; |
59 |
import org.openide.util.Mutex; |
55 |
import org.openide.util.test.MockLookup; |
60 |
import org.openide.util.test.MockLookup; |
56 |
|
61 |
|
57 |
/* XXX tests needed: |
62 |
/* XXX tests needed: |
Lines 67-73
Link Here
|
67 |
* Test ProjectManager find and save functionality. |
72 |
* Test ProjectManager find and save functionality. |
68 |
* @author Jesse Glick |
73 |
* @author Jesse Glick |
69 |
*/ |
74 |
*/ |
70 |
public class ProjectManagerTest extends NbTestCase { |
75 |
public class ProjectManagerTest extends NbTestCase |
|
|
76 |
implements FileChangeListener { |
71 |
|
77 |
|
72 |
static { |
78 |
static { |
73 |
// For easier testing. |
79 |
// For easier testing. |
Lines 92-97
Link Here
|
92 |
protected void setUp() throws Exception { |
98 |
protected void setUp() throws Exception { |
93 |
super.setUp(); |
99 |
super.setUp(); |
94 |
scratch = TestUtil.makeScratchDir(this); |
100 |
scratch = TestUtil.makeScratchDir(this); |
|
|
101 |
|
102 |
scratch.getFileSystem().addFileChangeListener(this); |
103 |
|
95 |
goodproject = scratch.createFolder("good"); |
104 |
goodproject = scratch.createFolder("good"); |
96 |
goodproject.createFolder("testproject"); |
105 |
goodproject.createFolder("testproject"); |
97 |
goodproject2 = scratch.createFolder("good2"); |
106 |
goodproject2 = scratch.createFolder("good2"); |
Lines 106-111
Link Here
|
106 |
} |
115 |
} |
107 |
|
116 |
|
108 |
protected void tearDown() throws Exception { |
117 |
protected void tearDown() throws Exception { |
|
|
118 |
scratch.getFileSystem().removeFileChangeListener(this); |
119 |
|
109 |
scratch = null; |
120 |
scratch = null; |
110 |
goodproject = null; |
121 |
goodproject = null; |
111 |
badproject = null; |
122 |
badproject = null; |
Lines 343-348
Link Here
|
343 |
assertNotNull("now p3 is recognized as a non-broken project", pm.findProject(p3)); |
354 |
assertNotNull("now p3 is recognized as a non-broken project", pm.findProject(p3)); |
344 |
assertEquals("p1 still recognized as a project", proj1, pm.findProject(p1)); |
355 |
assertEquals("p1 still recognized as a project", proj1, pm.findProject(p1)); |
345 |
} |
356 |
} |
|
|
357 |
public void testClearNonProjectCacheInWriteAccess() throws Exception { |
358 |
ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() { |
359 |
public Void run() throws Exception { |
360 |
testClearNonProjectCache(); |
361 |
return null; |
362 |
} |
363 |
}); |
364 |
} |
365 |
public void testClearNonProjectCacheInReadAccess() throws Exception { |
366 |
ProjectManager.mutex().readAccess(new Mutex.ExceptionAction<Void>() { |
367 |
public Void run() throws Exception { |
368 |
testClearNonProjectCache(); |
369 |
return null; |
370 |
} |
371 |
}); |
372 |
} |
346 |
|
373 |
|
347 |
public void testLoadExceptionWithConcurrentLoad() throws Exception { |
374 |
public void testLoadExceptionWithConcurrentLoad() throws Exception { |
348 |
TestUtil.BROKEN_PROJECT_LOAD_LOCK = new Object(); |
375 |
TestUtil.BROKEN_PROJECT_LOAD_LOCK = new Object(); |
Lines 473-476
Link Here
|
473 |
assertTrue("An IllegalStateException was thrown when calling notifyDeleted twice.", wasException); |
500 |
assertTrue("An IllegalStateException was thrown when calling notifyDeleted twice.", wasException); |
474 |
} |
501 |
} |
475 |
|
502 |
|
|
|
503 |
private void assertNoAccess() { |
504 |
assertFalse("No read access", ProjectManager.mutex().isReadAccess()); |
505 |
assertFalse("No write access", ProjectManager.mutex().isWriteAccess()); |
476 |
} |
506 |
} |
|
|
507 |
|
508 |
public void fileFolderCreated(FileEvent fe) { |
509 |
assertNoAccess(); |
510 |
} |
511 |
|
512 |
public void fileDataCreated(FileEvent fe) { |
513 |
assertNoAccess(); |
514 |
} |
515 |
|
516 |
public void fileChanged(FileEvent fe) { |
517 |
assertNoAccess(); |
518 |
} |
519 |
|
520 |
public void fileDeleted(FileEvent fe) { |
521 |
assertNoAccess(); |
522 |
} |
523 |
|
524 |
public void fileRenamed(FileRenameEvent fe) { |
525 |
assertNoAccess(); |
526 |
} |
527 |
|
528 |
public void fileAttributeChanged(FileAttributeEvent fe) { |
529 |
assertNoAccess(); |
530 |
} |
531 |
} |