Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Kinzler2010-08-10 05:49:59 -0400
committerCode Review2010-08-10 05:49:59 -0400
commit0279ff29012404cc904de89df6b94ffff6300c04 (patch)
tree70bfe8620f2e604305dea6b834c125b7ead54e0d /org.eclipse.egit.core.test
parentc4c4e797dca3ddefdc562ab471d7142b0b79bcfb (diff)
parentc4e85d9fe3b30c7e033a30406f026df96757bad8 (diff)
downloadegit-0279ff29012404cc904de89df6b94ffff6300c04.tar.gz
egit-0279ff29012404cc904de89df6b94ffff6300c04.tar.xz
egit-0279ff29012404cc904de89df6b94ffff6300c04.zip
Merge "Fixed several warnings around ConnectProviderOperation"
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java13
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java27
2 files changed, 11 insertions, 29 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java
index ac971b273..a6ceca2a7 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java
@@ -18,7 +18,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.lib.ObjectWriter;
+import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.SystemReader;
@@ -57,8 +57,15 @@ public abstract class GitTestCase {
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(content);
fileWriter.close();
- ObjectWriter objectWriter = new ObjectWriter(repository);
- return objectWriter.writeBlob(file);
+ byte[] fileContents = IO.readFully(file);
+ ObjectInserter inserter = repository.newObjectInserter();
+ try {
+ ObjectId objectId = inserter.insert(Constants.OBJ_BLOB, fileContents);
+ inserter.flush();
+ return objectId;
+ } finally {
+ inserter.release();
+ }
}
protected ObjectId createFileCorruptShort(Repository repository, IProject actProject, String name, String content) throws IOException {
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
index ecb2022b3..42ec2e403 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
@@ -22,9 +22,6 @@ import java.util.TimeZone;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.core.op.ConnectProviderOperation;
import org.eclipse.egit.core.test.GitTestCase;
import org.eclipse.jgit.lib.Commit;
@@ -56,8 +53,6 @@ public class ConnectProviderOperationTest extends GitTestCase {
@Test
public void testNewRepository() throws CoreException, IOException {
- File gitDir = new File(project.getProject().getWorkspace().getRoot()
- .getRawLocation().toFile(), Constants.DOT_GIT);
Repository repository = new FileRepository(gitDir);
repository.create();
repository.close();
@@ -71,16 +66,13 @@ public class ConnectProviderOperationTest extends GitTestCase {
}
@Test
- public void testNewUnsharedFile() throws CoreException, IOException,
- InterruptedException {
+ public void testNewUnsharedFile() throws CoreException, IOException {
project.createSourceFolder();
IFile fileA = project.getProject().getFolder("src").getFile("A.java");
String srcA = "class A {\n" + "}\n";
fileA.create(new ByteArrayInputStream(srcA.getBytes()), false, null);
- File gitDir = new File(project.getProject().getWorkspace().getRoot()
- .getRawLocation().toFile(), Constants.DOT_GIT);
Repository thisGit = new FileRepository(gitDir);
thisGit.create();
Tree rootTree = new Tree(thisGit);
@@ -108,23 +100,6 @@ public class ConnectProviderOperationTest extends GitTestCase {
project.getProject(), gitDir);
operation.execute(null);
- final boolean f[] = new boolean[1];
- new Job("wait") {
- protected IStatus run(IProgressMonitor monitor) {
-
- f[0] = true;
- return null;
- }
-
- {
- setRule(project.getProject());
- schedule();
- }
- };
- while (!f[0]) {
- Thread.sleep(1000);
- }
-
assertNotNull(RepositoryProvider.getProvider(project.getProject()));
}

Back to the top