Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2015-06-30 17:50:59 +0000
committerAndrey Loskutov2015-06-30 17:50:59 +0000
commit33aced3eb636f56472c9d5514757b1aebffe2f28 (patch)
tree6e092fb50a12b63fd2c2aba822c66c148fe392c9 /org.eclipse.egit.ui.test
parent2be71f7d17c26ef3be540a1b0da3e2c793b20b13 (diff)
downloadegit-33aced3eb636f56472c9d5514757b1aebffe2f28.tar.gz
egit-33aced3eb636f56472c9d5514757b1aebffe2f28.tar.xz
egit-33aced3eb636f56472c9d5514757b1aebffe2f28.zip
Test stability: missing RepositoryMapping
Trying to fix instabilities in recently failed unstable CommitActionTest.testOpenCommitWithoutChanged test, where the RepositoryMapping was not found for just created projects. Change-Id: I14b8b1a45d9032068f265c87dfc6983034f06483 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui.test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java42
1 files changed, 40 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
index 090b879702..9c0c1c38a2 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
@@ -11,6 +11,7 @@
package org.eclipse.egit.ui.common;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
@@ -32,6 +33,7 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.GitCorePreferences;
+import org.eclipse.egit.core.GitProvider;
import org.eclipse.egit.core.JobFamilies;
import org.eclipse.egit.core.RepositoryCache;
import org.eclipse.egit.core.internal.indexdiff.IndexDiffCache;
@@ -40,6 +42,8 @@ import org.eclipse.egit.core.op.CloneOperation;
import org.eclipse.egit.core.op.CommitOperation;
import org.eclipse.egit.core.op.ConnectProviderOperation;
import org.eclipse.egit.core.op.ListRemoteOperation;
+import org.eclipse.egit.core.project.GitProjectData;
+import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.core.test.TestUtils;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.push.PushOperationUI;
@@ -63,6 +67,7 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.team.core.RepositoryProvider;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -249,6 +254,9 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
firstProject.open(null);
TestUtil.waitForJobs(50, 5000);
+ assertTrue("Project is not accessible: " + firstProject,
+ firstProject.isAccessible());
+
IFolder folder = firstProject.getFolder(FOLDER);
folder.create(false, true, null);
IFile textFile = folder.getFile(FILE1);
@@ -259,6 +267,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
.getBytes(firstProject.getDefaultCharset())), false, null);
new ConnectProviderOperation(firstProject, gitDir).execute(null);
+ assertConnected(firstProject);
IProject secondProject = ResourcesPlugin.getWorkspace().getRoot()
.getProject(PROJ2);
@@ -291,9 +300,13 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
// .getBytes(firstProject.getDefaultCharset())), false, null);
new ConnectProviderOperation(secondProject, gitDir).execute(null);
- TestUtil.waitForJobs(50, 1000);
+ assertConnected(secondProject);
+
+ IFile dotProject = firstProject.getFile(".project");
+ assertTrue(".project is not accessible: " + dotProject,
+ dotProject.isAccessible());
- IFile[] commitables = new IFile[] { firstProject.getFile(".project"),
+ IFile[] commitables = new IFile[] { dotProject,
textFile, textFile2, secondtextFile, secondtextFile2 };
ArrayList<IFile> untracked = new ArrayList<IFile>();
untracked.addAll(Arrays.asList(commitables));
@@ -315,6 +328,30 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
return gitDir;
}
+ private void assertConnected(IProject project) {
+ RepositoryProvider provider = RepositoryProvider.getProvider(project,
+ GitProvider.ID);
+ if (provider == null) {
+ TestUtil.waitForJobs(100, 5000);
+ provider = RepositoryProvider.getProvider(project, GitProvider.ID);
+ }
+ assertNotNull("GitProvider not mapped to: " + project, provider);
+
+ GitProjectData data = ((GitProvider) provider).getData();
+ if (data == null) {
+ TestUtil.waitForJobs(100, 5000);
+ data = ((GitProvider) provider).getData();
+ }
+ assertNotNull("GitProjectData is null for: " + project, data);
+
+ RepositoryMapping mapping = data.getRepositoryMapping(project);
+ if (mapping == null) {
+ TestUtil.waitForJobs(100, 5000);
+ mapping = data.getRepositoryMapping(project);
+ }
+ assertNotNull("RepositoryMapping is null for: " + project, mapping);
+ }
+
protected File createRemoteRepository(File repositoryDir)
throws Exception {
Repository myRepository = lookupRepository(repositoryDir);
@@ -447,6 +484,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
new ConnectProviderOperation(prj, myRepository
.getDirectory()).execute(null);
+ assertConnected(prj);
}
}
}

Back to the top