Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2013-05-03 14:23:20 +0000
committerRobin Stocker2013-05-03 15:00:32 +0000
commit91861e58ca2cfddf11253a17dc574233b967cdaa (patch)
tree2afbde2f54082ec1e4723dd0d7bd2b8c7edc5f71 /org.eclipse.egit.ui.test/src
parentdadf0386a08feff68b62bf1a1b506611ec7fce6b (diff)
downloadegit-91861e58ca2cfddf11253a17dc574233b967cdaa.tar.gz
egit-91861e58ca2cfddf11253a17dc574233b967cdaa.tar.xz
egit-91861e58ca2cfddf11253a17dc574233b967cdaa.zip
Fix line endings
Change-Id: Id7f665b3f4cd7aa48c31593f8b7ce74ee417d5c3 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Robin Stocker <robin@nibor.org>
Diffstat (limited to 'org.eclipse.egit.ui.test/src')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LoginDialogTester.java52
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushResultDialogTester.java52
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushWizardTester.java108
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RefSpecPageTester.java42
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java234
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/SampleTestRepository.java379
6 files changed, 433 insertions, 434 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LoginDialogTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LoginDialogTester.java
index 3316ae19d5..b85334e4bc 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LoginDialogTester.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LoginDialogTester.java
@@ -1,26 +1,26 @@
-/*******************************************************************************
- * 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.common;
-
-import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-
-public class LoginDialogTester {
-
- private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
-
- public void login(String user, String password) {
- bot.textWithLabel(UIText.LoginDialog_user).setText(user);
- bot.textWithLabel(UIText.LoginDialog_password).setText(password);
- bot.checkBoxWithLabel(UIText.LoginDialog_storeInSecureStore).deselect();
- bot.button(IDialogConstants.OK_LABEL).click();
- }
-
-}
+/*******************************************************************************
+ * 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.common;
+
+import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+
+public class LoginDialogTester {
+
+ private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+ public void login(String user, String password) {
+ bot.textWithLabel(UIText.LoginDialog_user).setText(user);
+ bot.textWithLabel(UIText.LoginDialog_password).setText(password);
+ bot.checkBoxWithLabel(UIText.LoginDialog_storeInSecureStore).deselect();
+ bot.button(IDialogConstants.OK_LABEL).click();
+ }
+
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushResultDialogTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushResultDialogTester.java
index 49376751dd..610544b497 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushResultDialogTester.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushResultDialogTester.java
@@ -1,26 +1,26 @@
-/*******************************************************************************
- * 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.common;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-
-public class PushResultDialogTester {
-
- private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
-
- public void assertResultMessage(String expectedMessage) {
- bot.styledText(expectedMessage);
- }
-
- public void closeDialog() {
- bot.button(IDialogConstants.OK_LABEL).click();
- }
-
-}
+/*******************************************************************************
+ * 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.common;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+
+public class PushResultDialogTester {
+
+ private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+ public void assertResultMessage(String expectedMessage) {
+ bot.styledText(expectedMessage);
+ }
+
+ public void closeDialog() {
+ bot.button(IDialogConstants.OK_LABEL).click();
+ }
+
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushWizardTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushWizardTester.java
index eae0d81983..14e6877ec9 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushWizardTester.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/PushWizardTester.java
@@ -1,54 +1,54 @@
-/*******************************************************************************
- * 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.common;
-
-import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.egit.ui.internal.push.PushWizard;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.waits.Conditions;
-import org.eclipse.ui.PlatformUI;
-
-public class PushWizardTester {
-
- private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
-
- public RepoPropertiesPage openPushWizard(final Repository repository)
- throws Exception {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- try {
- Shell shell = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell();
- PushWizard pushWizard = new PushWizard(repository);
- WizardDialog dlg = new WizardDialog(shell, pushWizard);
- dlg.setHelpAvailable(false);
- dlg.open();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- });
- bot.waitUntil(Conditions.shellIsActive(UIText.PushWizard_windowTitleDefault),
- 20000);
- return new RepoPropertiesPage();
- }
-
- public void nextPage() {
- bot.button(IDialogConstants.NEXT_LABEL).click();
- }
-
- public void finish() {
- bot.button(IDialogConstants.FINISH_LABEL).click();
- }
-
-}
+/*******************************************************************************
+ * 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.common;
+
+import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.push.PushWizard;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.ui.PlatformUI;
+
+public class PushWizardTester {
+
+ private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+ public RepoPropertiesPage openPushWizard(final Repository repository)
+ throws Exception {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ PushWizard pushWizard = new PushWizard(repository);
+ WizardDialog dlg = new WizardDialog(shell, pushWizard);
+ dlg.setHelpAvailable(false);
+ dlg.open();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ bot.waitUntil(Conditions.shellIsActive(UIText.PushWizard_windowTitleDefault),
+ 20000);
+ return new RepoPropertiesPage();
+ }
+
+ public void nextPage() {
+ bot.button(IDialogConstants.NEXT_LABEL).click();
+ }
+
+ public void finish() {
+ bot.button(IDialogConstants.FINISH_LABEL).click();
+ }
+
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RefSpecPageTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RefSpecPageTester.java
index 0415f6325b..8b57c30687 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RefSpecPageTester.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RefSpecPageTester.java
@@ -1,21 +1,21 @@
-/*******************************************************************************
- * 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.common;
-
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.waits.Conditions;
-
-public class RefSpecPageTester {
-
- private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
-
- public void waitUntilPageIsReady(int nrOfEcpectedTableEntries) {
- bot.waitUntil(Conditions.tableHasRows(bot.table(), nrOfEcpectedTableEntries), 20000);
- }
-}
+/*******************************************************************************
+ * 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.common;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+
+public class RefSpecPageTester {
+
+ private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+ public void waitUntilPageIsReady(int nrOfEcpectedTableEntries) {
+ bot.waitUntil(Conditions.tableHasRows(bot.table(), nrOfEcpectedTableEntries), 20000);
+ }
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java
index 519f618fcd..e7c9a0bb0f 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java
@@ -1,117 +1,117 @@
-/*******************************************************************************
- * 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.httpauth;
-
-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.core.Activator;
-import org.eclipse.egit.core.op.CloneOperation;
-import org.eclipse.egit.ui.common.EGitTestCase;
-import org.eclipse.egit.ui.common.LoginDialogTester;
-import org.eclipse.egit.ui.common.PushResultDialogTester;
-import org.eclipse.egit.ui.common.PushWizardTester;
-import org.eclipse.egit.ui.common.RefSpecPageTester;
-import org.eclipse.egit.ui.common.RepoPropertiesPage;
-import org.eclipse.egit.ui.test.TestUtil;
-import org.eclipse.egit.ui.wizards.clone.SampleTestRepository;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.lib.StoredConfig;
-import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
-import org.eclipse.jgit.util.FileUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class PushTest extends EGitTestCase {
-
- private static final int NUMBER_RANDOM_COMMITS = 5;
-
- private SampleTestRepository remoteRepository;
-
- private Repository localRepository;
-
- private File file;
-
- private File localRepoPath;
-
- @Before
- public void setup() throws Exception {
- TestUtil.disableProxy();
- remoteRepository = new SampleTestRepository(NUMBER_RANDOM_COMMITS, true);
- localRepoPath = new File(ResourcesPlugin.getWorkspace().getRoot()
- .getLocation().toFile(), "test" + System.nanoTime());
- String branch = Constants.R_HEADS + SampleTestRepository.FIX;
- CloneOperation cloneOperation = new CloneOperation(new URIish(
- remoteRepository.getUri()), true, null, localRepoPath, branch,
- "origin", 30);
- cloneOperation
- .setCredentialsProvider(new UsernamePasswordCredentialsProvider(
- "agitter", "letmein"));
- cloneOperation.run(null);
- file = new File(localRepoPath, SampleTestRepository.A_txt_name);
- assertTrue(file.exists());
- localRepository = Activator.getDefault().getRepositoryCache()
- .lookupRepository(new File(localRepoPath, ".git"));
- assertNotNull(localRepository);
- }
-
- @Test
- public void testPush() throws Exception {
- // change file
- TestUtil.appendFileContent(file, "additional content", true);
- // commit change
- Git git = new Git(localRepository);
- git.add().addFilepattern(SampleTestRepository.A_txt_name).call();
- git.commit().setMessage("Change").call();
- configurePush();
- // push change
- PushWizardTester wizardTester = new PushWizardTester();
- RepoPropertiesPage repoPropertiesPage = wizardTester.openPushWizard(localRepository);
- repoPropertiesPage.setPushDestination("push");
- wizardTester.nextPage();
- // now login dialog appears
- LoginDialogTester loginDialogTester = new LoginDialogTester();
- loginDialogTester.login("agitter", "letmein");
- RefSpecPageTester refSpecPageTester = new RefSpecPageTester();
- refSpecPageTester.waitUntilPageIsReady(1);
- wizardTester.finish();
- loginDialogTester.login("agitter", "letmein");
- PushResultDialogTester pushResultDialogTester = new PushResultDialogTester();
- String expectedMessage = "Repository " + remoteRepository.getUri();
- pushResultDialogTester.assertResultMessage(expectedMessage);
- pushResultDialogTester.closeDialog();
- }
-
- private void configurePush() throws Exception {
- StoredConfig config = localRepository.getConfig();
- config.setString("remote", "push", "pushurl", remoteRepository.getUri());
- config.setString("remote", "push", "push", "+refs/heads/*:refs/heads/*");
- config.save();
- }
-
- @After
- public void tearDown() throws Exception {
- if (remoteRepository != null)
- remoteRepository.shutDown();
- Activator.getDefault().getRepositoryCache().clear();
- if (localRepository != null)
- localRepository.close();
- if (localRepoPath != null)
- FileUtils.delete(localRepoPath, FileUtils.RECURSIVE
- | FileUtils.RETRY);
- }
-
-}
+/*******************************************************************************
+ * 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.httpauth;
+
+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.core.Activator;
+import org.eclipse.egit.core.op.CloneOperation;
+import org.eclipse.egit.ui.common.EGitTestCase;
+import org.eclipse.egit.ui.common.LoginDialogTester;
+import org.eclipse.egit.ui.common.PushResultDialogTester;
+import org.eclipse.egit.ui.common.PushWizardTester;
+import org.eclipse.egit.ui.common.RefSpecPageTester;
+import org.eclipse.egit.ui.common.RepoPropertiesPage;
+import org.eclipse.egit.ui.test.TestUtil;
+import org.eclipse.egit.ui.wizards.clone.SampleTestRepository;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
+import org.eclipse.jgit.util.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class PushTest extends EGitTestCase {
+
+ private static final int NUMBER_RANDOM_COMMITS = 5;
+
+ private SampleTestRepository remoteRepository;
+
+ private Repository localRepository;
+
+ private File file;
+
+ private File localRepoPath;
+
+ @Before
+ public void setup() throws Exception {
+ TestUtil.disableProxy();
+ remoteRepository = new SampleTestRepository(NUMBER_RANDOM_COMMITS, true);
+ localRepoPath = new File(ResourcesPlugin.getWorkspace().getRoot()
+ .getLocation().toFile(), "test" + System.nanoTime());
+ String branch = Constants.R_HEADS + SampleTestRepository.FIX;
+ CloneOperation cloneOperation = new CloneOperation(new URIish(
+ remoteRepository.getUri()), true, null, localRepoPath, branch,
+ "origin", 30);
+ cloneOperation
+ .setCredentialsProvider(new UsernamePasswordCredentialsProvider(
+ "agitter", "letmein"));
+ cloneOperation.run(null);
+ file = new File(localRepoPath, SampleTestRepository.A_txt_name);
+ assertTrue(file.exists());
+ localRepository = Activator.getDefault().getRepositoryCache()
+ .lookupRepository(new File(localRepoPath, ".git"));
+ assertNotNull(localRepository);
+ }
+
+ @Test
+ public void testPush() throws Exception {
+ // change file
+ TestUtil.appendFileContent(file, "additional content", true);
+ // commit change
+ Git git = new Git(localRepository);
+ git.add().addFilepattern(SampleTestRepository.A_txt_name).call();
+ git.commit().setMessage("Change").call();
+ configurePush();
+ // push change
+ PushWizardTester wizardTester = new PushWizardTester();
+ RepoPropertiesPage repoPropertiesPage = wizardTester.openPushWizard(localRepository);
+ repoPropertiesPage.setPushDestination("push");
+ wizardTester.nextPage();
+ // now login dialog appears
+ LoginDialogTester loginDialogTester = new LoginDialogTester();
+ loginDialogTester.login("agitter", "letmein");
+ RefSpecPageTester refSpecPageTester = new RefSpecPageTester();
+ refSpecPageTester.waitUntilPageIsReady(1);
+ wizardTester.finish();
+ loginDialogTester.login("agitter", "letmein");
+ PushResultDialogTester pushResultDialogTester = new PushResultDialogTester();
+ String expectedMessage = "Repository " + remoteRepository.getUri();
+ pushResultDialogTester.assertResultMessage(expectedMessage);
+ pushResultDialogTester.closeDialog();
+ }
+
+ private void configurePush() throws Exception {
+ StoredConfig config = localRepository.getConfig();
+ config.setString("remote", "push", "pushurl", remoteRepository.getUri());
+ config.setString("remote", "push", "push", "+refs/heads/*:refs/heads/*");
+ config.save();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (remoteRepository != null)
+ remoteRepository.shutDown();
+ Activator.getDefault().getRepositoryCache().clear();
+ if (localRepository != null)
+ localRepository.close();
+ if (localRepoPath != null)
+ FileUtils.delete(localRepoPath, FileUtils.RECURSIVE
+ | FileUtils.RETRY);
+ }
+
+}
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 c5924a4494..47e7b19fab 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
@@ -1,192 +1,191 @@
-/*******************************************************************************
- * Copyright (C) 2010, Matthias Sohn <matthias.sohn@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.assertFalse;
-
-import java.io.File;
-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;
-import org.eclipse.jgit.revwalk.RevTag;
-import org.eclipse.jgit.internal.storage.file.FileRepository;
-import org.eclipse.jgit.transport.Daemon;
-import org.eclipse.jgit.transport.DaemonClient;
-import org.eclipse.jgit.transport.resolver.FileResolver;
-import org.eclipse.jgit.util.FileUtils;
-
-/**
- * Creates an on disk sample repository with some generated content and starts a
- * git daemon on a free port.
- *
- * If the system property <code>test-repo-no-cleanup</code> is defined the
- * source repository data will not be deleted from disk to enable testing the
- * test.
- */
-public class SampleTestRepository {
- /**
- * Name of the test repository
- */
- public static final String REPO_NAME = "test";
-
- /**
- * Name of a branch in the sample repository
- */
- public static final String FIX = "fix";
-
- /**
- * Name of a tag in the sample repository
- */
- public static final String v1_0_name = "v1_0";
-
- /**
- * Name of a tag in the sample repository
- */
- public static final String v2_0_name = "v2_0";
-
- /**
- * Name of a file in the sample repository
- */
- public static final String A_txt_name = "A_txt";
-
- 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;
-
- private RevCommit A, B, C;
-
- private RevTag v1_0, v2_0;
-
- private final boolean serveHttp;
-
- public String getUri() {
- return uri;
- }
-
- /**
- * Create a bare repository, generate some sample data and start git daemon
- * on a free port
- *
- * @param n
- * hint how many random commits should be generated
- * @param
- * serveHttp
- *
- * @throws Exception
- */
- public SampleTestRepository(int n, boolean serveHttp) throws Exception {
- this.serveHttp = serveHttp;
- src = createRepository();
- generateSampleData(n);
- if (serveHttp)
- serveHttp();
- else
- serve();
- }
-
- private TestRepository<FileRepository> createRepository() throws Exception {
- String gitdirName = "test" + System.currentTimeMillis()
- + Constants.DOT_GIT;
- File gitdir = new File(trash, gitdirName).getCanonicalFile();
- FileRepository db = new FileRepository(gitdir);
- assertFalse(gitdir.exists());
- db.create();
- return new TestRepository<FileRepository>(db);
- }
-
- private void generateSampleData(int n) throws Exception {
- A_txt = src.blob("A");
- A = src.commit().add(A_txt_name, A_txt).create();
- src.update(Constants.R_HEADS + Constants.MASTER, A);
-
- // create some random commits
- RevCommit X = A;
- for (int i = 0; i < n; i++) {
- X = src.commit().parent(X)
- .add(randomAsciiString(), randomAsciiString()).create();
- }
-
- B = src.commit().parent(X).add(A_txt_name, "C").add("B", "B").create();
- src.update(Constants.R_HEADS + Constants.MASTER, B);
-
- v1_0 = src.tag(v1_0_name, B);
- src.update(Constants.R_TAGS + v1_0_name, v1_0);
-
- C = src.commit().parent(A).add(A_txt_name, "D").add("C", "C").create();
- src.update(Constants.R_HEADS + FIX, C);
-
- v2_0 = src.tag(v2_0_name, C);
- src.update(Constants.R_TAGS + v2_0_name, v2_0);
- }
-
- private String randomAsciiString() {
- StringBuilder randstring = new StringBuilder("");
- Random rand = new Random();
- int strlen = rand.nextInt(20) + 10;
- for (int i = 0, j = 0; i < strlen; i++) {
- if (rand.nextInt(2) == 1)
- j = 97;
- else
- j = 65;
- randstring.append((char) (rand.nextInt(26) + j));
- }
- return randstring.toString();
- }
-
- private void serve() throws IOException {
- d = new Daemon();
- FileResolver<DaemonClient> resolver = new FileResolver<DaemonClient>();
- resolver.exportRepository(REPO_NAME, src.getRepository());
- d.setRepositoryResolver(resolver);
- d.start();
- uri = "git://localhost:" + d.getAddress().getPort() + "/" + REPO_NAME
- + Constants.DOT_GIT_EXT;
- }
-
- 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.
+/*******************************************************************************
+ * Copyright (C) 2010, Matthias Sohn <matthias.sohn@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.assertFalse;
+
+import java.io.File;
+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;
+import org.eclipse.jgit.revwalk.RevTag;
+import org.eclipse.jgit.internal.storage.file.FileRepository;
+import org.eclipse.jgit.transport.Daemon;
+import org.eclipse.jgit.transport.DaemonClient;
+import org.eclipse.jgit.transport.resolver.FileResolver;
+import org.eclipse.jgit.util.FileUtils;
+
+/**
+ * Creates an on disk sample repository with some generated content and starts a
+ * git daemon on a free port.
+ *
+ * If the system property <code>test-repo-no-cleanup</code> is defined the
+ * source repository data will not be deleted from disk to enable testing the
+ * test.
+ */
+public class SampleTestRepository {
+ /**
+ * Name of the test repository
+ */
+ public static final String REPO_NAME = "test";
+
+ /**
+ * Name of a branch in the sample repository
+ */
+ public static final String FIX = "fix";
+
+ /**
+ * Name of a tag in the sample repository
+ */
+ public static final String v1_0_name = "v1_0";
+
+ /**
+ * Name of a tag in the sample repository
+ */
+ public static final String v2_0_name = "v2_0";
+
+ /**
+ * Name of a file in the sample repository
+ */
+ public static final String A_txt_name = "A_txt";
+
+ 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;
+
+ private RevCommit A, B, C;
+
+ private RevTag v1_0, v2_0;
+
+ private final boolean serveHttp;
+
+ public String getUri() {
+ return uri;
+ }
+
+ /**
+ * Create a bare repository, generate some sample data and start git daemon
+ * on a free port
+ *
+ * @param n
+ * hint how many random commits should be generated
+ * @param serveHttp
+ *
+ * @throws Exception
+ */
+ public SampleTestRepository(int n, boolean serveHttp) throws Exception {
+ this.serveHttp = serveHttp;
+ src = createRepository();
+ generateSampleData(n);
+ if (serveHttp)
+ serveHttp();
+ else
+ serve();
+ }
+
+ private TestRepository<FileRepository> createRepository() throws Exception {
+ String gitdirName = "test" + System.currentTimeMillis()
+ + Constants.DOT_GIT;
+ File gitdir = new File(trash, gitdirName).getCanonicalFile();
+ FileRepository db = new FileRepository(gitdir);
+ assertFalse(gitdir.exists());
+ db.create();
+ return new TestRepository<FileRepository>(db);
+ }
+
+ private void generateSampleData(int n) throws Exception {
+ A_txt = src.blob("A");
+ A = src.commit().add(A_txt_name, A_txt).create();
+ src.update(Constants.R_HEADS + Constants.MASTER, A);
+
+ // create some random commits
+ RevCommit X = A;
+ for (int i = 0; i < n; i++) {
+ X = src.commit().parent(X)
+ .add(randomAsciiString(), randomAsciiString()).create();
+ }
+
+ B = src.commit().parent(X).add(A_txt_name, "C").add("B", "B").create();
+ src.update(Constants.R_HEADS + Constants.MASTER, B);
+
+ v1_0 = src.tag(v1_0_name, B);
+ src.update(Constants.R_TAGS + v1_0_name, v1_0);
+
+ C = src.commit().parent(A).add(A_txt_name, "D").add("C", "C").create();
+ src.update(Constants.R_HEADS + FIX, C);
+
+ v2_0 = src.tag(v2_0_name, C);
+ src.update(Constants.R_TAGS + v2_0_name, v2_0);
+ }
+
+ private String randomAsciiString() {
+ StringBuilder randstring = new StringBuilder("");
+ Random rand = new Random();
+ int strlen = rand.nextInt(20) + 10;
+ for (int i = 0, j = 0; i < strlen; i++) {
+ if (rand.nextInt(2) == 1)
+ j = 97;
+ else
+ j = 65;
+ randstring.append((char) (rand.nextInt(26) + j));
+ }
+ return randstring.toString();
+ }
+
+ private void serve() throws IOException {
+ d = new Daemon();
+ FileResolver<DaemonClient> resolver = new FileResolver<DaemonClient>();
+ resolver.exportRepository(REPO_NAME, src.getRepository());
+ d.setRepositoryResolver(resolver);
+ d.start();
+ uri = "git://localhost:" + d.getAddress().getPort() + "/" + REPO_NAME
+ + Constants.DOT_GIT_EXT;
+ }
+
+ 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 Exception
- * deletion of test repository failed
- * @throws IOException
- * deletion of test repository failed
- */
- public void shutDown() throws Exception {
- src.getRepository().close();
- if (serveHttp)
- httpServer.stop();
- else
+ * @throws Exception
+ * deletion of test repository failed
+ * @throws IOException
+ * deletion of test repository failed
+ */
+ public void shutDown() throws Exception {
+ src.getRepository().close();
+ if (serveHttp)
+ httpServer.stop();
+ else
d.stop();
-
- if (!System.getProperties().contains("test-repo-no-cleanup"))
- FileUtils.delete(trash, FileUtils.RECURSIVE | FileUtils.RETRY);
- }
-
-}
+
+ if (!System.getProperties().contains("test-repo-no-cleanup"))
+ FileUtils.delete(trash, FileUtils.RECURSIVE | FileUtils.RETRY);
+ }
+
+}

Back to the top