001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.apisupport.project;
042:
043: import java.io.File;
044: import java.io.IOException;
045: import junit.framework.*;
046: import org.apache.tools.ant.module.api.support.ActionUtils;
047: import org.netbeans.junit.*;
048: import org.netbeans.modules.apisupport.project.layers.LayerTestBase;
049: import org.openide.DialogDescriptor;
050: import org.openide.filesystems.FileObject;
051:
052: /**
053: * Test building and cleaning tests
054: * @author pzajac
055: */
056: public class TestBuildCleanTest extends TestBase {
057:
058: public TestBuildCleanTest(java.lang.String testName) {
059: super (testName);
060: }
061:
062: static {
063: // #65461: do not try to load ModuleInfo instances from ant module
064: System.setProperty(
065: "org.netbeans.core.startup.ModuleSystem.CULPRIT",
066: "true");
067: LayerTestBase.Lkp.setLookup(new Object[0]);
068: DialogDisplayerImpl
069: .returnFromNotify(DialogDescriptor.NO_OPTION);
070: }
071:
072: protected void setUp() throws Exception {
073: clearWorkDir();
074: super .setUp();
075: InstalledFileLocatorImpl.registerDestDir(destDirF);
076: }
077:
078: protected void tearDown() throws Exception {
079: // restore jars
080: super .tearDown();
081: }
082:
083: // public void testNBCVSProject() throws Exception {
084: // FileObject fsbuild = nbCVSRoot().getFileObject("openide/fs/build.xml");
085: // FileObject msfsbuild = nbCVSRoot().getFileObject("openide/masterfs/build.xml");
086: // FileObject loadersBuild = nbCVSRoot().getFileObject("openide/loaders/build.xml");
087: // try {
088: // // Check unit tests
089: // //
090: // runTask(fsbuild,"test-build");
091: // checkTest("org-openide-filesystems",CLUSTER_PLATFORM,"unit",true);
092: // // masterfs tests depends on fs tests
093: // runTask(msfsbuild,"test-build");
094: // checkTest("org-netbeans-modules-masterfs",CLUSTER_PLATFORM,"unit",true);
095: //
096: // deleteTests("org-openide-filesystems",CLUSTER_PLATFORM,"unit");
097: //// checkTest("org-openide-filesystems",CLUSTER_PLATFORM,"unit",false);
098: // runTask(fsbuild,"test-build");
099: // checkTest("org-openide-filesystems",CLUSTER_PLATFORM,"unit",true);
100: //
101: // // check qa-functional tests
102: // runTask(loadersBuild,"test-build-qa-functional");
103: // checkTest("org-openide-loaders",CLUSTER_PLATFORM,"qa-functional",true);
104: //// deleteTests("org-openide-loaders",CLUSTER_PLATFORM,"qa-functional");
105: //// checkTest("org-openide-loaders",CLUSTER_PLATFORM,"qa-functional",false);
106: // } finally {
107: // String pathfs = "nbbuild/build/testdist/unit/" + CLUSTER_PLATFORM + "/org-openide-fs/tests.jar";
108: // String pathjava = "nbbuild/build/testdist/unit/" + CLUSTER_IDE + "/org-netbeans-modules-java-project/tests.jar";
109: //
110: // if (!(new File(nbCVSRootFile(),pathfs).exists())) {
111: // runTask(fsbuild,"test-build");
112: // }
113: // if (!(new File(nbCVSRootFile(),pathjava).exists())) {
114: // runTask(loadersBuild,"test-build-qa-functional");
115: // }
116: // }
117: // }
118:
119: public void testExternalProject() throws Exception {
120: FileObject module1build = resolveEEP("/suite4/module1/build.xml");
121: FileObject module2build = resolveEEP("/suite4/module2/build.xml");
122: runTask(module1build, "test-build");
123: checkTestExternal("module1", true);
124: runTask(module2build, "test-build");
125: checkTestExternal("module2", true);
126: runTask(module1build, "clean");
127: checkTestExternal("module1", false);
128: }
129:
130: /*
131: private void checkTest(String cnb, String cluster, String testtype, boolean exist) {
132: String path = "nbbuild/build/testdist/" + testtype + "/" + cluster + "/" + cnb + "/tests.jar";
133: FileObject testsFo = nbCVSRoot().getFileObject(path);
134: if (exist) {
135: assertTrue("test.jar for " + path + " doesn't exist.", testsFo != null && testsFo.isValid());
136: } else {
137: assertTrue("test.jar for " + path + " exists.", testsFo == null || !testsFo.isValid());
138: }
139: }
140:
141: private void deleteTests(String cnb,String cluster,String testtype) throws IOException {
142: String path = "nbbuild/build/testdist/" + testtype + "/" + cluster + "/" + cnb + "/tests.jar";
143: FileObject testsFo = nbCVSRoot().getFileObject(path);
144: if (testsFo.isValid()) {
145: // testsFo.delete();
146: }
147: }
148: */
149: private void runTask(FileObject fo, String target)
150: throws IOException {
151: ActionUtils.runTarget(fo, new String[] { target }, null)
152: .waitFinished();
153: }
154:
155: private void checkTestExternal(String cnd, boolean exist) {
156: String path = "/suite4/build/testdist/unit/cluster/" + cnd
157: + "/tests.jar";
158: File tests = resolveEEPFile(path);
159: if (exist) {
160: assertTrue("test.jar for " + path + " doesn't exist.",
161: tests.exists());
162: } else {
163: assertTrue("test.jar for " + path + " exists.", !tests
164: .exists());
165: }
166: }
167: }
|