KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > freeform > ActionsWebTest


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.web.freeform;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Arrays JavaDoc;
24 import java.util.Collections JavaDoc;
25 import java.util.List JavaDoc;
26 import org.netbeans.junit.NbTestCase;
27 import org.netbeans.spi.project.ActionProvider;
28 import org.openide.modules.ModuleInfo;
29 import org.openide.util.Lookup;
30
31 // XXX testContextActions
32
// XXX testLogicalViewActions
33

34 /**
35  * Test functionality of actions in FreeformProject.
36  * This class just tests the basic functionality found in the "jakarta" project.
37  * @author Pavel Buzek
38  */

39 public class ActionsWebTest extends TestBaseWeb {
40
41     public ActionsWebTest (String JavaDoc name) {
42         super(name);
43     }
44         
45     public void testBasicActions() throws Exception JavaDoc {
46         ActionProvider ap = (ActionProvider)jakarta.getLookup().lookup(ActionProvider.class);
47         assertNotNull("have an action provider", ap);
48         List JavaDoc/*<String>*/ actionNames = new ArrayList JavaDoc(Arrays.asList(ap.getSupportedActions()));
49         Collections.sort(actionNames);
50         assertEquals("right action names", Arrays.asList(new String JavaDoc[] {"build", "clean", "compile.single", "copy", "debug", "delete", "javadoc", "move", "rebuild", "redeploy", "rename", "run", "test"}), actionNames);
51         assertTrue("clean is enabled", ap.isActionEnabled("clean", Lookup.EMPTY));
52         try {
53             ap.isActionEnabled("frobnitz", Lookup.EMPTY);
54             fail("Should throw IAE for unrecognized commands");
55         } catch (IllegalArgumentException JavaDoc e) {
56             // Good.
57
}
58         try {
59             ap.invokeAction("goetterdaemmerung", Lookup.EMPTY);
60             fail("Should throw IAE for unrecognized commands");
61         } catch (IllegalArgumentException JavaDoc e) {
62             // Good.
63
}
64         // XXX actually test running the action? how to know when it is done though? there is no API for that...
65
// when Ant logger API is available, could provide a null InputOutput impl, and test that the right messages are logged
66
}
67     
68 }
69
Popular Tags