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:
042: package org.netbeans.modules.apisupport.project.suite;
043:
044: import java.io.File;
045: import java.util.Arrays;
046: import java.util.List;
047: import java.util.logging.Level;
048: import org.netbeans.modules.apisupport.project.DialogDisplayerImpl;
049: import org.netbeans.modules.apisupport.project.InstalledFileLocatorImpl;
050: import org.netbeans.modules.apisupport.project.NbModuleProject;
051: import org.netbeans.modules.apisupport.project.TestBase;
052: import org.netbeans.modules.apisupport.project.layers.LayerTestBase;
053: import org.netbeans.modules.apisupport.project.ui.SuiteActions;
054: import org.netbeans.spi.project.ActionProvider;
055: import org.openide.DialogDescriptor;
056: import org.openide.execution.ExecutorTask;
057: import org.openide.filesystems.FileObject;
058: import org.openide.util.Utilities;
059:
060: /**
061: * Checks building of NBM files.
062: * @author Petr Zajac
063: */
064: public class BuildNBMSTest extends TestBase {
065:
066: static {
067: // #65461: do not try to load ModuleInfo instances from ant module
068: System.setProperty(
069: "org.netbeans.core.startup.ModuleSystem.CULPRIT",
070: "true");
071: LayerTestBase.Lkp.setLookup(new Object[0]);
072: }
073:
074: public @Override
075: boolean canRun() {
076: return super .canRun() && !Utilities.isWindows(); // #107995: path name too long
077: }
078:
079: private SuiteProject suite;
080:
081: public BuildNBMSTest(String name) {
082: super (name);
083: }
084:
085: @Override
086: protected Level logLevel() {
087: return Level.FINE;
088: }
089:
090: protected @Override
091: void setUp() throws Exception {
092: clearWorkDir();
093:
094: super .setUp();
095:
096: InstalledFileLocatorImpl.registerDestDir(destDirF);
097:
098: suite = TestBase.generateSuite(new File(getWorkDir(),
099: "projects"), "suite");
100: NbModuleProject proj = TestBase.generateSuiteComponent(suite,
101: "mod1");
102:
103: suite.open();
104: proj.open();
105: }
106:
107: public void testBuildNBMS() throws Exception {
108: SuiteActions p = (SuiteActions) suite.getLookup().lookup(
109: ActionProvider.class);
110: assertNotNull("Provider is here", p);
111:
112: List l = Arrays.asList(p.getSupportedActions());
113: assertTrue("We support nbms: " + l, l.contains("nbms"));
114:
115: DialogDisplayerImpl
116: .returnFromNotify(DialogDescriptor.NO_OPTION);
117: ExecutorTask task = p.invokeActionImpl("nbms", suite
118: .getLookup());
119: assertNotNull("did not even run task", task);
120: task.waitFinished();
121: FileObject nbmFo = suite.getProjectDirectory().getFileObject(
122: "build/updates/org-example-mod1.nbm");
123: FileObject updatesXml = suite.getProjectDirectory()
124: .getFileObject("build/updates/updates.xml");
125: assertNotNull(
126: "Nbm build/updates/org-example-mod1.nbm doesn't exist",
127: nbmFo);
128: assertNotNull("build/updates/updates.xml doesn't exist",
129: updatesXml);
130: }
131:
132: }
|