@ -43,11 +43,14 @@
package org.eclipse.jgit.lib ;
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.assertEquals ;
import static org.junit.Assert.assertFalse ;
import static org.junit.Assert.assertFalse ;
import static org.junit.Assert.assertNotNull ;
import static org.junit.Assert.assertNotNull ;
import static org.junit.Assert.assertNotSame ;
import static org.junit.Assert.assertNotSame ;
import static org.junit.Assert.assertSame ;
import static org.junit.Assert.assertSame ;
import static org.junit.Assert.assertThat ;
import static org.junit.Assert.assertTrue ;
import static org.junit.Assert.assertTrue ;
import static org.junit.Assert.fail ;
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.eclipse.jgit.lib.RepositoryCache.FileKey ;
import org.junit.Test ;
import org.junit.Test ;
@SuppressWarnings ( "boxing" )
public class RepositoryCacheTest extends RepositoryTestCase {
public class RepositoryCacheTest extends RepositoryTestCase {
@Test
@Test
public void testNonBareFileKey ( ) throws IOException {
public void testNonBareFileKey ( ) throws IOException {
@ -147,4 +151,28 @@ public class RepositoryCacheTest extends RepositoryTestCase {
d2 . close ( ) ;
d2 . close ( ) ;
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 ) ) ;
}
}
}