Search in sources :

Example 96 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class SvnCachingRepositoryPoolTest method testBigFlow.

private void testBigFlow(final SvnIdeaRepositoryPoolManager poolManager, boolean disposeAfter) throws SVNException, InterruptedException {
    poolManager.setCreator(svnurl -> new MockSvnRepository(svnurl, ISVNSession.DEFAULT));
    final SVNURL url = SVNURL.parseURIEncoded("http://a.b.c");
    final Random random = new Random(System.currentTimeMillis() & 0x00ff);
    final int[] cnt = new int[1];
    cnt[0] = 25;
    final SVNException[] exc = new SVNException[1];
    List<Thread> threads = new ArrayList<>();
    for (int i = 0; i < 25; i++) {
        Runnable target = () -> {
            MockSvnRepository repository = null;
            try {
                repository = (MockSvnRepository) poolManager.createRepository(url, true);
            } catch (SVNException e) {
                e.printStackTrace();
                exc[0] = e;
                return;
            }
            repository.fireConnectionOpened();
            TimeoutUtil.sleep(random.nextInt(10));
            repository.fireConnectionClosed();
            synchronized (cnt) {
                --cnt[0];
            }
        };
        Thread thread = new Thread(target, "svn cache");
        thread.start();
        threads.add(thread);
    }
    final long start = System.currentTimeMillis();
    synchronized (cnt) {
        while (cnt[0] > 0 && !timeout(start)) {
            try {
                cnt.wait(5);
            } catch (InterruptedException e) {
            //
            }
        }
    }
    Assert.assertEquals(0, cnt[0]);
    // test no open repositories, but may have inactive
    final ApplicationLevelNumberConnectionsGuardImpl guard = SvnIdeaRepositoryPoolManager.getOurGuard();
    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());
    if (disposeAfter) {
        poolManager.dispose();
        Assert.assertEquals(0, guard.getCurrentlyActiveConnections());
        Assert.assertEquals(0, guard.getInstanceCount());
        Assert.assertEquals(0, group.getUsedSize());
        Assert.assertEquals(0, group.getInactiveSize());
    }
    ConcurrencyUtil.joinAll(threads);
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) ArrayList(java.util.ArrayList) SVNException(org.tmatesoft.svn.core.SVNException) Random(java.util.Random) ApplicationLevelNumberConnectionsGuardImpl(org.jetbrains.idea.svn.svnkit.lowLevel.ApplicationLevelNumberConnectionsGuardImpl) CachingSvnRepositoryPool(org.jetbrains.idea.svn.svnkit.lowLevel.CachingSvnRepositoryPool)

Example 97 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class AbstractSvnUpdatePanel method init.

protected void init(final Collection<FilePath> roots) {
    final JPanel configureRootsPanel = getRootsPanel();
    configureRootsPanel.setLayout(new BorderLayout());
    final ArrayList<FilePath> rootsCopy = new ArrayList<>(roots);
    Collections.sort(rootsCopy, FilePathByPathComparator.getInstance());
    for (FilePath root : rootsCopy) {
        SVNURL url = getUrlFor(root);
        if (url != null) {
            myRootToPanel.put(root, createRootPanel(root, myVCS, roots));
        }
        Container parent = configureRootsPanel.getParent();
        parent.remove(configureRootsPanel);
        parent.setLayout(new BorderLayout());
        JPanel additionalPanel = getAdditionalPanel();
        if (additionalPanel != null) {
            parent.remove(additionalPanel);
        }
        if (myRootToPanel.size() == 1) {
            configureRootsPanel.add(myRootToPanel.values().iterator().next().getPanel(), BorderLayout.CENTER);
            parent.add(configureRootsPanel, BorderLayout.NORTH);
            if (additionalPanel != null) {
                parent.add(additionalPanel, BorderLayout.CENTER);
            }
        } else {
            final MultipleRootEditorWithSplitter multipleRootsEditor = new MultipleRootEditorWithSplitter(myRootToPanel, myVCS.getProject());
            configureRootsPanel.add(multipleRootsEditor, BorderLayout.CENTER);
            parent.add(configureRootsPanel, BorderLayout.CENTER);
            if (additionalPanel != null) {
                parent.add(additionalPanel, BorderLayout.SOUTH);
            }
        }
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) SVNURL(org.tmatesoft.svn.core.SVNURL)

Example 98 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class SvnAuthenticationTest method testWhenPassPhraseSaveNo.

public void testWhenPassPhraseSaveNo() throws Exception {
    final TestListener listener = new TestListener(mySynchObject);
    myAuthenticationManager.addListener(listener);
    final SavedOnceListener savedOnceListener = new SavedOnceListener();
    myAuthenticationManager.addListener(savedOnceListener);
    final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
    final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
    FileUtil.copy(servers, oldServers);
    try {
        FileUtil.appendToFile(servers, "\nstore-ssl-client-cert-pp=no\n");
        final SVNURL url = SVNURL.parseURIEncoded("https://some.host.com/repo");
        final SVNException[] exception = new SVNException[1];
        final Boolean[] result = new Boolean[1];
        synchronousBackground(() -> {
            try {
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
                commonScheme(url, false, null);
                Assert.assertEquals(3, listener.getCnt());
                Assert.assertEquals(1, myTestInteraction.getNumSSLWarn());
                myTestInteraction.reset();
                savedOnceListener.assertForAwt();
                savedOnceListener.reset();
                SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
                commonScheme(url, false, null);
                Assert.assertEquals(6, listener.getCnt());
                Assert.assertEquals(1, myTestInteraction.getNumSSLWarn());
            } catch (SVNException e) {
                exception[0] = e;
            }
            result[0] = true;
        });
        Assert.assertTrue(result[0]);
        Assert.assertEquals(1, myTestInteraction.getNumSSLWarn());
        Assert.assertEquals(6, listener.getCnt());
        listener.assertForAwt();
        savedOnceListener.assertForAwt();
        savedOnceListener.assertSaved(url, ISVNAuthenticationManager.SSL);
        if (exception[0] != null) {
            throw exception[0];
        }
    } finally {
        FileUtil.delete(servers);
        FileUtil.rename(oldServers, servers);
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException) SVNConfigFile(org.tmatesoft.svn.core.internal.wc.SVNConfigFile) File(java.io.File)

Example 99 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class SvnAuthenticationTest method testSavedAndReadUnix.

public void testSavedAndReadUnix() throws Exception {
    if (SystemInfo.isWindows)
        return;
    final TestListener listener = new TestListener(mySynchObject);
    myAuthenticationManager.addListener(listener);
    final SavedOnceListener savedOnceListener = new SavedOnceListener();
    myAuthenticationManager.addListener(savedOnceListener);
    final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
    final SVNException[] exception = new SVNException[1];
    final Boolean[] result = new Boolean[1];
    final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
    final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
    FileUtil.copy(servers, oldServers);
    try {
        FileUtil.appendToFile(servers, "\nstore-plaintext-passwords=yes\n");
        synchronousBackground(() -> {
            try {
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.save));
                commonScheme(url, false, null);
                Assert.assertEquals(3, listener.getCnt());
                //long start = System.currentTimeMillis();
                //waitListenerStep(start, listener, 3);
                SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
                commonScheme(url, false, null);
                //start = System.currentTimeMillis();
                //waitListenerStep(start, listener, 4);
                Assert.assertEquals(4, listener.getCnt());
            } catch (SVNException e) {
                exception[0] = e;
            }
            result[0] = true;
        });
    } finally {
        FileUtil.delete(servers);
        FileUtil.rename(oldServers, servers);
    }
    Assert.assertTrue(result[0]);
    myTestInteraction.assertNothing();
    Assert.assertEquals(4, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
    if (exception[0] != null) {
        throw exception[0];
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException) SVNConfigFile(org.tmatesoft.svn.core.internal.wc.SVNConfigFile) File(java.io.File)

Example 100 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class SvnAuthenticationTest method testSavedAndRead.

public void testSavedAndRead() throws Exception {
    final TestListener listener = new TestListener(mySynchObject);
    myAuthenticationManager.addListener(listener);
    final SavedOnceListener savedOnceListener = new SavedOnceListener();
    myAuthenticationManager.addListener(savedOnceListener);
    final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
    final SVNException[] exception = new SVNException[1];
    final boolean[] result = { false };
    synchronousBackground(() -> {
        try {
            listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
            listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
            if (SystemInfo.isWindows) {
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.save));
            } else {
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
            }
            commonScheme(url, false, null);
            Assert.assertEquals(3, listener.getCnt());
            //long start = System.currentTimeMillis();
            //waitListenerStep(start, listener, 3);
            listener.reset();
            if (!SystemInfo.isWindows)
                savedOnceListener.reset();
            SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
            listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
            if (!SystemInfo.isWindows) {
                listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
            }
            commonScheme(url, false, null);
            //start = System.currentTimeMillis();
            //waitListenerStep(start, listener, 4);
            Assert.assertEquals(SystemInfo.isWindows ? 1 : 3, listener.getCnt());
        } catch (SVNException e) {
            exception[0] = e;
        }
        result[0] = true;
    });
    Assert.assertTrue(result[0]);
    Assert.assertEquals(SystemInfo.isWindows ? 0 : 2, myTestInteraction.getNumPlaintextPrompt());
    Assert.assertEquals(0, myTestInteraction.getNumAuthWarn());
    Assert.assertEquals(0, myTestInteraction.getNumPasswordsWarn());
    Assert.assertEquals(0, myTestInteraction.getNumSSLPlaintextPrompt());
    Assert.assertEquals(0, myTestInteraction.getNumSSLWarn());
    Assert.assertEquals(SystemInfo.isWindows ? 1 : 3, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
    if (exception[0] != null) {
        throw exception[0];
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException)

Aggregations

SVNURL (org.tmatesoft.svn.core.SVNURL)121 SVNException (org.tmatesoft.svn.core.SVNException)52 File (java.io.File)41 SVNConfigFile (org.tmatesoft.svn.core.internal.wc.SVNConfigFile)15 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 ArrayList (java.util.ArrayList)12 SVNRepository (org.tmatesoft.svn.core.io.SVNRepository)10 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)9 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)8 VcsException (com.intellij.openapi.vcs.VcsException)7 Nullable (org.jetbrains.annotations.Nullable)7 SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)7 NotNull (org.jetbrains.annotations.NotNull)6 Info (org.jetbrains.idea.svn.info.Info)6 SVNClientManager (org.tmatesoft.svn.core.wc.SVNClientManager)6 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)5 SVNDirEntry (org.tmatesoft.svn.core.SVNDirEntry)5 FilePath (com.intellij.openapi.vcs.FilePath)4 DefaultSVNOptions (org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions)4 SvnAuthenticationManager (org.jetbrains.idea.svn.auth.SvnAuthenticationManager)3