Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.gitflow.ui/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.egit.ui.test/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java54
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureRebaseHandlerTest.java96
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java121
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/InitHandlerTest.java45
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java36
7 files changed, 353 insertions, 7 deletions
diff --git a/org.eclipse.egit.gitflow.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.gitflow.ui/META-INF/MANIFEST.MF
index 03ee369a1..c20a0d80b 100644
--- a/org.eclipse.egit.gitflow.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.gitflow.ui/META-INF/MANIFEST.MF
@@ -34,3 +34,6 @@ Require-Bundle: org.eclipse.core.jobs;bundle-version="[3.4.0,4.0.0)",
org.eclipse.team.ui;bundle-version="[3.4.0,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.4.0,4.0.0)"
+Export-Package: org.eclipse.egit.gitflow.ui;version="4.1.0";x-friends:="org.eclipse.egit.ui.test",
+ org.eclipse.egit.gitflow.ui.internal;version="4.1.0";x-friends:="org.eclipse.egit.ui.test",
+ org.eclipse.egit.gitflow.ui.internal.actions;version="4.1.0";x-friends:="org.eclipse.egit.ui.test"
diff --git a/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF b/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
index 2e4e776b7..e728da89d 100644
--- a/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
@@ -16,6 +16,11 @@ Require-Bundle: org.apache.log4j;bundle-version="[1.0.0,2.0.0)",
org.hamcrest;bundle-version="[1.1.0,2.0.0)",
org.mockito;bundle-version="[1.8.0,1.9.0)"
Import-Package: org.eclipse.egit.core.test;version="[4.1.0,4.2.0)",
+ org.eclipse.egit.gitflow;version="[4.1.0,4.2.0)",
+ org.eclipse.egit.gitflow.op;version="[4.1.0,4.2.0)",
+ org.eclipse.egit.gitflow.ui;version="[4.1.0,4.2.0)",
+ org.eclipse.egit.gitflow.ui.internal;version="[4.1.0,4.2.0)",
+ org.eclipse.egit.gitflow.ui.internal.actions;version="[4.1.0,4.2.0)",
org.eclipse.jgit.api;version="[4.1.0,4.2.0)",
org.eclipse.jgit.api.errors;version="[4.1.0,4.2.0)",
org.eclipse.jgit.junit;version="[4.1.0,4.2.0)",
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java
new file mode 100644
index 000000000..4b5257a92
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (C) 2015, Max Hohenegger <eclipse@hohenegger.eu>
+ *
+ * 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.gitflow;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.AbortedByHookException;
+import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.api.errors.NoHeadException;
+import org.eclipse.jgit.api.errors.NoMessageException;
+import org.eclipse.jgit.api.errors.UnmergedPathsException;
+import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for the Team->Gitflow
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public abstract class AbstractGitflowHandlerTest extends LocalRepositoryTestCase {
+ protected static final String DEVELOP = "develop";
+ protected static final String FEATURE_NAME = "myFeature";
+
+ protected Repository repository;
+
+ @Before
+ public void setup() throws Exception {
+ File repositoryFile = createProjectAndCommitToRepository();
+ repository = lookupRepository(repositoryFile);
+ }
+
+ protected RevCommit setContentAddAndCommit(String newContent) throws Exception, GitAPIException, NoHeadException,
+ NoMessageException, UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException,
+ AbortedByHookException, IOException {
+ setTestFileContent(newContent);
+
+ Git git = Git.wrap(repository);
+ git.add().addFilepattern(".").call();
+ return git.commit().setMessage(newContent).call();
+ }
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureRebaseHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureRebaseHandlerTest.java
new file mode 100644
index 000000000..b03ba8c88
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureRebaseHandlerTest.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (C) 2015, Max Hohenegger <eclipse@hohenegger.eu>
+ *
+ * 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.gitflow;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.egit.core.op.BranchOperation;
+import org.eclipse.egit.gitflow.GitFlowRepository;
+import org.eclipse.egit.gitflow.op.FeatureCheckoutOperation;
+import org.eclipse.egit.gitflow.op.FeatureStartOperation;
+import org.eclipse.egit.gitflow.op.InitOperation;
+import org.eclipse.egit.gitflow.ui.Activator;
+import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
+import org.eclipse.egit.ui.test.ContextMenuHelper;
+import org.eclipse.egit.ui.test.TestUtil;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.ui.PlatformUI;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for the Team->Gitflow->Rebase Feature actions
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class FeatureRebaseHandlerTest extends AbstractGitflowHandlerTest {
+
+ @Test
+ public void testRebase() throws Exception {
+ Git git = Git.wrap(repository);
+
+ init();
+
+ createFeature(FEATURE_NAME);
+ setContentAddAndCommit("foo");
+
+ checkoutBranch(DEVELOP);
+ setContentAddAndCommit("bar");
+
+ checkoutFeature(FEATURE_NAME);
+
+ rebaseFeature();
+
+ Status call = git.status().call();
+ Object[] conflicting = call.getConflicting().toArray();
+ assertEquals(1, conflicting.length);
+ assertEquals(FILE1_PATH, conflicting[0]);
+
+ assertEquals("org.eclipse.egit.ui.InteractiveRebaseView", bot.activeView().getReference().getId());
+ }
+
+ private void init() throws CoreException {
+ new InitOperation(repository).execute(null);
+ }
+
+ private void createFeature(String featureName) throws CoreException {
+ new FeatureStartOperation(new GitFlowRepository(repository),
+ featureName).execute(null);
+ }
+
+ private void checkoutFeature(String featureName) throws CoreException {
+ new FeatureCheckoutOperation(new GitFlowRepository(repository), featureName).execute(null);
+ }
+
+ private void checkoutBranch(String branchToCheckout) throws CoreException {
+ new BranchOperation(repository, branchToCheckout).execute(null);
+ }
+
+ private void rebaseFeature() {
+ final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ getProjectItem(projectExplorerTree, PROJ1).select();
+ final String[] menuPath = new String[] {
+ util.getPluginLocalizedValue("TeamMenu.label"),
+ util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
+ util.getPluginLocalizedValue("TeamGitFlowFeatureRebase.name", false, Activator.getDefault().getBundle()) };
+
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
+ }
+ });
+ bot.button().click();
+ bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
+ }
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java
new file mode 100644
index 000000000..c3465fc7e
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (C) 2015, Max Hohenegger <eclipse@hohenegger.eu>
+ *
+ * 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.gitflow;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.egit.core.op.BranchOperation;
+import org.eclipse.egit.gitflow.GitFlowRepository;
+import org.eclipse.egit.gitflow.op.InitOperation;
+import org.eclipse.egit.gitflow.ui.Activator;
+import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
+import org.eclipse.egit.gitflow.ui.internal.UIText;
+import org.eclipse.egit.ui.test.ContextMenuHelper;
+import org.eclipse.egit.ui.test.TestUtil;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
+import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.ui.PlatformUI;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for the Team->Gitflow->Feature Start/Finish actions
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class FeatureStartFinishHandlerTest extends AbstractGitflowHandlerTest {
+
+ @Test
+ public void testFeatureStart() throws Exception {
+ init();
+
+ setContentAddAndCommit("bar");
+
+ createFeature(FEATURE_NAME);
+ RevCommit featureBranchCommit = setContentAddAndCommit("foo");
+
+ checkoutBranch(DEVELOP);
+
+ checkoutFeature(FEATURE_NAME);
+
+ finishFeature();
+
+ RevCommit developHead = new GitFlowRepository(repository).findHead();
+ assertEquals(developHead, featureBranchCommit);
+ }
+
+ private void finishFeature() {
+ final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ getProjectItem(projectExplorerTree, PROJ1).select();
+ final String[] menuPath = new String[] {
+ util.getPluginLocalizedValue("TeamMenu.label"),
+ util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
+ util.getPluginLocalizedValue("TeamGitFlowFeatureFinish.name", false, Activator.getDefault().getBundle()) };
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
+ }
+ });
+ bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
+ }
+
+ private void init() throws CoreException {
+ new InitOperation(repository).execute(null);
+ }
+
+ private void createFeature(String featureName) {
+ final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ getProjectItem(projectExplorerTree, PROJ1).select();
+ final String[] menuPath = new String[] {
+ util.getPluginLocalizedValue("TeamMenu.label"),
+ util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
+ util.getPluginLocalizedValue("TeamGitFlowFeatureStart.name", false, Activator.getDefault().getBundle()) };
+
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
+ }
+ });
+
+ bot.waitUntil(shellIsActive(UIText.FeatureStartHandler_provideFeatureName));
+ bot.text().typeText(featureName);
+ bot.button("OK").click();
+ bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
+ }
+
+ private void checkoutFeature(String featureName) {
+ final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ getProjectItem(projectExplorerTree, PROJ1).select();
+ final String[] menuPath = new String[] {
+ util.getPluginLocalizedValue("TeamMenu.label"),
+ util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
+ util.getPluginLocalizedValue("TeamGitFlowFeatureCheckout.name", false, Activator.getDefault().getBundle()) };
+
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
+ }
+ });
+
+ bot.waitUntil(shellIsActive(UIText.FeatureCheckoutHandler_selectFeature));
+ bot.table().select(featureName);
+ bot.button("OK").click();
+ bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
+ }
+
+ private void checkoutBranch(String branchToCheckout) throws CoreException {
+ new BranchOperation(repository, branchToCheckout).execute(null);
+ }
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/InitHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/InitHandlerTest.java
new file mode 100644
index 000000000..1fff621bc
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/InitHandlerTest.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (C) 2015, Max Hohenegger <eclipse@hohenegger.eu>
+ *
+ * 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.gitflow;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.egit.gitflow.ui.Activator;
+import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
+import org.eclipse.egit.ui.test.ContextMenuHelper;
+import org.eclipse.egit.ui.test.TestUtil;
+import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for the Team->Gitflow init
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class InitHandlerTest extends AbstractGitflowHandlerTest {
+
+ @Test
+ public void testInit() throws Exception {
+ init();
+
+ assertEquals(DEVELOP, repository.getBranch());
+ }
+
+ private void init() {
+ SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ getProjectItem(projectExplorerTree, PROJ1).select();
+ String[] menuPath = new String[] {
+ util.getPluginLocalizedValue("TeamMenu.label"),
+ util.getPluginLocalizedValue("TeamGitFlowInit.name", false, Activator.getDefault().getBundle()) };
+ ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
+ bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
+ }
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
index fa28ef2ea..2b48f13bc 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
@@ -71,6 +72,7 @@ import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
@@ -90,7 +92,7 @@ public class TestUtil {
private final static char AMPERSAND = '&';
- private ResourceBundle myBundle;
+ private Map<Bundle, ResourceBundle> bundle2ResourceBundle = new HashMap<>();
/**
* Allows access to the localized values of the EGit UI Plug-in
@@ -126,10 +128,28 @@ public class TestUtil {
*/
public synchronized String getPluginLocalizedValue(String key,
boolean keepAmpersands) throws MissingResourceException {
- if (myBundle == null) {
+ return getPluginLocalizedValue(key, keepAmpersands, Activator.getDefault().getBundle());
+ }
- BundleContext context = Activator.getDefault().getBundle()
- .getBundleContext();
+ /**
+ * Allows access to the localized values of the given Bundle
+ * <p>
+ *
+ * @param key
+ * see {@link #getPluginLocalizedValue(String)}
+ * @param keepAmpersands
+ * if <code>true</code>, ampersands will be kept
+ * @param bundle
+ * the Bundle that contains the localization
+ * @return see {@link #getPluginLocalizedValue(String)}
+ * @throws MissingResourceException
+ * see {@link #getPluginLocalizedValue(String)}
+ */
+ public synchronized String getPluginLocalizedValue(String key,
+ boolean keepAmpersands, Bundle bundle) throws MissingResourceException {
+ ResourceBundle myBundle = bundle2ResourceBundle.get(bundle);
+ if (myBundle == null) {
+ BundleContext context = bundle.getBundleContext();
ServiceTracker<BundleLocalization, BundleLocalization> localizationTracker =
new ServiceTracker<BundleLocalization, BundleLocalization>(
@@ -137,9 +157,11 @@ public class TestUtil {
localizationTracker.open();
BundleLocalization location = localizationTracker.getService();
- if (location != null)
- myBundle = location.getLocalization(Activator.getDefault()
- .getBundle(), Locale.getDefault().toString());
+ if (location != null) {
+ myBundle = location.getLocalization(bundle, Locale.getDefault().toString());
+ bundle2ResourceBundle.put(bundle, myBundle);
+ }
+
}
if (myBundle != null) {
String raw = myBundle.getString(key);

Back to the top