1 9 10 package org.netbeans.test.subversion.main.diff; 11 12 import java.io.File ; 13 import java.io.PrintStream ; 14 import junit.textui.TestRunner; 15 import org.netbeans.jellytools.EditorOperator; 16 import org.netbeans.jellytools.JellyTestCase; 17 import org.netbeans.jellytools.NbDialogOperator; 18 import org.netbeans.jellytools.OutputTabOperator; 19 import org.netbeans.jellytools.nodes.Node; 20 import org.netbeans.jellytools.nodes.SourcePackagesNode; 21 import org.netbeans.jemmy.JemmyProperties; 22 import org.netbeans.jemmy.QueueTool; 23 import org.netbeans.jemmy.TimeoutExpiredException; 24 import org.netbeans.jemmy.operators.JButtonOperator; 25 import org.netbeans.junit.NbTestSuite; 26 import org.netbeans.test.subversion.operators.CheckoutWizardOperator; 27 import org.netbeans.test.subversion.operators.RepositoryStepOperator; 28 import org.netbeans.test.subversion.operators.VersioningOperator; 29 import org.netbeans.test.subversion.operators.WorkDirStepOperator; 30 import org.netbeans.test.subversion.utils.RepositoryMaintenance; 31 import org.netbeans.test.subversion.utils.TestKit; 32 import org.netbeans.junit.ide.ProjectSupport; 33 import org.netbeans.test.subversion.operators.DiffOperator; 34 35 39 public class DiffTest extends JellyTestCase { 40 41 public static final String TMP_PATH = "/tmp"; 42 public static final String REPO_PATH = "repo"; 43 public static final String WORK_PATH = "work"; 44 public static final String PROJECT_NAME = "JavaApp"; 45 public File projectPath; 46 public PrintStream stream; 47 String os_name; 48 49 50 public DiffTest(String name) { 51 super(name); 52 } 53 54 protected void setUp() throws Exception { 55 os_name = System.getProperty("os.name"); 56 System.out.println("### "+getName()+" ###"); 58 59 } 60 61 protected boolean isUnix() { 62 boolean unix = false; 63 if (os_name.indexOf("Windows") == -1) { 64 unix = true; 65 } 66 return unix; 67 } 68 69 public static void main(String [] args) { 70 TestRunner.run(suite()); 72 } 73 74 public static NbTestSuite suite() { 75 NbTestSuite suite = new NbTestSuite(); 76 suite.addTest(new DiffTest("testDiffFile")); 77 return suite; 78 } 79 80 public void testDiffFile() throws Exception { 81 try { 84 TestKit.closeProject(PROJECT_NAME); 85 86 stream = new PrintStream (new File (getWorkDir(), getName() + ".log")); 87 VersioningOperator vo = VersioningOperator.invoke(); 88 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 89 RepositoryStepOperator rso = new RepositoryStepOperator(); 90 91 File work = new File (TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis()); 93 new File (TMP_PATH).mkdirs(); 94 work.mkdirs(); 95 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 96 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 98 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 99 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 100 101 rso.next(); 102 WorkDirStepOperator wdso = new WorkDirStepOperator(); 103 wdso.setRepositoryFolder("trunk/" + PROJECT_NAME); 104 wdso.setLocalFolder(work.getCanonicalPath()); 105 wdso.checkCheckoutContentOnly(false); 106 OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo"); 107 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 108 oto.clear(); 109 wdso.finish(); 110 oto.waitText("Checking out... finished."); 112 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 113 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 114 open.push(); 115 116 ProjectSupport.waitScanFinished(); 117 new QueueTool().waitEmpty(1000); 118 ProjectSupport.waitScanFinished(); 119 120 oto = new OutputTabOperator("file:///tmp/repo"); 122 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 123 oto.clear(); 124 Node node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|Main.java"); 125 node.performPopupAction("Open"); 126 EditorOperator eo = new EditorOperator("Main.java"); 127 eo.deleteLine(2); 128 eo.insert(" insert", 5, 1); 129 eo.insert("\tSystem.out.println(\"\");\n", 19, 1); 130 eo.save(); 131 node.performPopupAction("Subversion|Show Changes"); 132 Thread.sleep(1000); 133 vo = VersioningOperator.invoke(); 134 org.openide.nodes.Node nodeIDE = (org.openide.nodes.Node) node.getOpenideNode(); 136 String color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 137 String status = TestKit.getStatus(nodeIDE.getHtmlDisplayName()); 138 assertEquals("Wrong color of node - file color should be new!!!", TestKit.MODIFIED_COLOR, color); 139 assertEquals("Wrong annotation of node - file status should be new!!!", TestKit.MODIFIED_STATUS, status); 140 assertEquals("Wrong number of records in Versioning view!!!", 1, vo.tabFiles().getRowCount()); 141 142 node.performPopupAction("Subversion|Diff"); 143 System.out.println("DIFF action doesn't print information into OUTPUT!!!"); 144 Thread.sleep(2000); 146 147 DiffOperator diffOp = new DiffOperator("Main.java"); 148 try { 150 TimeoutExpiredException afee = null; 151 diffOp.next(); 152 diffOp.next(); 153 try { 154 diffOp.next(); 155 } catch (TimeoutExpiredException e) { 156 afee = e; 157 } 158 assertNotNull("TimeoutExpiredException was expected.", afee); 159 160 afee = null; 162 diffOp.previous(); 163 diffOp.previous(); 164 try { 165 diffOp.previous(); 166 } catch (TimeoutExpiredException e) { 167 afee = e; 168 } 169 assertNotNull("TimeoutExpiredException was expected.", afee); 170 } catch (Exception e) { 171 System.out.println("Problem with buttons of differences"); 172 } 173 174 stream.flush(); 176 stream.close(); 177 178 } catch (Exception e) { 179 throw new Exception ("Test failed: " + e); 180 } finally { 181 TestKit.closeProject(PROJECT_NAME); 182 } 183 } 184 } 185 | Popular Tags |