1 9 10 package org.netbeans.test.subversion.main.archeology; 11 12 import java.io.File ; 13 import java.io.PrintStream ; 14 import org.netbeans.jellytools.JellyTestCase; 15 import org.netbeans.jellytools.NbDialogOperator; 16 import org.netbeans.jellytools.OutputTabOperator; 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.JButtonOperator; 21 import org.netbeans.junit.NbTestSuite; 22 import org.netbeans.test.subversion.operators.CheckoutWizardOperator; 23 import org.netbeans.test.subversion.operators.RepositoryBrowserOperator; 24 import org.netbeans.test.subversion.operators.RepositoryBrowserSearchHistoryOperator; 25 import org.netbeans.test.subversion.operators.RepositoryStepOperator; 26 import org.netbeans.test.subversion.operators.SearchHistoryOperator; 27 import org.netbeans.test.subversion.operators.VersioningOperator; 28 import org.netbeans.test.subversion.operators.WorkDirStepOperator; 29 import org.netbeans.test.subversion.utils.RepositoryMaintenance; 30 import org.netbeans.test.subversion.utils.TestKit; 31 import org.netbeans.junit.ide.ProjectSupport; 32 import junit.textui.TestRunner; 33 import org.netbeans.jellytools.EditorOperator; 34 import org.netbeans.jemmy.QueueTool; 35 import org.netbeans.jemmy.operators.Operator; 36 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 37 import org.netbeans.test.subversion.operators.RepositoryBrowserOperator; 38 39 43 public class SearchHistoryUITest extends JellyTestCase{ 44 45 public static final String TMP_PATH = "/tmp"; 46 public static final String REPO_PATH = "repo"; 47 public static final String WORK_PATH = "work"; 48 public static final String PROJECT_NAME = "JavaApp"; 49 public File projectPath; 50 public PrintStream stream; 51 String os_name; 52 Operator.DefaultStringComparator comOperator; 53 Operator.DefaultStringComparator oldOperator; 54 55 56 public SearchHistoryUITest(String name) { 57 super(name); 58 } 59 60 protected void setUp() throws Exception { 61 os_name = System.getProperty("os.name"); 62 System.out.println("### "+getName()+" ###"); 64 65 } 66 67 protected boolean isUnix() { 68 boolean unix = false; 69 if (os_name.indexOf("Windows") == -1) { 70 unix = true; 71 } 72 return unix; 73 } 74 75 public static void main(String [] args) { 76 TestRunner.run(suite()); 78 } 79 80 public static NbTestSuite suite() { 81 NbTestSuite suite = new NbTestSuite(); 82 suite.addTest(new SearchHistoryUITest("testInvokeSearch")); 83 return suite; 84 } 85 86 public void testInvokeSearch() throws Exception { 87 try { 90 TestKit.closeProject(PROJECT_NAME); 91 92 stream = new PrintStream (new File (getWorkDir(), getName() + ".log")); 93 comOperator = new Operator.DefaultStringComparator(true, true); 94 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 95 Operator.setDefaultStringComparator(comOperator); 96 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 97 Operator.setDefaultStringComparator(oldOperator); 98 RepositoryStepOperator rso = new RepositoryStepOperator(); 99 100 File work = new File (TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis()); 102 new File (TMP_PATH).mkdirs(); 103 work.mkdirs(); 104 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 105 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 107 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 108 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 109 110 rso.next(); 111 WorkDirStepOperator wdso = new WorkDirStepOperator(); 112 wdso.setRepositoryFolder("trunk/" + PROJECT_NAME); 113 wdso.setLocalFolder(work.getCanonicalPath()); 114 wdso.checkCheckoutContentOnly(false); 115 OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo"); 116 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 117 oto.clear(); 118 wdso.finish(); 119 oto.waitText("Checking out... finished."); 121 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 122 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 123 open.push(); 124 125 ProjectSupport.waitScanFinished(); 126 new QueueTool().waitEmpty(1000); 127 ProjectSupport.waitScanFinished(); 128 129 oto = new OutputTabOperator("file:///tmp/repo"); 130 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 131 oto.clear(); 132 Node node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|Main.java"); 133 SearchHistoryOperator sho = SearchHistoryOperator.invoke(node); 134 135 oto.waitText("Searching History... finished."); 136 oto = new OutputTabOperator("file:///tmp/repo"); 137 oto.clear(); 138 sho.verify(); 139 RepositoryBrowserOperator rbo = sho.getRevisionFrom(); 140 oto.waitText("Loading... finished."); 141 rbo.verify(); 142 rbo.cancel(); 143 144 oto = new OutputTabOperator("file:///tmp/repo"); 145 oto.clear(); 146 rbo = sho.getRevisionTo(); 147 oto.waitText("Loading... finished."); 148 rbo.verify(); 149 rbo.cancel(); 150 151 sho.setUsername("test"); 152 sho.setFrom("1"); 153 sho.setTo("2"); 154 155 stream.flush(); 156 stream.close(); 157 } catch (Exception e) { 158 throw new Exception ("Test failed: " + e); 159 } finally { 160 TestKit.closeProject(PROJECT_NAME); 161 } 162 } 163 } 164 | Popular Tags |