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>
This commit is contained in:
parent
f595089be0
commit
8deff4b969
|
@ -51,6 +51,8 @@
|
|||
|
||||
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 void testAddHugeFile() throws Exception {
|
|||
rf.setLength(4429185024L);
|
||||
rf.close();
|
||||
measure("Created file");
|
||||
Git git = new Git(db);
|
||||
|
||||
git.add().addFilepattern("a.txt").call();
|
||||
measure("Added file");
|
||||
|
|
Loading…
Reference in New Issue