1 19 20 package org.netbeans.modules.java.freeform; 21 22 import java.net.URL ; 23 import java.util.Arrays ; 24 import java.util.Collections ; 25 import org.netbeans.api.java.queries.SourceForBinaryQuery; 26 import org.netbeans.modules.ant.freeform.TestBase; 27 import org.openide.filesystems.FileObject; 28 29 33 public class SourceForBinaryQueryImplTest extends TestBase { 34 35 public SourceForBinaryQueryImplTest(String name) { 36 super(name); 37 } 38 39 public void testFindSourcesForBinaries() throws Exception { 40 FileObject srcroot = simple.getProjectDirectory().getFileObject("src"); 41 URL binroot = new URL (simple.getProjectDirectory().getURL(), "build/classes/"); 42 assertEquals("correct source root for " + binroot, Collections.singletonList(srcroot), Arrays.asList(SourceForBinaryQuery.findSourceRoots(binroot).getRoots())); 43 binroot = new URL ("jar:" + simple.getProjectDirectory().getURL().toString() + "build/simple-app.jar!/"); 44 assertEquals("correct source root for " + binroot, Collections.singletonList(srcroot), Arrays.asList(SourceForBinaryQuery.findSourceRoots(binroot).getRoots())); 45 srcroot = simple.getProjectDirectory().getFileObject("antsrc"); 46 binroot = new URL (simple.getProjectDirectory().getURL(), "build/antclasses/"); 47 assertEquals("correct source root for " + binroot, Collections.singletonList(srcroot), Arrays.asList(SourceForBinaryQuery.findSourceRoots(binroot).getRoots())); 48 binroot = new URL (simple.getProjectDirectory().getURL(), "build/nonsense/"); 49 assertEquals("no source root for " + binroot, Collections.EMPTY_LIST, Arrays.asList(SourceForBinaryQuery.findSourceRoots(binroot).getRoots())); 50 } 51 52 } 53 | Popular Tags |