Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2015-09-05 12:50:25 +0000
committerMatthias Sohn2015-09-11 12:40:38 +0000
commit8711ef87dfabca84e5edd3b9fb5cbd364c160b39 (patch)
tree283b431222fa0d6c2724b5e4717d89d3fc678fed /org.eclipse.egit.ui.importer.tests/src
parent6403a4f6b8584196c8d632a184141ffb53ac8785 (diff)
downloadegit-8711ef87dfabca84e5edd3b9fb5cbd364c160b39.tar.gz
egit-8711ef87dfabca84e5edd3b9fb5cbd364c160b39.tar.xz
egit-8711ef87dfabca84e5edd3b9fb5cbd364c160b39.zip
[Importer] More direct re-use of EasymportWizard
This changes reuses the EasymportWizard and its operations instead of re-using finer-grained operations and classes that may change in the future. With this change, all changes in the EasymportWizard will be cascaded to EasymportGitWizard without any integration, reducing maintenance effort and ensuring a better consistency. Change-Id: I0f3042a98edfc0b2357b6039356685771d869eb4 Signed-off-by: Mickael Istria <mistria@redhat.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui.importer.tests/src')
-rw-r--r--org.eclipse.egit.ui.importer.tests/src/org/eclipse/egit/ui/importer/tests/EasymportWizardTest.java100
1 files changed, 100 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui.importer.tests/src/org/eclipse/egit/ui/importer/tests/EasymportWizardTest.java b/org.eclipse.egit.ui.importer.tests/src/org/eclipse/egit/ui/importer/tests/EasymportWizardTest.java
new file mode 100644
index 0000000000..2d152e5062
--- /dev/null
+++ b/org.eclipse.egit.ui.importer.tests/src/org/eclipse/egit/ui/importer/tests/EasymportWizardTest.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (C) 2015 Red Hat Inc.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * - Mickael Istria (Red Hat Inc.) : initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.ui.importer.tests;
+
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.tools.ant.taskdefs.Delete;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.SWTBotTestCase;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Test;
+
+public class EasymportWizardTest extends SWTBotTestCase {
+
+ @Test
+ public void test() throws Exception {
+ try {
+ new URL("https://git.eclipse.org/r/").openConnection();
+ } catch (Exception ex) {
+ Assume.assumeNoException("Internet access is required for that test", ex);
+ }
+
+ Set<IProject> initialProjects = new HashSet<>(Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects()));
+ Set<IProject> newProjects = null;
+
+ bot.menu("File").menu("Import...").click();
+ bot.tree().expandNode("Git").select("Projects from Git (with smart import)");
+ bot.button("Next >").click();
+ bot.tree().select("Clone URI");
+ bot.button("Next >").click();
+ bot.text().setText("https://git.eclipse.org/r/jgit/jgit");
+ bot.button("Next >").click();
+ bot.button("Deselect All").click();
+ bot.tree().getTreeItem("master").check();
+ bot.button("Next >").click();
+ Path tmpDir = Files.createTempDirectory(getClass().getName());
+ try {
+ bot.text().setText(tmpDir.toString());
+ bot.button("Next >").click();
+ bot.waitWhile(new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ return !bot.button("Next >").isEnabled();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+ @Override
+ public String getFailureMessage() {
+ return null;
+ }
+ }, 180000); // Time to clone repo, up to 3 minutes
+ bot.button("Next >").click();
+ bot.button("Finish").click();
+
+ bot.shell("Nested Projects");
+ bot.button("OK").click();
+
+ newProjects = new HashSet<>(Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects()));
+ newProjects.removeAll(initialProjects);
+ Assert.assertTrue("There should be more than one project imported with jgit...", newProjects.size() > 1);
+
+ IProject someProject = ResourcesPlugin.getWorkspace().getRoot().getProject("org.eclipse.jgit.ui");
+ Assert.assertTrue("Project not found", someProject.exists());
+ } finally {
+ // clean up
+ if (newProjects != null) {
+ for (IProject p : newProjects) {
+ p.delete(true, new NullProgressMonitor());
+ }
+ }
+
+ Delete deleteTask = new Delete();
+ deleteTask.setDir(tmpDir.toFile());
+ deleteTask.execute();
+ }
+ }
+
+}

Back to the top