org.tmatesoft.svn.util.SVNTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of svnkit Show documentation
Show all versions of svnkit Show documentation
Java(tm) library to manage Subversion working copies and repositories
package org.tmatesoft.svn.util;
import java.io.File;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.BasicAuthenticationManager;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.auth.SVNAuthentication;
import org.tmatesoft.svn.core.auth.SVNSSHAuthentication;
import org.tmatesoft.svn.core.auth.SVNUserNameAuthentication;
import org.tmatesoft.svn.core.internal.wc.SVNFileUtil;
import org.tmatesoft.svn.core.internal.wc2.SvnWcGeneration;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.wc.DefaultSVNRepositoryPool;
import org.tmatesoft.svn.core.wc.ISVNRepositoryPool;
import org.tmatesoft.svn.core.wc2.SvnOperationFactory;
public class SVNTest {
/**
* @param args
* @throws SVNException
*/
public static void main(String[] args) throws SVNException {
final File wcDb = new File("C:/users/alex/sandbox/ideacrash/.svn/wc.db");
final File wcDbSource = new File("C:/users/alex/sandbox/ideacrash/wc.db.original");
SVNFileUtil.deleteFile(wcDb);
SVNFileUtil.copy(wcDbSource, wcDb, false, false);
final SvnWcGeneration g = SvnOperationFactory.detectWcGeneration(wcDb, false);
System.out.println(g);
System.exit(0);
final SVNURL url = SVNURL.parseURIEncoded("svn+ssh://teamcity.tmatesoft.com/home/alex/reposki");
final File keyFile = new File("C:/users/alex/personal/keys/id2.dsa");
final SVNSSHAuthentication sshAuth = new SVNSSHAuthentication("alex", keyFile, null, 22, false, url, false);
final SVNUserNameAuthentication userAuth = new SVNUserNameAuthentication("alex", false, url, false);
final ISVNAuthenticationManager authManager = new BasicAuthenticationManager(new SVNAuthentication[] {userAuth, sshAuth});
for (int i = 0; i < 20; i++) {
final ISVNRepositoryPool pool = new DefaultSVNRepositoryPool(authManager, null);
final SVNRepository repository = pool.createRepository(url, true);
try {
final long rev = repository.getLatestRevision();
System.out.println("revision fetched: " + rev);
pool.dispose();
Thread.sleep(60 * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
// repository.closeSession();
}
}
}
}