use of org.jetbrains.idea.svn.svnkit.lowLevel.SvnIdeaRepositoryPoolManager in project intellij-community by JetBrains.
the class SvnCachingRepositoryPoolTest method testCloseWorker.
@Test
public void testCloseWorker() throws Exception {
final SvnIdeaRepositoryPoolManager poolManager = new SvnIdeaRepositoryPoolManager(true, null, null);
final ApplicationLevelNumberConnectionsGuardImpl guard = SvnIdeaRepositoryPoolManager.getOurGuard();
guard.setDelay(20);
((CachingSvnRepositoryPool) poolManager.getPool()).setConnectionTimeout(20);
testBigFlow(poolManager, false);
TimeoutUtil.sleep(50);
Assert.assertEquals(0, guard.getCurrentlyActiveConnections());
final CachingSvnRepositoryPool pool = (CachingSvnRepositoryPool) poolManager.getPool();
Map<String, CachingSvnRepositoryPool.RepoGroup> groups = pool.getGroups();
Assert.assertEquals(1, groups.size());
CachingSvnRepositoryPool.RepoGroup group = groups.values().iterator().next();
Assert.assertEquals(0, group.getUsedSize());
// !!!
Assert.assertEquals(0, group.getInactiveSize());
poolManager.dispose();
checkAfterDispose(poolManager);
}
use of org.jetbrains.idea.svn.svnkit.lowLevel.SvnIdeaRepositoryPoolManager in project intellij-community by JetBrains.
the class SvnCachingRepositoryPoolTest method testRepositoriesAreClosed.
@Test
public void testRepositoriesAreClosed() throws Exception {
final SvnIdeaRepositoryPoolManager poolManager = new SvnIdeaRepositoryPoolManager(true, null, null);
testBigFlow(poolManager, true);
}
use of org.jetbrains.idea.svn.svnkit.lowLevel.SvnIdeaRepositoryPoolManager in project intellij-community by JetBrains.
the class SvnCachingRepositoryPoolTest method testCancel.
@Test
public void testCancel() throws Exception {
final SvnIdeaRepositoryPoolManager poolManager = new SvnIdeaRepositoryPoolManager(true, null, null, 1, 1);
final SVNURL url = SVNURL.parseURIEncoded("http://a.b.c");
poolManager.setCreator(svnurl -> new MockSvnRepository(svnurl, ISVNSession.DEFAULT));
final MockSvnRepository repository1 = (MockSvnRepository) poolManager.createRepository(url, true);
final Semaphore semaphore = new Semaphore();
semaphore.down();
poolManager.setCreator(svnurl -> {
semaphore.waitFor();
return new MockSvnRepository(svnurl, ISVNSession.DEFAULT);
});
final SVNException[] exc = new SVNException[1];
final Runnable target = () -> {
try {
final MockSvnRepository repository = (MockSvnRepository) poolManager.createRepository(url, true);
repository.fireConnectionClosed();
} catch (SVNException e) {
e.printStackTrace();
exc[0] = e;
}
};
final EmptyProgressIndicator indicator = new EmptyProgressIndicator();
Thread thread = new Thread(() -> ((ProgressManagerImpl) ProgressManager.getInstance()).executeProcessUnderProgress(target, indicator), "svn cache repo");
thread.start();
TimeoutUtil.sleep(10);
Assert.assertTrue(thread.isAlive());
indicator.cancel();
final Object obj = new Object();
while (!timeout(System.currentTimeMillis()) && thread.isAlive()) {
synchronized (obj) {
try {
obj.wait(300);
} catch (InterruptedException e) {
//
}
}
}
Assert.assertTrue(!thread.isAlive());
thread.join();
Assert.assertNotNull(exc[0]);
//repository1.fireConnectionClosed(); // also test that used are also closed.. in dispose
poolManager.dispose();
checkAfterDispose(poolManager);
}
Aggregations