Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2016-02-15 08:41:05 +0000
committerDavid Pursehouse2016-02-15 09:04:07 +0000
commit8deff4b969653379c9a51d952d8c2cadae394934 (patch)
tree899f83b15d8c14e73f96bb6c111b9d84273f1ee2
parentf595089be04f8357495c25c7ee336198caa7dcd7 (diff)
downloadjgit-8deff4b969653379c9a51d952d8c2cadae394934.tar.gz
jgit-8deff4b969653379c9a51d952d8c2cadae394934.tar.xz
jgit-8deff4b969653379c9a51d952d8c2cadae394934.zip
HugeFileTest: Make Git a class member and open in try-with-resource
There's only one test method in this module and it's quite long, so rather than using a try-with-resource and having to indent a huge block of existing code, make the Git a member variable that gets initialised and closed in @Before and @After annotated methods. The methods are named 'before' and 'after' rather than the conventional 'setUp' and 'tearDown' so as not to conflict with the names of the existing methods in LocalDiskRepositoryTestCase. Change-Id: I5a4a9b59f244c450dbcae9fdde7d9e0f0cd24e6f Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/HugeFileTest.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/HugeFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/HugeFileTest.java
index 5449d02a08..4208f4d8e3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/HugeFileTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/HugeFileTest.java
@@ -51,6 +51,8 @@ import java.util.Collection;
import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.junit.RepositoryTestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -60,12 +62,26 @@ public class HugeFileTest extends RepositoryTestCase {
private long lastt = t;
+ private Git git;
+
private void measure(String name) {
long c = System.currentTimeMillis();
System.out.println(name + ", dt=" + (c - lastt) / 1000.0 + "s");
lastt = c;
}
+ @Before
+ public void before() {
+ git = new Git(db);
+ }
+
+ @After
+ public void after() {
+ if (git != null) {
+ git.close();
+ }
+ }
+
@Ignore("Test takes way too long (~10 minutes) to be part of the standard suite")
@Test
public void testAddHugeFile() throws Exception {
@@ -75,7 +91,6 @@ public class HugeFileTest extends RepositoryTestCase {
rf.setLength(4429185024L);
rf.close();
measure("Created file");
- Git git = new Git(db);
git.add().addFilepattern("a.txt").call();
measure("Added file");

Back to the top