@ -109,7 +109,7 @@ public class RepositoryCacheTest extends RepositoryTestCase {
@Test
@Test
public void testFileKeyOpenNew ( ) throws IOException {
public void testFileKeyOpenNew ( ) throws IOException {
final Repository n = createBare Repository ( ) ;
final Repository n = createRepository ( true , false ) ;
final File gitdir = n . getDirectory ( ) ;
final File gitdir = n . getDirectory ( ) ;
n . close ( ) ;
n . close ( ) ;
recursiveDelete ( gitdir ) ;
recursiveDelete ( gitdir ) ;
@ -187,12 +187,14 @@ public class RepositoryCacheTest extends RepositoryTestCase {
}
}
@Test
@Test
public void testRepositoryUsageCountWithRegisteredRepository ( ) {
public void testRepositoryUsageCountWithRegisteredRepository ( )
assertEquals ( 1 , ( ( Repository ) db ) . useCnt . get ( ) ) ;
throws IOException {
RepositoryCache . register ( db ) ;
Repository repo = createRepository ( false , false ) ;
assertEquals ( 1 , ( ( Repository ) db ) . useCnt . get ( ) ) ;
assertEquals ( 1 , repo . useCnt . get ( ) ) ;
db . close ( ) ;
RepositoryCache . register ( repo ) ;
assertEquals ( 0 , ( ( Repository ) db ) . useCnt . get ( ) ) ;
assertEquals ( 1 , repo . useCnt . get ( ) ) ;
repo . close ( ) ;
assertEquals ( 0 , repo . useCnt . get ( ) ) ;
}
}
@Test
@Test
@ -232,8 +234,8 @@ public class RepositoryCacheTest extends RepositoryTestCase {
@Test
@Test
public void testRepositoryUnregisteringWhenExpired ( ) throws Exception {
public void testRepositoryUnregisteringWhenExpired ( ) throws Exception {
Repository repoA = createBare Repository ( ) ;
Repository repoA = createRepository ( true , false ) ;
Repository repoB = createBare Repository ( ) ;
Repository repoB = createRepository ( true , false ) ;
Repository repoC = createBareRepository ( ) ;
Repository repoC = createBareRepository ( ) ;
RepositoryCache . register ( repoA ) ;
RepositoryCache . register ( repoA ) ;
RepositoryCache . register ( repoB ) ;
RepositoryCache . register ( repoB ) ;
@ -265,11 +267,12 @@ public class RepositoryCacheTest extends RepositoryTestCase {
}
}
@Test
@Test
public void testReconfigure ( ) throws InterruptedException {
public void testReconfigure ( ) throws InterruptedException , IOException {
RepositoryCache . register ( db ) ;
Repository repo = createRepository ( false , false ) ;
assertTrue ( RepositoryCache . isCached ( db ) ) ;
RepositoryCache . register ( repo ) ;
db . close ( ) ;
assertTrue ( RepositoryCache . isCached ( repo ) ) ;
assertTrue ( RepositoryCache . isCached ( db ) ) ;
repo . close ( ) ;
assertTrue ( RepositoryCache . isCached ( repo ) ) ;
// Actually, we would only need to validate that
// Actually, we would only need to validate that
// WorkQueue.getExecutor().scheduleWithFixedDelay is called with proper
// WorkQueue.getExecutor().scheduleWithFixedDelay is called with proper
@ -287,7 +290,7 @@ public class RepositoryCacheTest extends RepositoryTestCase {
// This wait will time out after 2048 ms
// This wait will time out after 2048 ms
for ( int i = 0 ; i < = 10 ; i + + ) {
for ( int i = 0 ; i < = 10 ; i + + ) {
Thread . sleep ( 1 < < i ) ;
Thread . sleep ( 1 < < i ) ;
if ( ! RepositoryCache . isCached ( db ) ) {
if ( ! RepositoryCache . isCached ( repo ) ) {
return ;
return ;
}
}
}
}