Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java22
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java36
2 files changed, 37 insertions, 21 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
index 904333aa0..80f0fd1f5 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
@@ -15,6 +15,7 @@ import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.eclipse.jgit.lib.Constants.HEAD;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -33,6 +34,7 @@ import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet;
import org.eclipse.egit.core.test.GitTestCase;
import org.eclipse.egit.core.test.TestRepository;
+import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -57,6 +59,10 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
testRepo = new TestRepository(gitDir);
testRepo.connect(iProject);
repo = RepositoryMapping.getMapping(iProject).getRepository();
+
+ // make initial commit
+ new Git(repo).commit().setAuthor("JUnit", "junit@jgit.org")
+ .setMessage("Initall commit").call();
}
@After
@@ -172,11 +178,11 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
+ "keep");
RevCommit commit = testRepo.addAndCommit(iProject, file,
"initial commit");
- String path = Repository.stripWorkDir(repo.getWorkTree(), file.getParentFile());
+ String path = Repository.stripWorkDir(repo.getWorkTree(), file);
IPath iPath = new Path(File.separator + path);
IContainer local = createMock(IContainer.class);
- expect(local.exists()).andReturn(true).anyTimes();
+ expect(local.exists()).andReturn(true);
expect(local.getFullPath()).andReturn(iPath).anyTimes();
replay(local);
@@ -201,7 +207,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
// when
byte[] shortContent = "short content".getBytes();
byte[] longContent = "very long long content".getBytes();
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
@@ -243,7 +249,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
byte[] localContent = "very long long content".getBytes();
// this typo should be here
byte[] remoteContent = "very long lonk content".getBytes();
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
@@ -287,7 +293,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
byte[] remoteContent = new byte[8192];
Arrays.fill(remoteContent, (byte) 'a');
remoteContent[8101] = 'b';
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
@@ -335,7 +341,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
Arrays.fill(localContent, (byte) 'a');
byte[] remoteContent = new byte[8200];
Arrays.fill(remoteContent, (byte) 'a');
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
@@ -376,7 +382,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
// when
byte[] localContent = "very long long content".getBytes();
byte[] remoteContent = "very long long content".getBytes();
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
@@ -420,7 +426,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
Arrays.fill(localContent, (byte) 'a');
byte[] remoteContent = new byte[8192];
Arrays.fill(remoteContent, (byte) 'a');
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", true);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, true);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
GitResourceVariantComparator grvc = new GitResourceVariantComparator(
dataSet);
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 073117a80..3ca306c1b 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
@@ -8,6 +8,8 @@
*******************************************************************************/
package org.eclipse.egit.core.synchronize;
+import static org.eclipse.jgit.lib.Constants.HEAD;
+import static org.eclipse.jgit.lib.Constants.MASTER;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -16,7 +18,6 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
@@ -33,6 +34,7 @@ import org.eclipse.egit.core.test.TestProject;
import org.eclipse.egit.core.test.TestRepository;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.team.core.variants.IResourceVariant;
@@ -72,12 +74,14 @@ public class GitResourceVariantTreeTest extends GitTestCase {
* given repository. In this case there is only one project associated with
* this repository therefore only one root should be returned.
*
- * @throws IOException
+ * @throws Exception
*/
@Test
- public void shouldReturnOneRoot() throws IOException {
+ public void shouldReturnOneRoot() throws Exception {
// when
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", false);
+ new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given
@@ -105,7 +109,9 @@ public class GitResourceVariantTreeTest extends GitTestCase {
IProject secondIProject = secondProject.project;
// add connect project with repository
new ConnectProviderOperation(secondIProject, gitDir).execute(null);
- GitSynchronizeData data = new GitSynchronizeData(repo, "", "", false);
+ new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD, false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given
@@ -130,8 +136,10 @@ public class GitResourceVariantTreeTest extends GitTestCase {
@Test
public void shouldReturnNullResourceVariant() throws Exception {
// when
- GitSynchronizeData data = new GitSynchronizeData(repo, Constants.HEAD,
- Constants.MASTER, false);
+ new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER,
+ false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given
@@ -153,8 +161,10 @@ public class GitResourceVariantTreeTest extends GitTestCase {
IPackageFragment iPackage = project.createPackage("org.egit.test");
IType mainJava = project.createType(iPackage, "Main.java",
"class Main {}");
- GitSynchronizeData data = new GitSynchronizeData(repo, Constants.HEAD,
- Constants.MASTER, false);
+ new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
+ .setMessage("Initial commit").call();
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER,
+ false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given
@@ -179,8 +189,8 @@ public class GitResourceVariantTreeTest extends GitTestCase {
testRepo.appendContentAndCommit(iProject, file, "class Main {}",
"initial commit");
IFile mainJava = testRepo.getIFile(iProject, file);
- GitSynchronizeData data = new GitSynchronizeData(repo, Constants.HEAD,
- Constants.MASTER, false);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER,
+ false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given
@@ -221,8 +231,8 @@ public class GitResourceVariantTreeTest extends GitTestCase {
Constants.R_HEADS + "test");
testRepo.appendContentAndCommit(iProject, file, "// test",
"first commit");
- GitSynchronizeData data = new GitSynchronizeData(repo, Constants.HEAD,
- Constants.MASTER, false);
+ GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER,
+ false);
GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);
// given

Back to the top