summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java
index 6bea320120..b44b4c34a7 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java
@@ -210,6 +210,27 @@ public class RepositoryCacheTest extends RepositoryTestCase {
}
@Test
+ public void testRepositoryUnregisteringWhenExpiredAndUsageCountNegative()
+ throws Exception {
+ Repository repoA = createBareRepository();
+ RepositoryCache.register(repoA);
+
+ assertEquals(1, RepositoryCache.getRegisteredKeys().size());
+ assertTrue(RepositoryCache.isCached(repoA));
+
+ // close the repo twice to make usage count negative
+ repoA.close();
+ repoA.close();
+ // fake that repoA was closed more than 1 hour ago (default expiration
+ // time)
+ repoA.closedAt.set(System.currentTimeMillis() - 65 * 60 * 1000);
+
+ RepositoryCache.clearExpired();
+
+ assertEquals(0, RepositoryCache.getRegisteredKeys().size());
+ }
+
+ @Test
public void testRepositoryUnregisteringWhenExpired() throws Exception {
Repository repoA = createBareRepository();
Repository repoB = createBareRepository();