Source Code Cross Referenced for ExportDiffPatchTest.java in  » IDE-Netbeans » subversion » org » netbeans » test » subversion » main » diff » 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 » subversion » org.netbeans.test.subversion.main.diff 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ExportDiffPatchTest.java
003:         *
004:         * Created on Piatok, 2006, september 15, 10:49
005:         *
006:         * To change this template, choose Tools | Template Manager
007:         * and open the template in the editor.
008:         */
009:
010:        package org.netbeans.test.subversion.main.diff;
011:
012:        import java.io.BufferedReader;
013:        import java.io.File;
014:        import java.io.FileReader;
015:        import java.io.PrintStream;
016:        import org.netbeans.jellytools.JellyTestCase;
017:        import org.netbeans.junit.NbTestSuite;
018:        import junit.textui.TestRunner;
019:        import org.netbeans.jellytools.EditorOperator;
020:        import org.netbeans.jellytools.NbDialogOperator;
021:        import org.netbeans.jellytools.OutputTabOperator;
022:        import org.netbeans.jellytools.ProjectsTabOperator;
023:        import org.netbeans.jellytools.nodes.Node;
024:        import org.netbeans.jellytools.nodes.SourcePackagesNode;
025:        import org.netbeans.jemmy.operators.JButtonOperator;
026:        import org.netbeans.jemmy.operators.JTextFieldOperator;
027:        import org.netbeans.jemmy.operators.Operator;
028:        import org.netbeans.jemmy.operators.Operator.DefaultStringComparator;
029:        import org.netbeans.test.subversion.operators.CheckoutWizardOperator;
030:        import org.netbeans.test.subversion.operators.RepositoryStepOperator;
031:        import org.netbeans.test.subversion.operators.VersioningOperator;
032:        import org.netbeans.test.subversion.operators.WorkDirStepOperator;
033:        import org.netbeans.test.subversion.utils.RepositoryMaintenance;
034:        import org.netbeans.test.subversion.utils.TestKit;
035:
036:        /**
037:         *
038:         * @author pvcs
039:         */
040:        public class ExportDiffPatchTest extends JellyTestCase {
041:
042:            public static final String TMP_PATH = "/tmp";
043:            public static final String REPO_PATH = "repo";
044:            public static final String WORK_PATH = "work";
045:            public static final String PROJECT_NAME = "JavaApp";
046:            public File projectPath;
047:            public PrintStream stream;
048:            String os_name;
049:            Operator.DefaultStringComparator comOperator;
050:            Operator.DefaultStringComparator oldOperator;
051:
052:            /** Creates a new instance of ExportDiffPatchTest */
053:            public ExportDiffPatchTest(String name) {
054:                super (name);
055:            }
056:
057:            protected void setUp() throws Exception {
058:                os_name = System.getProperty("os.name");
059:                //System.out.println(os_name);
060:                System.out.println("### " + getName() + " ###");
061:
062:            }
063:
064:            protected boolean isUnix() {
065:                boolean unix = false;
066:                if (os_name.indexOf("Windows") == -1) {
067:                    unix = true;
068:                }
069:                return unix;
070:            }
071:
072:            public static void main(String[] args) {
073:                // TODO code application logic here
074:                TestRunner.run(suite());
075:            }
076:
077:            public static NbTestSuite suite() {
078:                NbTestSuite suite = new NbTestSuite();
079:                suite.addTest(new ExportDiffPatchTest("invokeExportDiffPatch"));
080:                return suite;
081:            }
082:
083:            public void invokeExportDiffPatch() throws Exception {
084:                //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000);
085:                //JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 30000);    
086:                try {
087:                    TestKit.closeProject(PROJECT_NAME);
088:
089:                    stream = new PrintStream(new File(getWorkDir(), getName()
090:                            + ".log"));
091:                    VersioningOperator vo = VersioningOperator.invoke();
092:                    CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
093:                    RepositoryStepOperator rso = new RepositoryStepOperator();
094:
095:                    //create repository...
096:                    File work = new File(TMP_PATH + File.separator + WORK_PATH
097:                            + File.separator + "w" + System.currentTimeMillis());
098:                    new File(TMP_PATH).mkdirs();
099:                    work.mkdirs();
100:                    RepositoryMaintenance.deleteFolder(new File(TMP_PATH
101:                            + File.separator + REPO_PATH));
102:                    //RepositoryMaintenance.deleteFolder(new File(TMP_PATH + File.separator + WORK_PATH));
103:                    RepositoryMaintenance.createRepository(TMP_PATH
104:                            + File.separator + REPO_PATH);
105:                    RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH
106:                            + File.separator + REPO_PATH, getDataDir()
107:                            .getCanonicalPath()
108:                            + File.separator + "repo_dump");
109:                    rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE
110:                            + RepositoryMaintenance.changeFileSeparator(
111:                                    TMP_PATH + File.separator + REPO_PATH,
112:                                    false));
113:
114:                    rso.next();
115:                    WorkDirStepOperator wdso = new WorkDirStepOperator();
116:                    wdso.setRepositoryFolder("trunk/" + PROJECT_NAME);
117:                    wdso.setLocalFolder(work.getCanonicalPath());
118:                    wdso.checkCheckoutContentOnly(false);
119:                    wdso.finish();
120:                    //open project
121:                    OutputTabOperator oto = new OutputTabOperator(
122:                            "file:///tmp/repo");
123:                    oto.getTimeouts().setTimeout(
124:                            "ComponentOperator.WaitStateTimeout", 30000);
125:                    //            oto.clear();            
126:                    oto.waitText("Checking out... finished.");
127:                    NbDialogOperator nbdialog = new NbDialogOperator(
128:                            "Checkout Completed");
129:                    JButtonOperator open = new JButtonOperator(nbdialog,
130:                            "Open Project");
131:                    open.push();
132:
133:                    TestKit.waitForScanFinishedAndQueueEmpty();
134:
135:                    //modify, save file and invoke Diff
136:                    oto = new OutputTabOperator("file:///tmp/repo");
137:                    oto.getTimeouts().setTimeout(
138:                            "ComponentOperator.WaitStateTimeout", 30000);
139:                    oto.clear();
140:                    Node node = new Node(new SourcePackagesNode(PROJECT_NAME),
141:                            "javaapp|Main.java");
142:                    node.performPopupAction("Open");
143:                    EditorOperator eo = new EditorOperator("Main.java");
144:                    eo.deleteLine(2);
145:                    eo.insert(" insert", 5, 1);
146:                    eo.insert("\tSystem.out.println(\"\");\n", 19, 1);
147:                    eo.save();
148:                    node.performPopupAction("Subversion|Show Changes");
149:                    Thread.sleep(1000);
150:                    vo = VersioningOperator.invoke();
151:                    //Save action should change the file annotations
152:                    org.openide.nodes.Node nodeIDE = (org.openide.nodes.Node) node
153:                            .getOpenideNode();
154:                    String color = TestKit.getColor(nodeIDE
155:                            .getHtmlDisplayName());
156:                    String status = TestKit.getStatus(nodeIDE
157:                            .getHtmlDisplayName());
158:                    assertEquals(
159:                            "Wrong color of node - file color should be new!!!",
160:                            TestKit.MODIFIED_COLOR, color);
161:                    assertEquals(
162:                            "Wrong annotation of node - file status should be new!!!",
163:                            TestKit.MODIFIED_STATUS, status);
164:                    assertEquals(
165:                            "Wrong number of records in Versioning view!!!", 1,
166:                            vo.tabFiles().getRowCount());
167:
168:                    //new ProjectsTabOperator().tree().clearSelection();
169:                    node = new Node(new ProjectsTabOperator().tree(),
170:                            PROJECT_NAME);
171:                    comOperator = new Operator.DefaultStringComparator(true,
172:                            true);
173:                    oldOperator = (DefaultStringComparator) Operator
174:                            .getDefaultStringComparator();
175:                    Operator.setDefaultStringComparator(comOperator);
176:                    node
177:                            .performMenuActionNoBlock("Versioning|Export Diff Patch...");
178:                    Operator.setDefaultStringComparator(oldOperator);
179:
180:                    //node.select();
181:
182:                    nbdialog = new NbDialogOperator("Export");
183:                    JButtonOperator btn = new JButtonOperator(nbdialog,
184:                            "Export");
185:                    JTextFieldOperator tf = new JTextFieldOperator(nbdialog, 0);
186:                    String patchFile = "/tmp/patch"
187:                            + System.currentTimeMillis() + ".patch";
188:                    File file = new File(patchFile);
189:                    tf.setText(file.getCanonicalFile().toString());
190:                    oto = new OutputTabOperator("file:///tmp/repo");
191:                    oto.getTimeouts().setTimeout(
192:                            "ComponentOperator.WaitStateTimeout", 30000);
193:                    oto.clear();
194:                    btn.push();
195:                    oto.waitText("Diff Patch finished");
196:
197:                    BufferedReader br = new BufferedReader(new FileReader(file));
198:                    String line = br.readLine();
199:                    boolean generated = false;
200:                    if (line != null) {
201:                        generated = line
202:                                .indexOf("# This patch file was generated by NetBeans IDE") != -1 ? true
203:                                : false;
204:                    }
205:
206:                    br.close();
207:                    assertTrue("Diff Patch file is empty!", generated);
208:                    System.setProperty("netbeans.t9y.cvs.connection.CVSROOT",
209:                            "");
210:                    stream.flush();
211:                    stream.close();
212:
213:                } catch (Exception e) {
214:                    throw new Exception("Test failed: " + e);
215:                } finally {
216:                    TestKit.closeProject(PROJECT_NAME);
217:                }
218:            }
219:
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.