Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Muskalla2010-07-09 08:36:55 +0000
committerMathias Kinzler2010-07-09 08:36:55 +0000
commitcd174b3e7f75779675d0a9694a20b8088aa6842b (patch)
tree5830ea3d7a183affa7459832ffb60e3f1ce3d3d8
parent51fd44fb1cf0d7d5ec4a5660e79d11db44feacc6 (diff)
downloadegit-cd174b3e7f75779675d0a9694a20b8088aa6842b.tar.gz
egit-cd174b3e7f75779675d0a9694a20b8088aa6842b.tar.xz
egit-cd174b3e7f75779675d0a9694a20b8088aa6842b.zip
Stabilize Core Tests
There are currently failures when the test workspace is not cleared. In the TrackUntrackOperation test, apparently, the check whether a file is "tracked" was too simplistic. Other fixes were required because resources were not handled properly. With these fixes, it is possible to run the tests without clearing the test workspace. The fixes have successfully been tested on Helios, too. Bug: 318444 Change-Id: I31cbbb63b5aa345d3f4afdea1078640973bbbbac Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java2
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java9
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java55
3 files changed, 48 insertions, 18 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
index 14c3a93771..68e18ad0a6 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
@@ -109,7 +109,7 @@ public class GitResourceVariantTreeTest extends GitTestCase {
public void shouldReturnTwoRoots() throws Exception {
// when
// create second project
- TestProject secondProject = new TestProject(false, "Project-2");
+ TestProject secondProject = new TestProject(true, "Project-2");
IProject secondIProject = secondProject.project;
// add connect project with repository
new ConnectProviderOperation(secondIProject, gitDir).execute(null);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java
index 3d3e1f59c6..d9e66590ad 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java
@@ -151,8 +151,13 @@ public class TestUtils {
String projectName) throws Exception {
IProject firstProject = ResourcesPlugin.getWorkspace().getRoot()
.getProject(projectName);
- if (firstProject.exists())
- firstProject.delete(false, null);
+ if (firstProject.exists()) {
+ firstProject.delete(true, null);
+ }
+ File testFile = new File(parentFile, projectName);
+ if (testFile.exists())
+ deleteRecursive(testFile);
+
IProjectDescription desc = ResourcesPlugin.getWorkspace()
.newProjectDescription(projectName);
desc.setLocation(new Path(new File(parentFile, projectName).getPath()));
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java
index ce6635f2f3..7112ddb7a6 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java
@@ -8,9 +8,10 @@
*******************************************************************************/
package org.eclipse.egit.core.test.op;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -23,6 +24,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.egit.core.op.TrackOperation;
import org.eclipse.egit.core.op.UntrackOperation;
+import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.core.test.DualRepositoryTestCase;
import org.eclipse.egit.core.test.TestRepository;
import org.eclipse.jgit.dircache.DirCache;
@@ -68,9 +70,6 @@ public class TrackUntrackOperationTest extends DualRepositoryTestCase {
final ArrayList<IFile> files = new ArrayList<IFile>();
- DirCache cache = DirCache.read(repository1.getRepository());
- assertEquals("Wrong cache entry count", 0, cache.getEntryCount());
-
project.accept(new IResourceVisitor() {
public boolean visit(IResource resource) throws CoreException {
@@ -82,18 +81,29 @@ public class TrackUntrackOperationTest extends DualRepositoryTestCase {
IFile[] fileArr = files.toArray(new IFile[files.size()]);
+ assertTrackedState(fileArr, false);
+
TrackOperation trop = new TrackOperation(fileArr);
trop.execute(new NullProgressMonitor());
- cache.read();
- assertEquals("Wrong cache entry count", 2, cache.getEntryCount());
+ assertTrackedState(fileArr, true);
UntrackOperation utop = new UntrackOperation(Arrays.asList(fileArr));
+
utop.execute(new NullProgressMonitor());
- cache.read();
- assertEquals("Wrong cache entry count", 0, cache.getEntryCount());
+ assertTrackedState(fileArr, false);
+ }
+ private void assertTrackedState(IFile[] fileArr, boolean expectedState)
+ throws IOException {
+ DirCache cache = DirCache.read(repository1.getRepository());
+ for (IFile file : fileArr) {
+ RepositoryMapping rm = RepositoryMapping.getMapping(file);
+ String fileDir = rm.getRepoRelativePath(file);
+ boolean tracked = cache.findEntry(fileDir) > -1;
+ assertTrue("Wrong tracking state", tracked == expectedState);
+ }
}
@Test
@@ -102,18 +112,33 @@ public class TrackUntrackOperationTest extends DualRepositoryTestCase {
final ArrayList<IContainer> containers = new ArrayList<IContainer>();
containers.add(project);
- DirCache cache = DirCache.read(repository1.getRepository());
+ IContainer[] projectArr = containers.toArray(new IContainer[containers
+ .size()]);
- assertEquals("Wrong cache entry count", 0, cache.getEntryCount());
+ final ArrayList<IFile> files = new ArrayList<IFile>();
- IContainer[] fileArr = containers.toArray(new IContainer[containers
- .size()]);
+ project.accept(new IResourceVisitor() {
- TrackOperation trop = new TrackOperation(fileArr);
+ public boolean visit(IResource resource) throws CoreException {
+ if (resource instanceof IFile)
+ files.add((IFile) resource);
+ return true;
+ }
+ });
+
+ IFile[] fileArr = files.toArray(new IFile[files.size()]);
+
+ assertTrackedState(fileArr, false);
+
+ TrackOperation trop = new TrackOperation(projectArr);
trop.execute(new NullProgressMonitor());
- cache.read();
- assertEquals("Wrong cache entry count", 2, cache.getEntryCount());
+ assertTrackedState(fileArr, true);
+
+ UntrackOperation utrop = new UntrackOperation(containers);
+ utrop.execute(new NullProgressMonitor());
+
+ assertTrackedState(fileArr, false);
}
}

Back to the top