1 19 20 package org.netbeans.modules.tasklist.docscan; 21 22 import java.io.File ; 23 import org.openide.loaders.DataObject; 24 import org.openide.filesystems.Repository; 25 import java.net.URL ; 26 import java.util.List ; 27 import junit.framework.TestCase; 28 import org.netbeans.junit.NbTestCase; 29 import org.netbeans.modules.tasklist.providers.SuggestionContexts; 30 import org.netbeans.modules.tasklist.suggestions.Types; 31 import org.openide.filesystems.FileObject; 32 import org.openide.filesystems.FileSystem; 33 import org.openide.filesystems.LocalFileSystem; 34 35 40 public class SourceTaskProviderTest extends TestCase { 41 42 public SourceTaskProviderTest (String name) { 43 super (name); 44 } 45 46 47 private FileSystem dataFS; 48 49 protected void setUp () throws Exception { 50 URL url = this.getClass().getResource("data"); 51 String resString = NbTestCase.convertNBFSURL(url); 52 LocalFileSystem fs = new LocalFileSystem(); 53 fs.setRootDirectory(new File (resString)); 54 Repository.getDefault().addFileSystem(fs); 55 dataFS = fs; 56 57 Types.installSuggestionTypes(); 58 } 59 60 protected void tearDown () throws Exception { 61 Repository.getDefault().removeFileSystem(dataFS); 62 } 63 64 73 public void testSourceScanner() throws Exception { 74 Settings settings = Settings.getDefault(); 75 settings.setSkipComments(true); 76 assertTrue("Skip Comments bean doesn't work", settings.getSkipComments()); 77 78 SourceTaskProvider scanner = new SourceTaskProvider(); 79 FileObject fo = dataFS.findResource("Comments.java"); 80 DataObject dobj = DataObject.find(fo); 81 List result = scanner.scan(SuggestionContexts.forDataObject(dobj)); 82 83 assertTrue(result.size() == 7); 84 85 87 } 186 187 188 192 public void testDuplicates27459() throws Exception { 193 194 Settings settings = Settings.getDefault(); 195 settings.setSkipComments(true); 196 assertTrue("Skip Comments bean doesn't work", settings.getSkipComments()); 197 198 SourceTaskProvider scanner = new SourceTaskProvider(); 199 FileObject fo = dataFS.findResource("iz27459.java"); 200 DataObject dobj = DataObject.find(fo); 201 List result = scanner.scan(SuggestionContexts.forDataObject(dobj)); 202 203 assertTrue(result.size() == 3); 204 205 207 } 304 305 308 public void testDirectoryScan() throws Exception { 309 311 } 354 } 355 | Popular Tags |