1 19 20 package org.netbeans.modules.apisupport.project; 21 22 import java.io.File ; 23 import org.netbeans.api.project.Project; 24 import org.netbeans.api.project.ProjectManager; 25 import org.netbeans.spi.project.support.ant.EditableProperties; 26 import org.netbeans.spi.project.support.ant.PropertyEvaluator; 27 import org.openide.filesystems.FileObject; 28 import org.openide.filesystems.FileUtil; 29 30 34 public class EvaluatorTest extends TestBase { 35 36 public EvaluatorTest(String name) { 37 super(name); 38 } 39 40 private NbModuleProject javaProjectProject; 41 private NbModuleProject loadersProject; 42 private File userPropertiesFile; 43 44 protected void setUp() throws Exception { 45 super.setUp(); 46 userPropertiesFile = TestBase.initializeBuildProperties(getWorkDir(), getDataDir()); 47 FileObject dir = nbCVSRoot().getFileObject("java/project"); 48 assertNotNull("have java/project checked out", dir); 49 Project p = ProjectManager.getDefault().findProject(dir); 50 javaProjectProject = (NbModuleProject)p; 51 dir = nbCVSRoot().getFileObject("openide/loaders"); 52 assertNotNull("have openide/loaders checked out", dir); 53 p = ProjectManager.getDefault().findProject(dir); 54 loadersProject = (NbModuleProject)p; 55 } 56 57 public void testEvaluator() throws Exception { 58 PropertyEvaluator eval = javaProjectProject.evaluator(); 59 assertEquals("right basedir", file("java/project"), 60 javaProjectProject.getHelper().resolveFile(eval.getProperty("basedir"))); 61 assertEquals("right nb_all", nbCVSRootFile(), 62 javaProjectProject.getHelper().resolveFile(eval.getProperty("nb_all"))); 63 assertEquals("right code.name.base.dashes", "org-netbeans-modules-java-project", eval.getProperty("code.name.base.dashes")); 64 assertEquals("right is.autoload", "true", eval.getProperty("is.autoload")); 65 assertEquals("right manifest.mf", "manifest.mf", eval.getProperty("manifest.mf")); 66 assertEquals("right core.dir", file("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM), 67 javaProjectProject.getHelper().resolveFile(eval.getProperty("core.dir"))); 68 assertEquals("right apisupport/project.dir", file("nbbuild/netbeans/" + TestBase.CLUSTER_IDE), 69 javaProjectProject.getHelper().resolveFile(eval.getProperty("apisupport/project.dir"))); 70 assertEquals("right module JAR", file("nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-java-project.jar"), 71 javaProjectProject.getHelper().resolveFile(eval.evaluate("${cluster}/${module.jar}"))); 72 eval = loadersProject.evaluator(); 73 assertEquals("right module JAR", file("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"), 74 loadersProject.getHelper().resolveFile(eval.evaluate("${cluster}/${module.jar}"))); 75 } 76 77 78 public void testJdkProperties() throws Exception { 79 File testjdk = new File (getWorkDir(), "testjdk"); 80 EditableProperties ep = Util.loadProperties(FileUtil.toFileObject(userPropertiesFile)); 81 ep.setProperty("platforms.testjdk.home", testjdk.getAbsolutePath()); 82 Util.storeProperties(FileUtil.toFileObject(userPropertiesFile), ep); 83 NbModuleProject p = generateStandaloneModule("module"); 84 PropertyEvaluator eval = p.evaluator(); 85 TestBase.TestPCL l = new TestBase.TestPCL(); 86 eval.addPropertyChangeListener(l); 87 String bootcp = eval.getProperty("nbjdk.bootclasspath"); 88 String origbootcp = bootcp; 89 assertNotNull(bootcp); ep = p.getHelper().getProperties("nbproject/platform.properties"); 91 ep.setProperty("nbjdk.active", "testjdk"); 92 p.getHelper().putProperties("nbproject/platform.properties", ep); 93 assertTrue("got a change in bootcp", l.changed.contains("nbjdk.bootclasspath")); 94 l.reset(); 95 bootcp = eval.getProperty("nbjdk.bootclasspath"); 96 assertEquals("correct bootcp", new File (testjdk, "jre/lib/rt.jar".replace('/', File.separatorChar)).getAbsolutePath(), bootcp); 97 ep = p.getHelper().getProperties("nbproject/platform.properties"); 98 ep.setProperty("nbjdk.active", "default"); 99 p.getHelper().putProperties("nbproject/platform.properties", ep); 100 assertTrue("got a change in bootcp", l.changed.contains("nbjdk.bootclasspath")); 101 l.reset(); 102 bootcp = eval.getProperty("nbjdk.bootclasspath"); 103 assertEquals(origbootcp, bootcp); 104 } 105 106 } 107 | Popular Tags |