PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/netbeans-7.3/mercurial/test/qa-functional/src/org/netbeans/test/mercurial/main/commit/CloneTest.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 171 lines | 99 code | 15 blank | 57 comment | 4 complexity | 714b42dd228fb79db86e99f563cdb9c3 MD5 | raw file
  1. /*
  2. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  3. *
  4. * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
  5. *
  6. * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  7. * Other names may be trademarks of their respective owners.
  8. *
  9. * The contents of this file are subject to the terms of either the GNU
  10. * General Public License Version 2 only ("GPL") or the Common
  11. * Development and Distribution License("CDDL") (collectively, the
  12. * "License"). You may not use this file except in compliance with the
  13. * License. You can obtain a copy of the License at
  14. * http://www.netbeans.org/cddl-gplv2.html
  15. * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  16. * specific language governing permissions and limitations under the
  17. * License. When distributing the software, include this License Header
  18. * Notice in each file and include the License file at
  19. * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
  20. * particular file as subject to the "Classpath" exception as provided
  21. * by Oracle in the GPL Version 2 section of the License file that
  22. * accompanied this code. If applicable, add the following below the
  23. * License Header, with the fields enclosed by brackets [] replaced by
  24. * your own identifying information:
  25. * "Portions Copyrighted [year] [name of copyright owner]"
  26. *
  27. * If you wish your version of this file to be governed by only the CDDL
  28. * or only the GPL Version 2, indicate your decision by adding
  29. * "[Contributor] elects to include this software in this distribution
  30. * under the [CDDL or GPL Version 2] license." If you do not indicate a
  31. * single choice of license, a recipient has the option to distribute
  32. * your version of this file under either the CDDL, the GPL Version 2 or
  33. * to extend the choice of license to its licensees as provided above.
  34. * However, if you add GPL Version 2 code and therefore, elected the GPL
  35. * Version 2 license, then the option applies only if the new code is
  36. * made subject to such option by the copyright holder.
  37. *
  38. * Contributor(s):
  39. *
  40. * Portions Copyrighted 2008 Sun Microsystems, Inc.
  41. */
  42. package org.netbeans.test.mercurial.main.commit;
  43. import java.io.File;
  44. import java.io.PrintStream;
  45. import java.util.logging.Level;
  46. import java.util.logging.Logger;
  47. import junit.framework.Test;
  48. import org.netbeans.jellytools.JellyTestCase;
  49. import org.netbeans.jellytools.NbDialogOperator;
  50. import org.netbeans.jellytools.NewProjectWizardOperator;
  51. import org.netbeans.jellytools.ProjectsTabOperator;
  52. import org.netbeans.jellytools.nodes.Node;
  53. import org.netbeans.jemmy.JemmyProperties;
  54. import org.netbeans.jemmy.operators.JButtonOperator;
  55. import org.netbeans.jemmy.operators.JTextFieldOperator;
  56. import org.netbeans.junit.NbModuleSuite;
  57. import org.netbeans.test.mercurial.utils.MessageHandler;
  58. import org.netbeans.test.mercurial.utils.TestKit;
  59. /**
  60. *
  61. * @author novakm
  62. */
  63. public class CloneTest extends JellyTestCase {
  64. public File projectPath;
  65. public PrintStream stream;
  66. String os_name;
  67. static File f;
  68. static Logger log;
  69. public CloneTest(String name) {
  70. super(name);
  71. }
  72. @Override
  73. protected void setUp() throws Exception {
  74. System.out.println("### "+getName()+" ###");
  75. if (log == null) {
  76. log = Logger.getLogger(TestKit.LOGGER_NAME);
  77. log.setLevel(Level.ALL);
  78. TestKit.removeHandlers(log);
  79. } else {
  80. TestKit.removeHandlers(log);
  81. }
  82. }
  83. public static Test suite() {
  84. return NbModuleSuite.create(
  85. NbModuleSuite.createConfiguration(CloneTest.class).addTest("testCloneProject").enableModules(".*").clusters(".*"));
  86. }
  87. public void testCloneProject() throws Exception {
  88. System.out.println("DEBUG: testCloneProject - start");
  89. long timeout = JemmyProperties.getCurrentTimeout("ComponentOperator.WaitComponentTimeout");
  90. // try {
  91. // JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 15000);
  92. // } finally {
  93. // JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", timeout);
  94. // }
  95. //
  96. // timeout = JemmyProperties.getCurrentTimeout("DialogWaiter.WaitDialogTimeout");
  97. // try {
  98. // JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 15000);
  99. // } finally {
  100. // JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", timeout);
  101. // }
  102. try {
  103. MessageHandler mh = new MessageHandler("Cloning");
  104. log.addHandler(mh);
  105. if (TestKit.getOsName().indexOf("Mac") > -1)
  106. NewProjectWizardOperator.invoke().close();
  107. Node nodeFile;
  108. NbDialogOperator ndo;
  109. JButtonOperator bo;
  110. JTextFieldOperator tfo;
  111. TestKit.loadOpenProject(TestKit.PROJECT_NAME, getDataDir());
  112. String s = TestKit.getProjectAbsolutePath(TestKit.PROJECT_NAME);
  113. nodeFile = new ProjectsTabOperator().getProjectRootNode(TestKit.PROJECT_NAME);
  114. nodeFile.performMenuActionNoBlock("Team|Mercurial|Clone -");
  115. ndo = new NbDialogOperator("Clone Repository");
  116. bo = new JButtonOperator(ndo, "Clone");
  117. bo.push();
  118. String outputTabName = s;
  119. System.out.println(outputTabName);
  120. TestKit.waitText(mh);
  121. mh = new MessageHandler("Cloning");
  122. TestKit.removeHandlers(log);
  123. log.addHandler(mh);
  124. nodeFile = new ProjectsTabOperator().getProjectRootNode(TestKit.PROJECT_NAME);
  125. nodeFile.performMenuActionNoBlock("Team|Mercurial|Clone Other...");
  126. ndo = new NbDialogOperator("Clone External Repository");
  127. tfo = new JTextFieldOperator(ndo);
  128. String repoPath = "file://" + s.replace(File.separatorChar, "/".toCharArray()[0]);
  129. tfo.setText(repoPath);
  130. bo = new JButtonOperator(ndo, "Next");
  131. bo.push();
  132. bo.push();
  133. tfo = new JTextFieldOperator(ndo);
  134. tfo.setText(tfo.getText() + TestKit.CLONE_SUF_1);
  135. System.out.println(tfo.getText() + TestKit.CLONE_SUF_1);
  136. bo = new JButtonOperator(ndo, "Finish");
  137. bo.push();
  138. ndo = new NbDialogOperator("Checkout Completed");
  139. bo = new JButtonOperator(ndo, "Open Project");
  140. System.out.println(bo.getText());
  141. bo.push();
  142. outputTabName=repoPath;
  143. System.out.println(outputTabName);
  144. TestKit.waitText(mh);
  145. TestKit.closeProject(TestKit.PROJECT_NAME);
  146. TestKit.closeProject(TestKit.PROJECT_NAME);
  147. TestKit.closeProject(TestKit.PROJECT_NAME);
  148. } catch (Exception e) {
  149. TestKit.closeProject(TestKit.PROJECT_NAME);
  150. TestKit.closeProject(TestKit.PROJECT_NAME);
  151. TestKit.closeProject(TestKit.PROJECT_NAME);
  152. throw new Exception("Test failed: " + e);
  153. }
  154. System.out.println("DEBUG: testCloneProject - finish");
  155. }
  156. }