Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2010-12-08 16:18:43 +0000
committerJens Baumgart2010-12-08 16:18:43 +0000
commit0a0509f01359f9c3fe38607c2e20930a57328d2d (patch)
treeb66883f2a65f8b66747b307156cf99c4bfe80ed1
parent1d24343f31e122ef854af0985c0d3f8c97d03cb6 (diff)
downloadegit-0a0509f01359f9c3fe38607c2e20930a57328d2d.tar.gz
egit-0a0509f01359f9c3fe38607c2e20930a57328d2d.tar.xz
egit-0a0509f01359f9c3fe38607c2e20930a57328d2d.zip
Implement UI Tests for http authentication
Implements a test for the clone wizard using http authentication. Depends on JGit Change I13bfc4c6c47e27d8f97d3e9752347d6d23e553d4 Change-Id: Ibe56d8e7352a121431e02ebeceab158267945843 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
-rw-r--r--org.eclipse.egit.ui.test/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoPropertiesPage.java33
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardHttpTest.java43
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java67
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTestBase.java92
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/SampleTestRepository.java32
-rw-r--r--pom.xml6
7 files changed, 205 insertions, 71 deletions
diff --git a/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF b/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
index 72f48a4d55..d4b5cbfcb7 100644
--- a/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
@@ -13,7 +13,8 @@ Require-Bundle: org.apache.log4j;version="[1.0.0,2.0.0)",
org.eclipse.core.resources;version="[3.4.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
org.hamcrest;bundle-version="[1.1.0,2.0.0)"
-Import-Package: org.eclipse.jgit.junit;version="[0.10.0,0.11.0)",
+Import-Package: org.eclipse.jgit.junit.http;version="[0.10.0,0.11.0)",
+ org.eclipse.jgit.junit;version="[0.10.0,0.11.0)",
org.eclipse.jgit.lib;version="[0.10.0,0.11.0)",
org.eclipse.jgit.revwalk;version="[0.10.0,0.11.0)",
org.eclipse.jgit.storage.file;version="[0.10.0,0.11.0)",
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoPropertiesPage.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoPropertiesPage.java
index 024fecaaa5..db2973e1f7 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoPropertiesPage.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoPropertiesPage.java
@@ -15,6 +15,7 @@ import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertText;
import static org.junit.Assert.assertEquals;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
public class RepoPropertiesPage {
@@ -25,6 +26,21 @@ public class RepoPropertiesPage {
uri().setText(uri);
}
+ public void setUser(String user) {
+ user().setText(user);
+ }
+
+ public void setPassword(String password) {
+ password().setText(password);
+ }
+
+ public void setStoreInSecureStore(boolean store) {
+ if (store)
+ storeCheckBox().select();
+ else
+ storeCheckBox().deselect();
+ }
+
public void appendToURI(String toAppend) {
SWTBotText uri = uri();
uri.setText(uri.getText() + toAppend);
@@ -65,9 +81,26 @@ public class RepoPropertiesPage {
return bot.textWithLabel("URI:");
}
+ private SWTBotText user() {
+ return bot.textWithLabel("User:");
+ }
+
+ private SWTBotText password() {
+ return bot.textWithLabel("Password:");
+ }
+
+ private SWTBotCheckBox storeCheckBox() {
+ return bot.checkBoxWithLabel("Store in Secure Store");
+ }
+
public RepoRemoteBranchesPage nextToRemoteBranches(String string) {
setURI(string);
+ return nextToRemoteBranches();
+ }
+
+ public RepoRemoteBranchesPage nextToRemoteBranches() {
bot.button("Next >").click();
return new RepoRemoteBranchesPage();
}
+
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardHttpTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardHttpTest.java
new file mode 100644
index 0000000000..fb01850536
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardHttpTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.egit.ui.wizards.clone;
+
+import java.io.File;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.egit.ui.common.RepoPropertiesPage;
+import org.eclipse.egit.ui.common.RepoRemoteBranchesPage;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class GitCloneWizardHttpTest extends GitCloneWizardTestBase {
+
+ @BeforeClass
+ public static void setup() throws Exception {
+ r = new SampleTestRepository(NUMBER_RANDOM_COMMITS, true);
+ }
+
+ @Test
+ public void canCloneARemoteRepo() throws Exception {
+ File destRepo = new File(ResourcesPlugin.getWorkspace()
+ .getRoot().getLocation().toFile(), "test1");
+
+ importWizard.openWizard();
+ RepoPropertiesPage propertiesPage = importWizard.openCloneWizard();
+ propertiesPage.setURI(r.getUri());
+ propertiesPage.setUser("agitter");
+ propertiesPage.setPassword("letmein");
+ propertiesPage.setStoreInSecureStore(false);
+
+ RepoRemoteBranchesPage remoteBranches = propertiesPage
+ .nextToRemoteBranches();
+
+ cloneRepo(destRepo, remoteBranches);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java
index e29c9d1377..df74c02727 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java
@@ -16,42 +16,24 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.io.IOException;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.egit.ui.common.GitImportRepoWizard;
-import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.common.RepoPropertiesPage;
import org.eclipse.egit.ui.common.RepoRemoteBranchesPage;
import org.eclipse.egit.ui.common.WorkingCopyPage;
-import org.eclipse.jgit.dircache.DirCache;
-import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepository;
-import org.junit.AfterClass;
-import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-public class GitCloneWizardTest extends LocalRepositoryTestCase {
-
- private static final int NUMBER_RANDOM_COMMITS = 100;
-
- private static SampleTestRepository r;
-
- private GitImportRepoWizard importWizard;
+public class GitCloneWizardTest extends GitCloneWizardTestBase {
@BeforeClass
public static void setup() throws Exception {
- r = new SampleTestRepository(NUMBER_RANDOM_COMMITS);
- }
-
- @AfterClass
- public static void tearDown() throws IOException {
- r.shutDown();
+ r = new SampleTestRepository(NUMBER_RANDOM_COMMITS, false);
}
@Test
@@ -199,43 +181,7 @@ public class GitCloneWizardTest extends LocalRepositoryTestCase {
RepoRemoteBranchesPage remoteBranches = propertiesPage
.nextToRemoteBranches(r.getUri());
- remoteBranches.assertRemoteBranches(SampleTestRepository.FIX, Constants.MASTER);
- remoteBranches.selectBranches(SampleTestRepository.FIX, Constants.MASTER);
-
- WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy();
- workingCopy.setDirectory(destRepo.toString());
-
- workingCopy.assertDirectory(destRepo.toString());
- workingCopy.assertBranch(Constants.MASTER);
- workingCopy.assertRemoteName(Constants.DEFAULT_REMOTE_NAME);
- workingCopy.waitForCreate();
-
- // Some random sampling to see we got something. We do not test
- // the integrity of the repository here. Only a few basic properties
- // we'd expect from a clone made this way, that would possibly
- // not hold true given other parameters in the GUI.
- Repository repository = new FileRepository(new File(destRepo, Constants.DOT_GIT));
- // we always have an origin/master
- assertNotNull(repository.resolve("origin/master"));
- // and a local master initialized from origin/master (default!)
- assertEquals(repository.resolve("master"), repository
- .resolve("origin/master"));
- // A well known tag
- assertNotNull(repository.resolve(Constants.R_TAGS + SampleTestRepository.v1_0_name).name());
- // lots of refs
- int refs = repository.getAllRefs().size();
- assertTrue(refs >= 4);
- // and a known file in the working dir
- assertTrue(new File(destRepo, SampleTestRepository.A_txt_name).exists());
- DirCacheEntry fileEntry = null;
- DirCache dc = repository.lockDirCache();
- fileEntry = dc.getEntry(SampleTestRepository.A_txt_name);
- dc.unlock();
- // check that we have the file in the index
- assertNotNull(fileEntry);
- // No project have been imported
- assertEquals(0,
- ResourcesPlugin.getWorkspace().getRoot().getProjects().length);
+ cloneRepo(destRepo, remoteBranches);
}
@@ -330,11 +276,4 @@ public class GitCloneWizardTest extends LocalRepositoryTestCase {
remoteBranches.cancel();
}
- @Before
- public void setupViews() {
- bot.perspectiveById("org.eclipse.jdt.ui.JavaPerspective").activate();
- bot.viewByTitle("Package Explorer").show();
- importWizard = new GitImportRepoWizard();
- }
-
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTestBase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTestBase.java
new file mode 100644
index 0000000000..06af78c7d6
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTestBase.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.egit.ui.wizards.clone;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.egit.ui.common.GitImportRepoWizard;
+import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
+import org.eclipse.egit.ui.common.RepoRemoteBranchesPage;
+import org.eclipse.egit.ui.common.WorkingCopyPage;
+import org.eclipse.jgit.dircache.DirCache;
+import org.eclipse.jgit.dircache.DirCacheEntry;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepository;
+import org.junit.AfterClass;
+import org.junit.Before;
+
+public abstract class GitCloneWizardTestBase extends LocalRepositoryTestCase {
+
+ protected static final int NUMBER_RANDOM_COMMITS = 100;
+ protected static SampleTestRepository r;
+ protected GitImportRepoWizard importWizard;
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ r.shutDown();
+ }
+
+ public GitCloneWizardTestBase() {
+ super();
+ }
+
+ protected void cloneRepo(File destRepo, RepoRemoteBranchesPage remoteBranches) throws Exception {
+ remoteBranches.assertRemoteBranches(SampleTestRepository.FIX, Constants.MASTER);
+ remoteBranches.selectBranches(SampleTestRepository.FIX, Constants.MASTER);
+
+ WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy();
+ workingCopy.setDirectory(destRepo.toString());
+
+ workingCopy.assertDirectory(destRepo.toString());
+ workingCopy.assertBranch(Constants.MASTER);
+ workingCopy.assertRemoteName(Constants.DEFAULT_REMOTE_NAME);
+ workingCopy.waitForCreate();
+
+ // Some random sampling to see we got something. We do not test
+ // the integrity of the repository here. Only a few basic properties
+ // we'd expect from a clone made this way, that would possibly
+ // not hold true given other parameters in the GUI.
+ Repository repository = new FileRepository(new File(destRepo, Constants.DOT_GIT));
+ // we always have an origin/master
+ assertNotNull(repository.resolve("origin/master"));
+ // and a local master initialized from origin/master (default!)
+ assertEquals(repository.resolve("master"), repository
+ .resolve("origin/master"));
+ // A well known tag
+ assertNotNull(repository.resolve(Constants.R_TAGS + SampleTestRepository.v1_0_name).name());
+ // lots of refs
+ int refs = repository.getAllRefs().size();
+ assertTrue(refs >= 4);
+ // and a known file in the working dir
+ assertTrue(new File(destRepo, SampleTestRepository.A_txt_name).exists());
+ DirCacheEntry fileEntry = null;
+ DirCache dc = repository.lockDirCache();
+ fileEntry = dc.getEntry(SampleTestRepository.A_txt_name);
+ dc.unlock();
+ // check that we have the file in the index
+ assertNotNull(fileEntry);
+ // No project has been imported
+ assertEquals(0,
+ ResourcesPlugin.getWorkspace().getRoot().getProjects().length);
+ }
+
+ @Before
+ public void setupViews() {
+ bot.perspectiveById("org.eclipse.jdt.ui.JavaPerspective").activate();
+ bot.viewByTitle("Package Explorer").show();
+ importWizard = new GitImportRepoWizard();
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/SampleTestRepository.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/SampleTestRepository.java
index 15cc3ad8b8..859dbdfa8c 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/SampleTestRepository.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/SampleTestRepository.java
@@ -16,6 +16,7 @@ import java.io.IOException;
import java.util.Random;
import org.eclipse.jgit.junit.TestRepository;
+import org.eclipse.jgit.junit.http.SimpleHttpServer;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -57,12 +58,14 @@ public class SampleTestRepository {
*/
public static final String A_txt_name = "A_txt";
- private static final File trash = new File("trash");
+ private static final File trash = new File("target/trash");
private final TestRepository<FileRepository> src;
private Daemon d;
+ private SimpleHttpServer httpServer;
+
private String uri;
private RevBlob A_txt;
@@ -71,6 +74,8 @@ public class SampleTestRepository {
private RevTag v1_0, v2_0;
+ private final boolean serveHttp;
+
public String getUri() {
return uri;
}
@@ -81,13 +86,19 @@ public class SampleTestRepository {
*
* @param n
* hint how many random commits should be generated
+ * @param
+ * serveHttp
*
* @throws Exception
*/
- public SampleTestRepository(int n) throws Exception {
+ public SampleTestRepository(int n, boolean serveHttp) throws Exception {
+ this.serveHttp = serveHttp;
src = createRepository();
generateSampleData(n);
- serve();
+ if (serveHttp)
+ serveHttp();
+ else
+ serve();
}
private TestRepository<FileRepository> createRepository() throws Exception {
@@ -147,16 +158,25 @@ public class SampleTestRepository {
+ Constants.DOT_GIT;
}
+ private void serveHttp() throws Exception{
+ httpServer = new SimpleHttpServer(src.getRepository());
+ httpServer.start();
+ uri = httpServer.getUri().toString();
+ }
+
/**
* Stop the git daemon and delete test data from disk. If the system
* property <code>test-repo-no-cleanup</code> is defined the test data will
* be left on disk for analysis.
*
- * @throws FileNotFoundException
+ * @throws Exception
* deletion of test repository failed
*/
- public void shutDown() throws FileNotFoundException {
- d.stop();
+ public void shutDown() throws Exception {
+ if (serveHttp)
+ httpServer.stop();
+ else
+ d.stop();
if (!System.getProperties().contains("test-repo-no-cleanup"))
delete(trash);
}
diff --git a/pom.xml b/pom.xml
index 53fd99d45c..be90c6d748 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,6 +65,7 @@
<tycho-version>0.10.0</tycho-version>
<platform-version-name>galileo</platform-version-name>
<jgit-site>file:/${basedir}/../../jgit/org.eclipse.jgit.packaging/org.eclipse.jgit.updatesite/target/site</jgit-site>
+ <jetty-site>http://download.eclipse.org/jetty/7.1.1.v20100517/repository/</jetty-site>
<eclipse-site>http://download.eclipse.org/releases/${platform-version-name}</eclipse-site>
<swtbot-site>http://download.eclipse.org/technology/swtbot/${platform-version-name}/dev-build/update-site</swtbot-site>
<wikitext-site>http://download.eclipse.org/tools/mylyn/update/weekly</wikitext-site>
@@ -145,6 +146,11 @@
<layout>p2</layout>
<url>${wikitext-site}</url>
</repository>
+ <repository>
+ <id>jetty</id>
+ <layout>p2</layout>
+ <url>${jetty-site}</url>
+ </repository>
</repositories>
<pluginRepositories>

Back to the top