Search in sources :

Example 1 with SvnIdeaRepositoryPoolManager

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);
}
Also used : SvnIdeaRepositoryPoolManager(org.jetbrains.idea.svn.svnkit.lowLevel.SvnIdeaRepositoryPoolManager) ApplicationLevelNumberConnectionsGuardImpl(org.jetbrains.idea.svn.svnkit.lowLevel.ApplicationLevelNumberConnectionsGuardImpl) CachingSvnRepositoryPool(org.jetbrains.idea.svn.svnkit.lowLevel.CachingSvnRepositoryPool) FileBasedTest(com.intellij.testFramework.vcs.FileBasedTest) Test(org.junit.Test)

Example 2 with SvnIdeaRepositoryPoolManager

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);
}
Also used : SvnIdeaRepositoryPoolManager(org.jetbrains.idea.svn.svnkit.lowLevel.SvnIdeaRepositoryPoolManager) FileBasedTest(com.intellij.testFramework.vcs.FileBasedTest) Test(org.junit.Test)

Example 3 with SvnIdeaRepositoryPoolManager

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);
}
Also used : EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) SVNURL(org.tmatesoft.svn.core.SVNURL) SvnIdeaRepositoryPoolManager(org.jetbrains.idea.svn.svnkit.lowLevel.SvnIdeaRepositoryPoolManager) Semaphore(com.intellij.util.concurrency.Semaphore) SVNException(org.tmatesoft.svn.core.SVNException) FileBasedTest(com.intellij.testFramework.vcs.FileBasedTest) Test(org.junit.Test)

Aggregations

FileBasedTest (com.intellij.testFramework.vcs.FileBasedTest)3 SvnIdeaRepositoryPoolManager (org.jetbrains.idea.svn.svnkit.lowLevel.SvnIdeaRepositoryPoolManager)3 Test (org.junit.Test)3 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)1 Semaphore (com.intellij.util.concurrency.Semaphore)1 ApplicationLevelNumberConnectionsGuardImpl (org.jetbrains.idea.svn.svnkit.lowLevel.ApplicationLevelNumberConnectionsGuardImpl)1 CachingSvnRepositoryPool (org.jetbrains.idea.svn.svnkit.lowLevel.CachingSvnRepositoryPool)1 SVNException (org.tmatesoft.svn.core.SVNException)1 SVNURL (org.tmatesoft.svn.core.SVNURL)1