1 19 package org.netbeans.modules.apisupport.project; 20 21 import java.io.File ; 22 import java.io.IOException ; 23 import junit.framework.*; 24 import org.apache.tools.ant.module.api.support.ActionUtils; 25 import org.netbeans.junit.*; 26 import org.netbeans.modules.apisupport.project.layers.LayerTestBase; 27 import org.openide.DialogDescriptor; 28 import org.openide.filesystems.FileObject; 29 30 34 public class TestBuildCleanTest extends TestBase { 35 36 public TestBuildCleanTest(java.lang.String testName) { 37 super(testName); 38 } 39 static { 40 System.setProperty("org.netbeans.core.startup.ModuleSystem.CULPRIT", "true"); 42 LayerTestBase.Lkp.setLookup(new Object [0]); 43 DialogDisplayerImpl.returnFromNotify(DialogDescriptor.NO_OPTION); 44 } 45 46 protected void setUp() throws Exception { 47 clearWorkDir(); 48 super.setUp(); 49 InstalledFileLocatorImpl.registerDestDir(destDirF); 50 } 51 52 protected void tearDown() throws Exception { 53 super.tearDown(); 55 } 56 57 93 public void testExternalProject() throws Exception { 94 FileObject module1build = resolveEEP("/suite4/module1/build.xml"); 95 FileObject module2build = resolveEEP("/suite4/module2/build.xml"); 96 runTask(module1build,"test-build"); 97 checkTestExternal("module1",true); 98 runTask(module2build,"test-build"); 99 checkTestExternal("module2",true); 100 runTask(module1build,"clean"); 101 checkTestExternal("module1",false); 102 } 103 104 private void checkTest(String cnb, String cluster, String testtype, boolean exist) { 105 String path = "nbbuild/build/testdist/" + testtype + "/" + cluster + "/" + cnb + "/tests.jar"; 106 FileObject testsFo = nbCVSRoot().getFileObject(path); 107 if (exist) { 108 assertTrue("test.jar for " + path + " doesn't exist.", testsFo != null && testsFo.isValid()); 109 } else { 110 assertTrue("test.jar for " + path + " exists.", testsFo == null || !testsFo.isValid()); 111 } 112 } 113 114 private void deleteTests(String cnb,String cluster,String testtype) throws IOException { 115 String path = "nbbuild/build/testdist/" + testtype + "/" + cluster + "/" + cnb + "/tests.jar"; 116 FileObject testsFo = nbCVSRoot().getFileObject(path); 117 if (testsFo.isValid()) { 118 } 120 } 121 private void runTask(FileObject fo, String target) throws IOException { 122 ActionUtils.runTarget(fo,new String []{target},null).waitFinished(); 123 } 124 125 private void checkTestExternal(String cnd, boolean exist) { 126 String path = "/suite4/build/testdist/unit/cluster/" + cnd + "/tests.jar"; 127 File tests = resolveEEPFile(path); 128 if (exist) { 129 assertTrue("test.jar for " + path + " doesn't exist.",tests.exists()); 130 } else { 131 assertTrue("test.jar for " + path + " exists.", !tests.exists()); 132 } 133 } 134 } 135 | Popular Tags |