-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestClass.java
125 lines (102 loc) · 4.88 KB
/
TestClass.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package chau;
/*
anythig
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNWCUtil;
class TestClass {
@SuppressWarnings("deprecation")
public static void main(String[] args) throws SVNException {
SVNRepositoryFactoryImpl.setup();
String url = "https://ucdenver.svn.cloudforge.com/prjtest/trunk";
String name = "annguyen2509";
String password = "Peiu050612";
SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));
try{
repository = SVNRepositoryFactory.create( SVNURL.parseURIEncoded( url ) );
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( name , password );
repository.setAuthenticationManager( authManager );
System.out.println("repo root: " + repository.getRepositoryRoot(true));
System.out.println("latest revision: " + repository.getLatestRevision());
}catch(SVNException svne){
svne.printStackTrace();
}
FSRepositoryFactory.setup();
String url2 = "file://localhost/Users/d2chau/Documents/UCD Academics/Fall 2013/CSCI 4738 Senior Design I/visiosvn-read-only";
SVNRepository repository2 = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url2));
try{
repository2 = SVNRepositoryFactory.create( SVNURL.parseURIEncoded( url2 ) );
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager();
repository2.setAuthenticationManager( authManager );
System.out.println("repo root: " + repository2.getRepositoryRoot(true));
System.out.println("latest revision: " + repository2.getLatestRevision());
}catch(SVNException svne){
svne.printStackTrace();
}
}
}
*/
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNWCUtil;
public class TestClass {
@SuppressWarnings("deprecation")
public static void main(String[] args) throws SVNException{
// Message
System.out.println("Connecting to the SVN server....\n");
// Initialize variables for the SVN connections
// username, password, and svn_url
String username="annguyen2509";
String password="Peiu050612";
//String svn_url="https://ucdenver.svn.cloudforge.com/prjtest/trunk";
//local
String svn_url="file:///C:/Users/An Nguyen/Desktop/myNewRepo";
String http_url = "https://ucdenver.svn.cloudforge.com/prjtest/trunk";
// Message
System.out.println("!!! Connection is established !!!\n");
SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(http_url));
try{
repository = SVNRepositoryFactory.create( SVNURL.parseURIEncoded( http_url ) );
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( username , password );
repository.setAuthenticationManager( authManager );
System.out.println("Testing: " + repository.getRepositoryRoot(true));
System.out.println("Latest revision number: " + repository.getLatestRevision());
System.out.println("Repository UUID: " + repository.getRepositoryUUID( true ) );
}catch(SVNException svne){
svne.printStackTrace();
}
// 3 ways of accessing the svn repo
// file:/// access (local)
// svn:// access (via custom protocol to an svn server)
// http:// access (via WebDAV protocol to subversion-aware Apache server)
// Setting up the library
DAVRepositoryFactory.setup();
// Creating the driver
SVNRepository repo=null;
/*
// Creating SVN factory and SVN Revision
SvnOperationFactory factory=new SvnOperationFactory();
SVNRevision rev=SVNRevision.create(10);
*/
// Creating the repo using the svn_url provided
//repo=SVNRepositoryFactory.create(SVNURL.parseURIDecoded(svn_url));
repo=SVNRepositoryFactory.create(SVNURL.parseURIEncoded(svn_url));
// Login in the repo using Authentication
ISVNAuthenticationManager admin=SVNWCUtil.createDefaultAuthenticationManager(username, password);
// SVN connection is established here
repo.setAuthenticationManager(admin);
// Checking if the svn connection is established
System.out.println("Testing: " + repo.getRepositoryRoot(true));
System.out.println("Latest revision number: " + repo.getLatestRevision());
System.out.println("Repository UUID: " + repo.getRepositoryUUID( true ) );
}
}