1 9 10 package org.netbeans.test.subversion.main.commit; 11 12 import java.io.File ; 13 import javax.swing.table.TableModel ; 14 import junit.textui.TestRunner; 15 import org.netbeans.jellytools.JellyTestCase; 16 import org.netbeans.jellytools.ProjectsTabOperator; 17 import org.netbeans.jellytools.nodes.Node; 18 import org.netbeans.jellytools.nodes.SourcePackagesNode; 19 import org.netbeans.jemmy.JemmyProperties; 20 import org.netbeans.jemmy.operators.JTableOperator; 21 import org.netbeans.junit.NbTestSuite; 22 import org.netbeans.test.subversion.operators.CommitOperator; 23 import org.netbeans.test.subversion.operators.CommitStepOperator; 24 import org.netbeans.test.subversion.operators.FolderToImportStepOperator; 25 import org.netbeans.test.subversion.operators.ImportWizardOperator; 26 import org.netbeans.test.subversion.operators.RepositoryStepOperator; 27 import org.netbeans.test.subversion.utils.RepositoryMaintenance; 28 import org.netbeans.test.subversion.utils.TestKit; 29 30 34 public class CommitUiTest extends JellyTestCase{ 35 36 public static final String TMP_PATH = "/tmp"; 37 public static final String REPO_PATH = "repo"; 38 public static final String WORK_PATH = "work"; 39 public static final String PROJECT_NAME = "SVNApplication"; 40 public File projectPath; 41 42 String os_name; 43 44 45 public CommitUiTest(String name) { 46 super(name); 47 } 48 49 protected void setUp() throws Exception { 50 os_name = System.getProperty("os.name"); 51 System.out.println("### "+getName()+" ###"); 53 54 } 55 56 protected boolean isUnix() { 57 boolean unix = false; 58 if (os_name.indexOf("Windows") == -1) { 59 unix = true; 60 } 61 return unix; 62 } 63 64 public static void main(String [] args) { 65 TestRunner.run(suite()); 67 } 68 69 public static NbTestSuite suite() { 70 NbTestSuite suite = new NbTestSuite(); 71 suite.addTest(new CommitUiTest("testInvokeCloseCommit")); 72 return suite; 73 } 74 75 public void testInvokeCloseCommit() throws Exception { 76 try { 79 TestKit.closeProject(PROJECT_NAME); 80 81 new File (TMP_PATH).mkdirs(); 82 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 83 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 84 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 85 projectPath = TestKit.prepareProject("General", "Java Application", PROJECT_NAME); 86 87 ImportWizardOperator iwo = ImportWizardOperator.invoke(ProjectsTabOperator.invoke().getProjectRootNode(PROJECT_NAME)); 88 RepositoryStepOperator rso = new RepositoryStepOperator(); 89 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 91 rso.next(); 92 Thread.sleep(1000); 93 94 FolderToImportStepOperator ftiso = new FolderToImportStepOperator(); 95 ftiso.setRepositoryFolder("trunk/" + PROJECT_NAME); 96 ftiso.setImportMessage("initial import"); 97 ftiso.next(); 98 Thread.sleep(1000); 99 CommitStepOperator cso = new CommitStepOperator(); 100 cso.finish(); 101 102 TestKit.createNewElements(PROJECT_NAME, "xx", "NewClass"); 103 TestKit.createNewElement(PROJECT_NAME, "xx", "NewClass2"); 104 TestKit.createNewElement(PROJECT_NAME, "xx", "NewClass3"); 105 Node packNode = new Node(new SourcePackagesNode(PROJECT_NAME), "xx"); 106 CommitOperator co = CommitOperator.invoke(packNode); 107 108 co.selectCommitAction("NewClass.java", "Add As Text"); 109 co.selectCommitAction("NewClass.java", "Add As Binary"); 110 co.selectCommitAction("NewClass.java", "Exclude from Commit"); 111 co.selectCommitAction(2, "Add As Text"); 112 co.selectCommitAction(2, "Add As Binary"); 113 co.selectCommitAction(2, "Exclude from Commit"); 114 115 JTableOperator table = co.tabFiles(); 116 TableModel model = table.getModel(); 117 String [] expected = {"xx", "NewClass.java", "NewClass2.java", "NewClass3.java"}; 118 String [] actual = new String [model.getRowCount()]; 119 for (int i = 0; i < model.getRowCount(); i++) { 120 actual[i] = model.getValueAt(i, 0).toString(); 121 } 122 int result = TestKit.compareThem(expected, actual, false); 123 assertEquals("Commit table doesn't contain all files!!!", expected.length, result); 124 125 co.verify(); 126 co.cancel(); 127 129 } catch (Exception e) { 130 throw new Exception ("Test failed: " + e); 131 } finally { 132 TestKit.closeProject(PROJECT_NAME); 133 } 134 } 135 } 136 | Popular Tags |