KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > gui > javadoc > TestGenerateJavadoc


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 2003 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * TestGenerateJavadoc.java
22  *
23  * Created on February 3, 2003, 3:56 PM
24  */

25
26 package org.netbeans.test.gui.javadoc;
27
28 import java.io.File JavaDoc;
29
30 import org.netbeans.jellytools.*;
31
32 import org.netbeans.jellytools.actions.Action;
33 import org.netbeans.jellytools.actions.ActionNoBlock;
34 import org.netbeans.jellytools.actions.PropertiesAction;
35
36 import org.netbeans.jellytools.nodes.Node;
37
38 import org.netbeans.jellytools.properties.Property;
39 import org.netbeans.jellytools.properties.PropertySheetOperator;
40
41 import org.netbeans.jemmy.EventTool;
42 import org.netbeans.jemmy.JemmyProperties;
43
44 import org.netbeans.jemmy.operators.JTextFieldOperator;
45 import org.netbeans.jemmy.operators.JTreeOperator;
46
47 /** JUnit test suite with Jemmy support
48  *
49  * @author mk97936
50  * @version 1.0
51  */

52 public class TestGenerateJavadoc extends JavadocTestCase {
53     
54     public static final String JavaDoc sep = File.separator;
55     
56     /** constructor required by JUnit
57      * @param testName method name to be used as testcase
58      */

59     public TestGenerateJavadoc(String JavaDoc testName) {
60         super(testName);
61     }
62     
63     protected void setUp() {
64         new PropertiesAction().perform();
65     }
66     
67     // -------------------------------------------------------------------------
68

69    /* public void testGenerate() {
70         
71         String userHome = System.getProperty("netbeans.user"); // NOI18N
72         RepositoryTabOperator repoTabOper = RepositoryTabOperator.invoke();
73         Node topNode = new Node(repoTabOper.getRootNode(), 0);
74         
75         String sampledirPath = topNode.getPath() + sep + "org" + sep + "netbeans" + sep + "test" + sep + // NOI18N
76                                "gui" + sep + "javadoc" + sep + "data" + sep + "sampledir"; // NOI18N
77         
78         repoTabOper.mountLocalDirectoryAPI(sampledirPath); // NOI18N
79         
80         JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 120000); // NOI18N
81         Action generateJDoc = new Action(toolsMainMenuItem + "|" + generateMenuItem, // NOI18N
82                                          toolsPopupMenuItem + "|" + generateMenuItem); // NOI18N
83         
84         // javadoc is generated to default location ${netbeans.user}/javadoc
85         
86         // generate for MemoryView.java
87         Node memoryViewNode = new Node(new Node(repoTabOper.getRootNode(), sampledirPath),
88                                        "examples|imageviewer|ImageViewer"); // NOI18N
89         generateJDoc.perform(memoryViewNode);
90         
91         // question about showing javadoc in browser
92         NbDialogOperator questionDialogOper = new NbDialogOperator(questionWinTitle);
93         questionDialogOper.no();
94         
95         verifyCommonJdocFiles(userHome, "javadoc");
96         assertTrue("ImageViewer doesn't exist!", new File(userHome + sep + "javadoc" + sep + "examples" + sep + // NOI18N
97                    "imageviewer" + sep + "ImageViewer.html").exists()); // NOI18N
98         new EventTool().waitNoEvent(1000);
99         
100         // generate for colorpicker package
101         Node colorPickerNode = new Node(new Node(repoTabOper.getRootNode(), sampledirPath), "examples|colorpicker"); // NOI18N
102         generateJDoc.perform(colorPickerNode);
103         
104         // question about showing javadoc in browser
105         NbDialogOperator questionDialogOper_2 = new NbDialogOperator(questionWinTitle);
106         questionDialogOper_2.no();
107         
108         verifyCommonJdocFiles(userHome, "javadoc");
109         assertTrue("ColorPicker doesn't exist!", new File(userHome + sep + "javadoc" + sep + "examples" + sep + // NOI18N
110                    "colorpicker" + sep + "ColorPicker.html").exists()); // NOI18N
111         new EventTool().waitNoEvent(1000);
112         
113         // generate for examples package
114         Node examplesNode = new Node(new Node(repoTabOper.getRootNode(), sampledirPath), "examples"); // NOI18N
115         generateJDoc.perform(examplesNode);
116         
117         // question about showing javadoc in browser
118         NbDialogOperator questionDialogOper_3 = new NbDialogOperator(questionWinTitle);
119         questionDialogOper_3.no();
120         
121         verifyCommonJdocFiles(userHome, "javadoc");
122 // verifyCommonJdocFilesInFolder(userHome, "javadoc" + sep + "examples" + sep + "clock");
123         verifyCommonJdocFilesInFolder(userHome, "javadoc" + sep + "examples" + sep + "imageviewer");
124 // verifyCommonJdocFilesInFolder(userHome, "javadoc" + sep + "examples" + sep + "advanced");
125         verifyCommonJdocFilesInFolder(userHome, "javadoc" + sep + "examples" + sep + "texteditor");
126         verifyCommonJdocFilesInFolder(userHome, "javadoc" + sep + "examples" + sep + "colorpicker");
127         
128 // assertTrue("ClockFrame doesn't exist!", new File(userHome + sep + "javadoc" + sep + "examples" + sep + // NOI18N
129 // "clock" + sep + "ClockFrame.html").exists()); // NOI18N
130         assertTrue("ImageFrame doesn't exist!", new File(userHome + sep + "javadoc" + sep + "examples" + sep + // NOI18N
131                    "imageviewer" + sep + "ImageFrame.html").exists()); // NOI18N
132         assertTrue("ImageViewer doesn't exist!", new File(userHome + sep + "javadoc" + sep + "examples" + sep + // NOI18N
133                    "imageviewer" + sep + "ImageViewer.html").exists()); // NOI18N
134 // assertTrue("MemoryView doesn't exist!", new File(userHome + sep + "javadoc" + sep + "examples" + sep + // NOI18N
135 // "advanced" + sep + "MemoryView.html").exists()); // NOI18N
136         assertTrue("Ted doesn't exist!", new File(userHome + sep + "javadoc" + sep + "examples" + sep + // NOI18N
137                    "texteditor" + sep + "Ted.html").exists()); // NOI18N
138         assertTrue("About doesn't exist!", new File(userHome + sep + "javadoc" + sep + "examples" + sep + // NOI18N
139                    "texteditor" + sep + "About.html").exists()); // NOI18N
140         assertTrue("Finder doesn't exist!", new File(userHome + sep + "javadoc" + sep + "examples" + sep + // NOI18N
141                    "texteditor" + sep + "Finder.html").exists()); // NOI18N
142         assertTrue("ColorPicker doesn't exist!", new File(userHome + sep + "javadoc" + sep + "examples" + sep + // NOI18N
143                    "colorpicker" + sep + "ColorPicker.html").exists()); // NOI18N
144         new EventTool().waitNoEvent(1000);
145         
146     }*/

147     
148     private void verifyCommonJdocFiles(String JavaDoc base, String JavaDoc folder) {
149         assertTrue("index.html doesn't exist!", new File JavaDoc(base + sep + folder + sep + "index.html").exists()); // NOI18N
150
assertTrue("index-all.html doesn't exist!", new File JavaDoc(base + sep + folder + sep + "index-all.html").exists()); // NOI18N
151
assertTrue("allclasses-frame.html doesn't exist!", new File JavaDoc(base + sep + folder + sep + "allclasses-frame.html").exists()); // NOI18N
152
assertTrue("allclasses-noframe.html doesn't exist!", new File JavaDoc(base + sep + folder + sep + "allclasses-noframe.html").exists()); // NOI18N
153
assertTrue("packages.html doesn't exist!", new File JavaDoc(base + sep + folder + sep + "packages.html").exists()); // NOI18N
154
assertTrue("stylesheet.css doesn't exist!", new File JavaDoc(base + sep + folder + sep + "stylesheet.css").exists()); // NOI18N
155
assertTrue("package-list doesn't exist!", new File JavaDoc(base + sep + folder + sep + "package-list").exists()); // NOI18N
156
assertTrue("help-doc.html doesn't exist!", new File JavaDoc(base + sep + folder + sep + "help-doc.html").exists()); // NOI18N
157
assertTrue("overview-tree.html doesn't exist!", new File JavaDoc(base + sep + folder + sep + "overview-tree.html").exists()); // NOI18N
158
}
159     
160     private void verifyCommonJdocFilesInFolder(String JavaDoc base, String JavaDoc folder) {
161         assertTrue("package-frame.html doesn't exist!", new File JavaDoc(base + sep + folder + sep + "package-frame.html").exists()); // NOI18N
162
assertTrue("package-summary.html doesn't exist!", new File JavaDoc(base + sep + folder + sep + "package-summary.html").exists()); // NOI18N
163
assertTrue("package-tree.html doesn't exist!", new File JavaDoc(base + sep + folder + sep + "package-tree.html").exists()); // NOI18N
164
}
165     
166   /* public void testGenerateToFolder() {
167         
168         String userHome = System.getProperty("netbeans.user"); // NOI18N
169         RepositoryTabOperator repoTabOper = RepositoryTabOperator.invoke();
170         Node topNode = new Node(repoTabOper.getRootNode(), 0);
171         
172         String sampledirPath = topNode.getPath() + sep + "org" + sep + "netbeans" + sep + "test" + sep + // NOI18N
173                                "gui" + sep + "javadoc" + sep + "data" + sep + "sampledir"; // NOI18N
174         
175         repoTabOper.mountLocalDirectoryAPI(sampledirPath); // NOI18N
176         Action generateJDoc = new Action(toolsMainMenuItem + "|" + generateMenuItem, // NOI18N
177                                          toolsPopupMenuItem + "|" + generateMenuItem); // NOI18N
178         
179         // set property "Ask for Destination Directory" to true
180         OptionsOperator optionsOper = OptionsOperator.invoke();
181         optionsOper.selectOption("Code Documentation|Documentation");
182         PropertySheetOperator propertiesTab = new PropertySheetOperator(optionsOper);
183         Property askForDestProp = new Property(propertiesTab, "Ask for Destination Directory");
184         askForDestProp.setValue("true");
185         optionsOper.close();
186         // -----
187         
188         Node imageviewerNode = new Node(new Node(repoTabOper.getRootNode(), sampledirPath), "examples|imageviewer"); // NOI18N
189         generateJDoc.perform(imageviewerNode);
190         
191         NbDialogOperator dialogOper = new NbDialogOperator("Javadoc Destination Directory");
192         JTextFieldOperator textOper = new JTextFieldOperator(dialogOper);
193         textOper.clearText();
194         textOper.typeText(userHome + sep + "javadoc_1");
195         dialogOper.ok();
196         
197         // question about creating non existing folder
198         NbDialogOperator questionDialogOper = new NbDialogOperator(questionWinTitle);
199         questionDialogOper.ok();
200         
201         // question about showing javadoc in browser
202         NbDialogOperator questionDialogOper_2 = new NbDialogOperator(questionWinTitle);
203         questionDialogOper_2.no();
204         
205         verifyCommonJdocFiles(userHome, "javadoc_1");
206         assertTrue("ImageViewer doesn't exist!", new File(userHome + sep + "javadoc_1" + sep + "examples" + sep + // NOI18N
207                    "imageviewer" + sep + "ImageViewer.html").exists()); // NOI18N
208         new EventTool().waitNoEvent(1000);
209         
210     }*/

211     
212     public void testCreateDoclet() {
213         
214         String JavaDoc [] docletSettings = new String JavaDoc [] {"Author", "Bottom", "Charset", "Doc Title", "Footer", "Group",
215             "Header", "Help File", "Link", "Linkoffline", "No Deprecated", "No Deprecated List", "No Help", "No Index",
216             "No Navbar", "No Tree", "Split Index", "Style Sheet File", "Use", "Version", "Window Title"};
217         String JavaDoc [] docletValues = new String JavaDoc [] {"false", "", "", "", "", "", "", "", "", "", "false", "false", "false",
218             "false", "false", "false", "false", "", "false", "false", ""};
219         
220         // create new doclet with name TestDoclet
221
OptionsOperator optionsOper = OptionsOperator.invoke();
222         JTreeOperator optionsTreeOper = optionsOper.treeTable().tree();
223         Node node = new Node(optionsTreeOper, "Code Documentation|Doclets");
224         ActionNoBlock newAction = new ActionNoBlock(null, "New|Standard Doclet");
225         newAction.perform(node);
226         WizardOperator newWizard = new WizardOperator("New Wizard - Standard Doclet");
227         JTextFieldOperator nameOper = new JTextFieldOperator(newWizard);
228         nameOper.typeText("TestDoclet");
229         newWizard.finish();
230         
231         // test default doclet values
232
optionsOper.selectOption("Code Documentation|Doclets|TestDoclet");
233         PropertySheetOperator propertiesTab = new PropertySheetOperator(optionsOper);
234         for (int i = 0; i < docletSettings.length; i++) {
235             Property docletProp = new Property(propertiesTab, docletSettings[i]);
236             assertTrue("Default value of " + docletSettings[i] + " is not " + docletValues[i],
237                        docletProp.getValue().indexOf(docletValues[i]) != -1);
238         }
239         
240         optionsOper.close();
241         
242     }
243 //
244
public void testCreateExecutor() {
245         
246         // Doclets setting excluded
247
String JavaDoc [] execSettings = new String JavaDoc [] {"1.1 style", "Enable JDK 1.4 source", "Encoding",
248             "Extdirs", "External Process", "Locale", "Members", "Overview", "Recursive", "Verbose"};
249         String JavaDoc [] execValues = new String JavaDoc [] {"false", "false", "", "", "External Javadoc Executor",
250             "", "protected", "", "true", "false"};
251         
252         OptionsOperator optionsOper = OptionsOperator.invoke();
253         JTreeOperator optionsTreeOper = optionsOper.treeTable().tree();
254         Node node = new Node(optionsTreeOper, "Code Documentation|Javadoc Executors");
255         ActionNoBlock newAction = new ActionNoBlock(null, "New|External Javadoc");
256         newAction.perform(node);
257         WizardOperator newWizard = new WizardOperator("New Wizard - External Javadoc");
258         JTextFieldOperator nameOper = new JTextFieldOperator(newWizard);
259         nameOper.typeText("TestExecutor");
260         newWizard.finish();
261         
262         // test default executor values
263
optionsOper.selectOption("Code Documentation|Javadoc Executors|TestExecutor");
264         PropertySheetOperator propertiesTab = new PropertySheetOperator(optionsOper);
265         for (int i = 0; i < execSettings.length; i++) {
266             Property execProp = new Property(propertiesTab, execSettings[i]);
267             assertTrue("Default value of " + execSettings[i] + " is not " + execValues[i],
268                        execProp.getValue().indexOf(execValues[i]) != -1);
269         }
270         
271         optionsOper.close();
272     }
273     
274 // private static final String toolsPopupMenuItem = Bundle.getStringTrimmed("org.openide.actions.Bundle", "CTL_Tools");
275
// private static final String toolsMainMenuItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools");
276
// private static final String generateMenuItem = Bundle.getStringTrimmed("org.netbeans.modules.javadoc.Bundle", "CTL_ActionGenerate");
277
// private static final String questionWinTitle = Bundle.getStringTrimmed("org.openide.Bundle", "NTF_QuestionTitle");
278

279 }
280
Popular Tags