Source Code Cross Referenced for TestKit.java in  » IDE-Netbeans » versioning » org » netbeans » test » cvsmodule » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » versioning » org.netbeans.test.cvsmodule 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.test.cvsmodule;
042:
043:        import java.io.BufferedReader;
044:        import java.io.File;
045:        import java.io.FileInputStream;
046:        import java.io.FileOutputStream;
047:        import java.io.FileReader;
048:        import java.io.IOException;
049:        import java.io.InputStream;
050:        import java.io.OutputStream;
051:        import java.util.Arrays;
052:        import javax.swing.JCheckBoxMenuItem;
053:        import org.netbeans.jellytools.EditorOperator;
054:        import org.netbeans.jellytools.MainWindowOperator;
055:        import org.netbeans.jellytools.NbDialogOperator;
056:        import org.netbeans.jellytools.NewFileNameLocationStepOperator;
057:        import org.netbeans.jellytools.NewFileWizardOperator;
058:        import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
059:        import org.netbeans.jellytools.NewProjectWizardOperator;
060:        import org.netbeans.jellytools.ProjectsTabOperator;
061:        import org.netbeans.jellytools.nodes.Node;
062:        import org.netbeans.jemmy.JemmyProperties;
063:        import org.netbeans.jemmy.QueueTool;
064:        import org.netbeans.jemmy.operators.JCheckBoxMenuItemOperator;
065:        import org.netbeans.jemmy.operators.JCheckBoxOperator;
066:        import org.netbeans.jemmy.operators.JMenuBarOperator;
067:        import org.netbeans.jemmy.operators.JMenuItemOperator;
068:        import org.netbeans.jemmy.operators.JTextFieldOperator;
069:
070:        /**
071:         * Set of utility methods.
072:         *
073:         * @author Peter Pis
074:         */
075:        public class TestKit {
076:            final static String MODIFIED_COLOR = "#0000FF";
077:            final static String NEW_COLOR = "#008000";
078:            final static String CONFLICT_COLOR = "#FF0000";
079:            final static String IGNORED_COLOR = "#999999";
080:
081:            public static File createTmpFolder(String prefix)
082:                    throws IOException {
083:                String tmpDir = System.getProperty("java.io.tmpdir"); // NOI18N
084:                File tmpFolder = new File(tmpDir);
085:                // generate unique name for tmp folder
086:                File tmp = File.createTempFile(prefix, "", tmpFolder); // NOI18N
087:                if (tmp.delete() == false) {
088:                    throw new IOException("Can not delete " + tmp);
089:                }
090:                ;
091:                if (tmp.mkdirs() == false) {
092:                    throw new IOException("Can not create " + tmp);
093:                }
094:                ;
095:                return tmp;
096:            }
097:
098:            public static void deleteRecursively(File dir) {
099:                if (dir.isDirectory()) {
100:                    String[] files = dir.list();
101:                    for (int i = 0; i < files.length; i++) {
102:                        deleteRecursively(new File(dir, files[i])); // RECURSION
103:                    }
104:                }
105:                dir.delete();
106:            }
107:
108:            public static void pseudoVersion(File file) throws Exception {
109:                File CVSdir = new File(file, "CVS");
110:                File Entries = new File(CVSdir, "Entries");
111:                OutputStream out = new FileOutputStream(Entries);
112:                String data = "D\n"
113:                        + "/Main.java/1.1/Wed Sep 14 08:51:41 2005//";
114:                out.write(data.getBytes("utf8"));
115:                out.flush();
116:                out.close();
117:                //Root
118:                File Root = new File(CVSdir, "Root");
119:                out = new FileOutputStream(Root);
120:                data = ":local:/Projects/CVSrepo";
121:                out.write(data.getBytes("utf8"));
122:                out.flush();
123:                out.close();
124:                //Repository
125:                File Repository = new File(CVSdir, "Repository");
126:                out = new FileOutputStream(Repository);
127:                data = "ForImport/src/forimport";
128:                out.write(data.getBytes("utf8"));
129:                out.flush();
130:                out.close();
131:            }
132:
133:            public static File prepareProject(String category, String project,
134:                    String project_name, String edit_file) throws Exception {
135:                //create temporary folder for test
136:                String folder = "" + System.currentTimeMillis();
137:                File file = new File("/tmp", folder); // NOI18N
138:                file.mkdirs();
139:                //PseudoVersioned project
140:                NewProjectWizardOperator npwo = NewProjectWizardOperator
141:                        .invoke();
142:                npwo.selectCategory(category);
143:                npwo.selectProject(project);
144:                npwo.next();
145:                NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator();
146:                new JTextFieldOperator(npnlso, 1).setText(file
147:                        .getAbsolutePath()); // NOI18N
148:                new JTextFieldOperator(npnlso, 0).setText(project_name); // NOI18N
149:                //new JTextFieldOperator(npnlso, 2).setText(folder); // NOI18N
150:                new NewProjectWizardOperator().finish();
151:                Node rootNode = new ProjectsTabOperator()
152:                        .getProjectRootNode(project_name);
153:                // wait classpath scanning finished
154:                return file;
155:            }
156:
157:            public static void removeAllData(String project_name) {
158:                Node rootNode = new ProjectsTabOperator()
159:                        .getProjectRootNode(project_name);
160:                rootNode.performPopupActionNoBlock("Delete Project");
161:                NbDialogOperator ndo = new NbDialogOperator("Delete");
162:                JCheckBoxOperator cb = new JCheckBoxOperator(ndo, "Also");
163:                cb.setSelected(true);
164:                ndo.yes();
165:                ndo.getTimeouts().setTimeout(
166:                        "ComponentOperator.WaitStateTimeout", 30000);
167:                ndo.waitClosed();
168:                //TestKit.deleteRecursively(file);
169:            }
170:
171:            public static void unversionProject(File file, String project_name)
172:                    throws Exception {
173:                File folder_CVS = new File(file, project_name + File.separator
174:                        + "src" + File.separator + project_name.toLowerCase()
175:                        + File.separator + "CVS");
176:                //System.out.println("File: " + file);
177:                TestKit.deleteRecursively(folder_CVS);
178:                //System.out.println("File: " + file.getAbsolutePath());
179:                EditorOperator eo = new EditorOperator("Main.java");
180:                eo.insert("//Comment\n");
181:                eo.save();
182:            }
183:
184:            public static void createNewElements(String projectName) {
185:                String pack = "xx";
186:
187:                NewFileWizardOperator nfwo = NewFileWizardOperator.invoke();
188:                nfwo.selectProject(projectName);
189:                nfwo.selectCategory("Java");
190:                nfwo.selectFileType("Java Package");
191:                nfwo.next();
192:                NewFileNameLocationStepOperator nfnlso = new NewFileNameLocationStepOperator();
193:                nfnlso.txtObjectName().clearText();
194:                nfnlso.txtObjectName().typeText(pack);
195:                nfnlso.finish();
196:                //
197:                nfwo = NewFileWizardOperator.invoke();
198:                nfwo.selectProject(projectName);
199:                nfwo.selectCategory("Java");
200:                nfwo.selectFileType("Java Class");
201:                nfwo.next();
202:                nfnlso = new NewFileNameLocationStepOperator();
203:                nfnlso.txtObjectName().clearText();
204:                nfnlso.txtObjectName().typeText("NewClass");
205:                nfnlso.selectPackage(pack);
206:                nfnlso.finish();
207:                //
208:                nfwo = NewFileWizardOperator.invoke();
209:                nfwo.selectProject(projectName);
210:                nfwo.selectCategory("Swing GUI Forms");
211:                nfwo.selectFileType("JFrame Form");
212:                nfwo.next();
213:                nfnlso = new NewFileNameLocationStepOperator();
214:                nfnlso.txtObjectName().clearText();
215:                nfnlso.txtObjectName().typeText("NewJFrame");
216:                nfnlso.selectPackage(pack);
217:                nfnlso.finish();
218:            }
219:
220:            public static void createNewElementsCommitCvs11(String projectName) {
221:                String pack = "xx";
222:
223:                NewFileWizardOperator nfwo = NewFileWizardOperator.invoke();
224:                nfwo.selectProject(projectName);
225:                nfwo.selectCategory("Java");
226:                nfwo.selectFileType("Java Package");
227:                nfwo.next();
228:                NewFileNameLocationStepOperator nfnlso = new NewFileNameLocationStepOperator();
229:                nfnlso.txtObjectName().clearText();
230:                nfnlso.txtObjectName().typeText(pack);
231:                nfnlso.finish();
232:                //
233:                nfwo = NewFileWizardOperator.invoke();
234:                nfwo.selectProject(projectName);
235:                nfwo.selectCategory("Java");
236:                nfwo.selectFileType("Java Class");
237:                nfwo.next();
238:                nfnlso = new NewFileNameLocationStepOperator();
239:                nfnlso.txtObjectName().clearText();
240:                nfnlso.txtObjectName().typeText("NewClass");
241:                nfnlso.selectPackage(pack);
242:                nfnlso.finish();
243:                //
244:                nfwo = NewFileWizardOperator.invoke();
245:                nfwo.selectProject(projectName);
246:                nfwo.selectCategory("Java");
247:                nfwo.selectFileType("Java Class");
248:                nfwo.next();
249:                nfnlso = new NewFileNameLocationStepOperator();
250:                nfnlso.txtObjectName().clearText();
251:                nfnlso.txtObjectName().typeText("NewClass2");
252:                nfnlso.selectPackage(pack);
253:                nfnlso.finish();
254:                //
255:                nfwo = NewFileWizardOperator.invoke();
256:                nfwo.selectProject(projectName);
257:                nfwo.selectCategory("Java");
258:                nfwo.selectFileType("Java Class");
259:                nfwo.next();
260:                nfnlso = new NewFileNameLocationStepOperator();
261:                nfnlso.txtObjectName().clearText();
262:                nfnlso.txtObjectName().typeText("NewClass3");
263:                nfnlso.selectPackage(pack);
264:                nfnlso.finish();
265:                //
266:                nfwo = NewFileWizardOperator.invoke();
267:                nfwo.selectProject(projectName);
268:                nfwo.selectCategory("Java");
269:                nfwo.selectFileType("Java Class");
270:                nfwo.next();
271:                nfnlso = new NewFileNameLocationStepOperator();
272:                nfnlso.txtObjectName().clearText();
273:                nfnlso.txtObjectName().typeText("NewClass4");
274:                nfnlso.selectPackage(pack);
275:                nfnlso.finish();
276:            }
277:
278:            public static void createNewElementsCommitCvs12(String projectName) {
279:                String pack = "aa";
280:
281:                NewFileWizardOperator nfwo = NewFileWizardOperator.invoke();
282:                nfwo.selectProject(projectName);
283:                nfwo.selectCategory("Java");
284:                nfwo.selectFileType("Java Package");
285:                nfwo.next();
286:                NewFileNameLocationStepOperator nfnlso = new NewFileNameLocationStepOperator();
287:                nfnlso.txtObjectName().clearText();
288:                nfnlso.txtObjectName().typeText("aa");
289:                nfnlso.finish();
290:
291:                //
292:                nfwo = NewFileWizardOperator.invoke();
293:                nfwo.selectProject(projectName);
294:                nfwo.selectCategory("Java");
295:                nfwo.selectFileType("Java Package");
296:                nfwo.next();
297:                nfnlso = new NewFileNameLocationStepOperator();
298:                nfnlso.txtObjectName().clearText();
299:                nfnlso.txtObjectName().typeText("bb");
300:                nfnlso.finish();
301:                //
302:                nfwo = NewFileWizardOperator.invoke();
303:                nfwo.selectProject(projectName);
304:                nfwo.selectCategory("Java");
305:                nfwo.selectFileType("Java Class");
306:                nfwo.next();
307:                nfnlso = new NewFileNameLocationStepOperator();
308:                nfnlso.txtObjectName().clearText();
309:                nfnlso.txtObjectName().typeText("NewClass");
310:                nfnlso.selectPackage("aa");
311:                nfnlso.finish();
312:
313:                //
314:                nfwo = NewFileWizardOperator.invoke();
315:                nfwo.selectProject(projectName);
316:                nfwo.selectCategory("Java");
317:                nfwo.selectFileType("Java Class");
318:                nfwo.next();
319:                nfnlso = new NewFileNameLocationStepOperator();
320:                nfnlso.txtObjectName().clearText();
321:                nfnlso.txtObjectName().typeText("NewClass2");
322:                nfnlso.selectPackage("aa");
323:                nfnlso.finish();
324:                //
325:                nfwo = NewFileWizardOperator.invoke();
326:                nfwo.selectProject(projectName);
327:                nfwo.selectCategory("Java");
328:                nfwo.selectFileType("Java Class");
329:                nfwo.next();
330:                nfnlso = new NewFileNameLocationStepOperator();
331:                nfnlso.txtObjectName().clearText();
332:                nfnlso.txtObjectName().typeText("NewClass");
333:                nfnlso.selectPackage("bb");
334:                nfnlso.finish();
335:                //
336:                nfwo = NewFileWizardOperator.invoke();
337:                nfwo.selectProject(projectName);
338:                nfwo.selectCategory("Java");
339:                nfwo.selectFileType("Java Class");
340:                nfwo.next();
341:                nfnlso = new NewFileNameLocationStepOperator();
342:                nfnlso.txtObjectName().clearText();
343:                nfnlso.txtObjectName().typeText("NewClass2");
344:                nfnlso.selectPackage("bb");
345:                nfnlso.finish();
346:            }
347:
348:            public static int compareThem(Object[] expected, Object[] actual,
349:                    boolean sorted) {
350:                int result = 0;
351:                if (expected == null || actual == null)
352:                    return -1;
353:                if (sorted) {
354:                    if (expected.length != actual.length) {
355:                        return -1;
356:                    }
357:                    for (int i = 0; i < expected.length; i++) {
358:                        if (((String) expected[i]).equals((String) actual[i])) {
359:                            result++;
360:                        } else {
361:                            return -1;
362:                        }
363:                    }
364:                } else {
365:                    if (expected.length > actual.length) {
366:                        return -1;
367:                    }
368:                    Arrays.sort(expected);
369:                    Arrays.sort(actual);
370:                    for (int i = 0; i < expected.length; i++) {
371:                        if (((String) expected[i]).equals((String) actual[i])) {
372:                            result++;
373:                        } else {
374:                            return -1;
375:                        }
376:                    }
377:                }
378:                return result;
379:            }
380:
381:            public static String getCVSroot(File cvsFolder) {
382:                String root = new String();
383:                if (cvsFolder.isDirectory()) {
384:                    try {
385:                        BufferedReader br = new BufferedReader(new FileReader(
386:                                cvsFolder + File.separator + "Root"));
387:                        root = br.readLine();
388:                        if (root == null || root.length() == 0)
389:                            return "";
390:                        br.close();
391:                    } catch (IOException e) {
392:                        return "";
393:                    }
394:                }
395:                return root;
396:            }
397:
398:            public static String getColor(String nodeHtmlDisplayName) {
399:
400:                if (nodeHtmlDisplayName == null
401:                        || nodeHtmlDisplayName.length() < 1)
402:                    return "";
403:                int hashPos = nodeHtmlDisplayName.indexOf('#');
404:                nodeHtmlDisplayName = nodeHtmlDisplayName.substring(hashPos);
405:                hashPos = nodeHtmlDisplayName.indexOf('"');
406:                nodeHtmlDisplayName = nodeHtmlDisplayName.substring(0, hashPos);
407:                return nodeHtmlDisplayName;
408:            }
409:
410:            public static InputStream getStream(String dir, String protocolName)
411:                    throws Exception {
412:                File file = new File(dir, protocolName);
413:                InputStream in = new FileInputStream(file);
414:                return in;
415:            }
416:
417:            public static void closeProject(String projectName) {
418:                try {
419:                    Node rootNode = new ProjectsTabOperator()
420:                            .getProjectRootNode(projectName);
421:                    rootNode.performPopupActionNoBlock("Close");
422:                    try {
423:                        Thread.sleep(2000);
424:                    } catch (InterruptedException ex) {
425:                        ex.printStackTrace();
426:                    }
427:                } catch (Exception e) {
428:
429:                }
430:            }
431:
432:            public static String getStatus(String nodeHtmlDisplayName) {
433:                if (nodeHtmlDisplayName == null
434:                        || nodeHtmlDisplayName.length() < 1)
435:                    return "";
436:                String status;
437:                int pos1 = nodeHtmlDisplayName.indexOf('[');
438:                int pos2 = nodeHtmlDisplayName.indexOf(']');
439:                if ((pos1 != -1) && (pos2 != -1))
440:                    status = nodeHtmlDisplayName.substring(pos1, pos2 + 1);
441:                else
442:                    status = "";
443:                return status;
444:            }
445:
446:            public static void showStatusLabels() {
447:                JMenuBarOperator mbo = new JMenuBarOperator(MainWindowOperator
448:                        .getDefault().getJMenuBar());
449:                JMenuItemOperator mo = mbo
450:                        .showMenuItem("View|Show Versioning Labels");
451:                JCheckBoxMenuItemOperator cbmio = new JCheckBoxMenuItemOperator(
452:                        (JCheckBoxMenuItem) mo.getSource());
453:                if (!cbmio.getState())
454:                    cbmio.push();
455:            }
456:
457:            public static void waitForQueueEmpty() {
458:                new QueueTool().waitEmpty(1000);
459:            }
460:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.