1 19 20 package org.netbeans.modules.apisupport.project; 21 22 import java.io.File ; 23 import java.io.InputStream ; 24 import javax.swing.JOptionPane ; 25 import org.apache.tools.ant.module.api.support.ActionUtils; 26 import org.netbeans.api.project.ProjectManager; 27 import org.netbeans.modules.apisupport.project.layers.LayerTestBase; 28 import org.netbeans.modules.apisupport.project.suite.SuiteProject; 29 import org.netbeans.spi.project.support.ant.GeneratedFilesHelper; 30 import org.openide.DialogDescriptor; 31 import org.openide.execution.ExecutorTask; 32 import org.openide.filesystems.FileObject; 33 import org.openide.filesystems.FileUtil; 34 35 41 public class BuildFeedreaderTest extends TestBase { 42 43 private File feedFolder = null; 44 45 static { 46 System.setProperty("org.netbeans.core.startup.ModuleSystem.CULPRIT", "true"); 48 LayerTestBase.Lkp.setLookup(new Object [0]); 49 DialogDisplayerImpl.returnFromNotify(DialogDescriptor.NO_OPTION); 50 } 51 52 public BuildFeedreaderTest(String testName) { 53 super(testName); 54 } 55 56 protected void setUp() throws Exception { 57 clearWorkDir(); 58 noDataDir = true; 59 super.setUp(); 60 InstalledFileLocatorImpl.registerDestDir(destDirF); 61 TestAntLogger.getDefault().setEnabled(true); 62 } 63 64 protected void tearDown() throws Exception { 65 TestAntLogger.getDefault().setEnabled(false); 66 } 67 68 71 public int runAntTargetsOnFeedreader(String [] targets) throws Exception { 72 InputStream is = getClass().getClassLoader().getResourceAsStream("org/netbeans/modules/apisupport/feedreader/FeedReaderProject.zip"); 73 assertNotNull(is); 74 feedFolder = new File (getWorkDir(),"feedreader"); 75 feedFolder.mkdir(); 76 FileObject fo = FileUtil.toFileObject(feedFolder); 77 assertNotNull(fo); 78 79 80 try { 81 FileUtil.extractJar(fo,is); 82 } finally { 83 is.close(); 84 } 85 86 File buildProps = new File (getWorkDir(), "build.properties"); 87 File privateFolder = new File (new File (feedFolder, "nbproject"),"private"); 88 privateFolder.mkdir(); 89 90 FileObject platfPrivateProps = FileUtil.copyFile(FileUtil.toFileObject(buildProps), FileUtil.toFileObject(privateFolder), "platform-private"); 91 assertNotNull(platfPrivateProps); 92 SuiteProject feedreaderSuite = (SuiteProject) ProjectManager.getDefault().findProject(fo); 93 assertNotNull(feedreaderSuite); 94 FileObject buildScript = feedreaderSuite.getProjectDirectory().getFileObject(GeneratedFilesHelper.BUILD_XML_PATH); 95 assertNotNull(buildScript); 96 assertTrue(buildScript.isValid()); 97 98 System.out.println("------------- BUILD OUTPUT --------------"); 99 ExecutorTask et = ActionUtils.runTarget(buildScript, targets, null); 100 et.waitFinished(); 101 System.out.println("-----------------------------------------"); 102 103 return et.result(); 104 } 105 106 109 public void testBuildJNLP() throws Exception { 110 int ret = runAntTargetsOnFeedreader(new String [] {"build-jnlp"}); 111 assertEquals("build-jnlp ant target should return zero - build successful", 0 , ret); 112 } 113 114 117 public void testBuildZip() throws Exception { 118 int ret = runAntTargetsOnFeedreader(new String [] {"build-zip"}); 119 assertEquals("build-zipant target should return zero - build successful", 0 , ret); 120 } 121 122 125 public void testBuild() throws Exception { 126 int ret = runAntTargetsOnFeedreader(new String [] {"build"}); 127 assertEquals("build ant target should return zero - build successful", 0 , ret); 128 } 129 130 133 public void testBuildNBMs() throws Exception { 134 int ret = runAntTargetsOnFeedreader(new String [] {"nbms"}); 135 assertEquals("build ant target should return zero - build successful", 0 , ret); 136 } 137 138 141 public void testClean() throws Exception { 142 int ret = runAntTargetsOnFeedreader(new String [] {"clean"}); 143 assertEquals("clean ant target should return zero - build successful", 0 , ret); 144 } 145 146 } 147 148 | Popular Tags |