diff options
author | Tobias Oberlies <tobias.oberlies@sap.com> | 2015-06-16 10:14:44 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2015-06-23 14:30:18 +0200 |
commit | d34314644ef9f7d85a94737653322eafa5a8b1b0 (patch) | |
tree | a37d37c9f7cc27558a5f9f351382c8b886c7e3ff /org.eclipse.jgit.test | |
parent | d2fbbc910a8ecc6cec36354b09fc276b5a236543 (diff) | |
download | jgit-d34314644ef9f7d85a94737653322eafa5a8b1b0.tar.gz jgit-d34314644ef9f7d85a94737653322eafa5a8b1b0.zip |
API to remove repositories from RepositoryCache
Add methods that allow to unregister repositories from the
RepositoryCache individually.
Bug: 470234
Change-Id: Ib918a634d829c9898072ae7bdeb22b099a32b1c9
Signed-off-by: Tobias Oberlies <tobias.oberlies@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java | 28 |
1 files changed, 28 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 0cab987e6a..df9e0294e8 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 @@ -43,11 +43,14 @@ package org.eclipse.jgit.lib; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -59,6 +62,7 @@ import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.lib.RepositoryCache.FileKey; import org.junit.Test; +@SuppressWarnings("boxing") public class RepositoryCacheTest extends RepositoryTestCase { @Test public void testNonBareFileKey() throws IOException { @@ -147,4 +151,28 @@ public class RepositoryCacheTest extends RepositoryTestCase { d2.close(); d2.close(); } + + @Test + public void testGetRegisteredWhenEmpty() { + assertThat(RepositoryCache.getRegisteredKeys().size(), is(0)); + } + + @Test + public void testGetRegistered() { + RepositoryCache.register(db); + + assertThat(RepositoryCache.getRegisteredKeys(), + hasItem(FileKey.exact(db.getDirectory(), db.getFS()))); + assertThat(RepositoryCache.getRegisteredKeys().size(), is(1)); + } + + @Test + public void testUnregister() { + RepositoryCache.register(db); + RepositoryCache + .unregister(FileKey.exact(db.getDirectory(), db.getFS())); + + assertThat(RepositoryCache.getRegisteredKeys().size(), is(0)); + } + } |