1 9 10 package org.netbeans.test.subversion.main.branches; 11 12 import java.io.File ; 13 import junit.textui.TestRunner; 14 import org.netbeans.jellytools.JellyTestCase; 15 import org.netbeans.jellytools.ProjectsTabOperator; 16 import org.netbeans.jellytools.nodes.Node; 17 import org.netbeans.jemmy.JemmyProperties; 18 import org.netbeans.jemmy.TimeoutExpiredException; 19 import org.netbeans.junit.NbTestSuite; 20 import org.netbeans.test.subversion.operators.CommitStepOperator; 21 import org.netbeans.test.subversion.operators.FolderToImportStepOperator; 22 import org.netbeans.test.subversion.operators.ImportWizardOperator; 23 import org.netbeans.test.subversion.operators.RepositoryStepOperator; 24 import org.netbeans.test.subversion.operators.RevertModificationsOperator; 25 import org.netbeans.test.subversion.utils.RepositoryMaintenance; 26 import org.netbeans.test.subversion.utils.TestKit; 27 28 32 public class RevertUiTest extends JellyTestCase{ 33 34 public static final String TMP_PATH = "/tmp"; 35 public static final String REPO_PATH = "repo"; 36 public static final String WORK_PATH = "work"; 37 public static final String PROJECT_NAME = "SVNApplication"; 38 public File projectPath; 39 40 String os_name; 41 42 43 public RevertUiTest(String name) { 44 super(name); 45 } 46 47 protected void setUp() throws Exception { 48 os_name = System.getProperty("os.name"); 49 System.out.println("### "+getName()+" ###"); 51 52 } 53 54 protected boolean isUnix() { 55 boolean unix = false; 56 if (os_name.indexOf("Windows") == -1) { 57 unix = true; 58 } 59 return unix; 60 } 61 62 public static void main(String [] args) { 63 TestRunner.run(suite()); 65 } 66 67 public static NbTestSuite suite() { 68 NbTestSuite suite = new NbTestSuite(); 69 suite.addTest(new RevertUiTest("testInvokeCloseRevert")); 70 return suite; 71 } 72 73 public void testInvokeCloseRevert() throws Exception { 74 try { 77 TestKit.closeProject(PROJECT_NAME); 78 79 new File (TMP_PATH).mkdirs(); 80 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 81 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 82 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 83 projectPath = TestKit.prepareProject("General", "Java Application", PROJECT_NAME); 84 85 ImportWizardOperator iwo = ImportWizardOperator.invoke(ProjectsTabOperator.invoke().getProjectRootNode(PROJECT_NAME)); 86 RepositoryStepOperator rso = new RepositoryStepOperator(); 87 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 89 rso.next(); 90 Thread.sleep(1000); 91 92 FolderToImportStepOperator ftiso = new FolderToImportStepOperator(); 93 ftiso.setRepositoryFolder("trunk/" + PROJECT_NAME); 94 ftiso.setImportMessage("initial import"); 95 ftiso.next(); 96 Thread.sleep(1000); 97 CommitStepOperator cso = new CommitStepOperator(); 98 cso.finish(); 99 100 Node projNode = new Node(new ProjectsTabOperator().tree(), PROJECT_NAME); 101 RevertModificationsOperator rmo = RevertModificationsOperator.invoke(projNode); 103 rmo.verify(); 104 TimeoutExpiredException tee = null; 105 try { 106 rmo.setStartRevision("1"); 107 } catch (Exception e) { 108 tee = (TimeoutExpiredException) e; 109 } 110 assertNotNull("Components shouldn't be accessed", tee); 111 tee = null; 112 try { 113 rmo.setEndRevision("1"); 114 } catch (Exception e) { 115 tee = (TimeoutExpiredException) e; 116 } 117 assertNotNull("Components shouldn't be accessed", tee); 118 tee = null; 119 try { 120 rmo.setEndRevision("1"); 121 } catch (Exception e) { 122 tee = (TimeoutExpiredException) e; 123 } 124 assertNotNull("Components shouldn't be accessed", tee); 125 126 rmo.rbPreviousCommits().push(); 127 rmo.setStartRevision("1"); 128 rmo.setEndRevision("2"); 129 130 tee = null; 131 try { 132 rmo.setRevision("3"); 133 } catch (Exception e) { 134 tee = (TimeoutExpiredException) e; 135 } 136 assertNotNull("Components shouldn't be accessed", tee); 137 138 rmo.rbSingleCommit().push(); 139 rmo.setRevision("3"); 140 141 tee = null; 142 try { 143 rmo.setStartRevision("1"); 144 } catch (Exception e) { 145 tee = (TimeoutExpiredException) e; 146 } 147 assertNotNull("Components shouldn't be accessed", tee); 148 149 tee = null; 150 try { 151 rmo.setEndRevision("2"); 152 } catch (Exception e) { 153 tee = (TimeoutExpiredException) e; 154 } 155 assertNotNull("Components shouldn't be accessed", tee); 156 157 rmo.cancel(); 158 } catch (Exception e) { 159 throw new Exception ("Test failed: " + e); 160 } finally { 161 TestKit.closeProject(PROJECT_NAME); 162 } 163 164 } 165 } 166 | Popular Tags |