KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > suite > BuildNBMSTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.project.suite;
21
22 import java.io.File JavaDoc;
23 import java.util.Arrays JavaDoc;
24 import java.util.List JavaDoc;
25 import java.util.logging.Level JavaDoc;
26 import org.netbeans.modules.apisupport.project.DialogDisplayerImpl;
27 import org.netbeans.modules.apisupport.project.InstalledFileLocatorImpl;
28 import org.netbeans.modules.apisupport.project.NbModuleProject;
29 import org.netbeans.modules.apisupport.project.TestBase;
30 import org.netbeans.modules.apisupport.project.layers.LayerTestBase;
31 import org.netbeans.modules.apisupport.project.ui.SuiteActions;
32 import org.netbeans.spi.project.ActionProvider;
33 import org.openide.DialogDescriptor;
34 import org.openide.execution.ExecutorTask;
35 import org.openide.filesystems.FileObject;
36
37 /**
38  * Checks building of NBM files.
39  * @author Petr Zajac
40  */

41 public class BuildNBMSTest extends TestBase {
42     
43     static {
44         // #65461: do not try to load ModuleInfo instances from ant module
45
System.setProperty("org.netbeans.core.startup.ModuleSystem.CULPRIT", "true");
46         LayerTestBase.Lkp.setLookup(new Object JavaDoc[0]);
47     }
48     
49     private SuiteProject suite;
50     
51     public BuildNBMSTest(String JavaDoc name) {
52         super(name);
53     }
54
55     @Override JavaDoc
56     protected Level JavaDoc logLevel() {
57         return Level.FINE;
58     }
59     
60     protected void setUp() throws Exception JavaDoc {
61         clearWorkDir();
62         
63         super.setUp();
64
65         InstalledFileLocatorImpl.registerDestDir(destDirF);
66         
67         suite = TestBase.generateSuite(new File JavaDoc(getWorkDir(), "projects"), "suite");
68         NbModuleProject proj = TestBase.generateSuiteComponent(suite, "mod1");
69         
70         SuiteProjectTest.openSuite(suite);
71         proj.open();
72     }
73     
74     public void testBuildNBMS() throws Exception JavaDoc {
75         SuiteActions p = (SuiteActions) suite.getLookup().lookup(ActionProvider.class);
76         assertNotNull("Provider is here", p);
77         
78         List JavaDoc l = Arrays.asList(p.getSupportedActions());
79         assertTrue("We support nbms: " + l, l.contains("nbms"));
80         
81         DialogDisplayerImpl.returnFromNotify(DialogDescriptor.NO_OPTION);
82         ExecutorTask task = p.invokeActionImpl("nbms", suite.getLookup());
83         assertNotNull("did not even run task", task);
84         task.waitFinished();
85         FileObject nbmFo = suite.getProjectDirectory().getFileObject("build/updates/org-example-mod1.nbm");
86         FileObject updatesXml = suite.getProjectDirectory().getFileObject("build/updates/updates.xml");
87         assertNotNull("Nbm build/updates/org-example-mod1.nbm doesn't exist",nbmFo);
88         assertNotNull("build/updates/updates.xml doesn't exist",updatesXml);
89     }
90     
91 }
92
93     
Popular Tags