View Javadoc

1   /**
2    * Copyright 2011-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.maven.plugins.externals;
17  
18  import java.io.File;
19  import java.util.List;
20  
21  import org.slf4j.Logger;
22  import org.slf4j.LoggerFactory;
23  import org.tmatesoft.svn.core.SVNCommitInfo;
24  
25  public class SVNUtilsTest {
26  
27  	private static final Logger log = LoggerFactory.getLogger(SVNUtilsTest.class);
28  	SVNUtils svnUtils = SVNUtils.getInstance();
29  	String username = "jcaddel";
30  	String password = System.getProperty("svn.password");
31  
32  	// @Test
33  	public void testGetExternalsFromWorkingCopyPath2() {
34  		try {
35  			File workingCopyPath = new File("/Users/jeffcaddel/ws/aggregate");
36  			List<SVNExternal> externals = svnUtils.getExternals(workingCopyPath);
37  			svnUtils.showExternals(externals);
38  		} catch (Exception e) {
39  			e.printStackTrace();
40  		}
41  	}
42  
43  	// @Test
44  	public void testDeleteExternals() {
45  		try {
46  			String url = "https://svn.kuali.org/repos/student/sandbox/enrollment/aggregate/tags/builds/student-2.0/2.0.0/r36447";
47  			List<SVNExternal> externals1 = svnUtils.getExternals(url);
48  			log.info("externals 1 - " + externals1.size());
49  			SVNCommitInfo info = svnUtils.deleteExternals(url);
50  			long newRevision = info.getNewRevision();
51  			log.info("Commited revision: " + newRevision);
52  			List<SVNExternal> externals2 = svnUtils.getExternals(url);
53  			log.info("externals 2 - " + externals2.size());
54  		} catch (Exception e) {
55  			e.printStackTrace();
56  		}
57  	}
58  
59  	// @Test
60  	public void testServerSideCopy() {
61  		try {
62  			long revision = 36416;
63  			String src = "https://svn.kuali.org/repos/student/sandbox/enrollment/ks-api/branches/M5";
64  			String dst = "https://svn.kuali.org/repos/student/sandbox/enrollment/ks-api/tags/builds/2.0/2.0.0-M5/20120919-r" + revision;
65  			Copy copy = new Copy();
66  			copy.setSource(src);
67  			copy.setRevision(revision);
68  			copy.setDestination(dst);
69  			copy.setUsername(username);
70  			copy.setPassword(password);
71  
72  			SVNCommitInfo info = svnUtils.copy(copy);
73  			long newRevision = info.getNewRevision();
74  			log.info("Commited revision: " + newRevision);
75  		} catch (Exception e) {
76  			e.printStackTrace();
77  		}
78  	}
79  
80  	// @Test
81  	public void testGetExternalsFromUrl() {
82  		try {
83  			String url = "https://svn.kuali.org/repos/student/sandbox/enrollment/aggregate/trunk";
84  			List<SVNExternal> externals = svnUtils.getExternals(url);
85  			svnUtils.showExternals(externals);
86  		} catch (Exception e) {
87  			e.printStackTrace();
88  		}
89  	}
90  
91  	// @Test
92  	public void testGetExternalsFromWorkingCopyPath() {
93  		try {
94  			File workingCopyPath = new File("/Users/jeffcaddel/ws/aggregate");
95  			List<SVNExternal> externals = svnUtils.getExternals(workingCopyPath);
96  			svnUtils.showExternals(externals);
97  		} catch (Exception e) {
98  			e.printStackTrace();
99  		}
100 	}
101 
102 	// @Test
103 	public void testGetUrl() {
104 		try {
105 			File workingCopyPath = new File("/Users/jeffcaddel/ws/aggregate");
106 			String url = svnUtils.getUrl(workingCopyPath);
107 			log.info("url=" + url);
108 		} catch (Exception e) {
109 			e.printStackTrace();
110 		}
111 	}
112 
113 	// @Test
114 	public void testGetLastRevision() {
115 		try {
116 			String url = "https://svn.kuali.org/repos/student/sandbox/enrollment/aggregate/trunk";
117 			File workingCopyPath = new File(".");
118 			log.info(url + " - Last revision: " + svnUtils.getLastRevision(url));
119 			log.info(workingCopyPath.getAbsolutePath() + " - Last revision: " + svnUtils.getLastRevision(workingCopyPath));
120 		} catch (Exception e) {
121 			e.printStackTrace();
122 		}
123 	}
124 
125 }