summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit/src
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.junit/src')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java9
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java19
2 files changed, 24 insertions, 4 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
index 29579d007f..3b7cdde496 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
@@ -401,10 +401,11 @@ public abstract class LocalDiskRepositoryTestCase {
* @return the newly created repository, opened for access
* @throws IOException
* the repository could not be created in the temporary area
+ * @since 5.3
*/
- private FileRepository createRepository(boolean bare)
+ protected FileRepository createRepository(boolean bare)
throws IOException {
- return createRepository(bare, true /* auto close */);
+ return createRepository(bare, false /* auto close */);
}
/**
@@ -414,11 +415,13 @@ public abstract class LocalDiskRepositoryTestCase {
* true to create a bare repository; false to make a repository
* within its working directory
* @param autoClose
- * auto close the repository in #tearDown
+ * auto close the repository in {@link #tearDown()}
* @return the newly created repository, opened for access
* @throws IOException
* the repository could not be created in the temporary area
+ * @deprecated use {@link #createRepository(boolean)} instead
*/
+ @Deprecated
public FileRepository createRepository(boolean bare, boolean autoClose)
throws IOException {
File gitdir = createUniqueTestGitDir(bare);
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index 49a2b2010d..02ffe4f409 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -112,7 +112,7 @@ import org.eclipse.jgit.util.FileUtils;
* @param <R>
* type of Repository the test data is stored on.
*/
-public class TestRepository<R extends Repository> {
+public class TestRepository<R extends Repository> implements AutoCloseable {
/** Constant <code>AUTHOR="J. Author"</code> */
public static final String AUTHOR = "J. Author";
@@ -933,6 +933,23 @@ public class TestRepository<R extends Repository> {
}
}
+ /**
+ * Closes the underlying {@link Repository} object and any other internal
+ * resources.
+ * <p>
+ * {@link AutoCloseable} resources that may escape this object, such as
+ * those returned by the {@link #git} and {@link #getRevWalk()} methods are
+ * not closed.
+ */
+ @Override
+ public void close() {
+ try {
+ inserter.close();
+ } finally {
+ db.close();
+ }
+ }
+
private static void prunePacked(ObjectDirectory odb) throws IOException {
for (PackFile p : odb.getPacks()) {
for (MutableEntry e : p)