1 19 20 package org.netbeans.modules.apisupport.project.queries; 21 22 import org.netbeans.api.java.classpath.ClassPath; 23 import org.netbeans.api.project.FileOwnerQuery; 24 import org.netbeans.api.project.Project; 25 import org.netbeans.api.project.ProjectManager; 26 import org.netbeans.modules.apisupport.project.TestBase; 27 import org.netbeans.spi.project.support.ant.PropertyUtils; 28 import org.openide.filesystems.FileObject; 29 import org.openide.filesystems.FileUtil; 30 31 35 public class UpdateTrackingFileOwnerQueryTest extends TestBase { 36 37 public UpdateTrackingFileOwnerQueryTest(String name) { 38 super(name); 39 } 40 41 public void testOwnershipNetBeansOrg() throws Exception { 42 assertOwnership("ant", "nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-apache-tools-ant-module.jar"); 44 assertOwnership("ant", "nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/ant/nblib/bridge.jar"); 46 assertTrue("ant module built (cannot scan by pattern unless files exist)", file("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/ant/lib/ant.jar").isFile()); 48 assertOwnership("ant", "nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/ant/lib/ant.jar"); 49 assertOwnership("ant", "nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/config/Modules/org-apache-tools-ant-module.xml"); 51 assertOwnership("ant", "nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/update_tracking/org-apache-tools-ant-module.xml"); 52 assertOwnership("core/javahelp", "nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/ext/jh-2.0_04.jar"); 54 assertOwnership("extbrowser", "nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/lib/extbrowser.dll"); 56 } 57 58 public void testOwnershipExternal() throws Exception { 59 assertOwnership(resolveEEPPath("/suite1/action-project"), resolveEEPPath("/suite1/build/cluster/modules/org-netbeans-examples-modules-action.jar")); 61 assertOwnership(resolveEEPPath("/suite1/action-project"), resolveEEPPath("/suite1/build/cluster/update_tracking/org-netbeans-examples-modules-action.xml")); 62 } 63 64 private void assertOwnership(String project, String file) throws Exception { 65 FileObject projectFO = FileUtil.toFileObject(PropertyUtils.resolveFile(nbCVSRootFile(), project)); 66 assertNotNull("have project " + project, projectFO); 67 Project p = ProjectManager.getDefault().findProject(projectFO); 68 assertNotNull("have a project in " + project, p); 69 ClassPath.getClassPath(projectFO.getFileObject("src"), ClassPath.COMPILE); 71 FileObject fileFO = FileUtil.toFileObject(PropertyUtils.resolveFile(nbCVSRootFile(), file)); 72 if (fileFO != null) { assertEquals("correct owner by FileObject of " + file, p, FileOwnerQuery.getOwner(fileFO)); 74 } 75 assertEquals("correct owner by URI of " + file, p, FileOwnerQuery.getOwner( 76 PropertyUtils.resolveFile(nbCVSRootFile(), file).toURI())); 77 } 78 79 } 80 | Popular Tags |