1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util;
17
18 import java.io.File;
19 import java.io.IOException;
20 import java.util.Arrays;
21
22 import org.apache.commons.io.FileUtils;
23 import org.junit.Ignore;
24 import org.junit.Test;
25
26 public class UnixUtilsTest {
27
28 @Test
29 @Ignore
30 public void testRsync() {
31 try {
32 String source = "root@env7.ole.kuali.org:/home/tomcat";
33 File destination = new File("/tmp/foo/man/chu/xyz");
34 FileUtils.deleteDirectory(new File("/tmp/foo"));
35 UnixUtils.rsyncdirs(Arrays.asList("--stats"), source, destination);
36 } catch (Exception e) {
37 e.printStackTrace();
38 }
39 }
40
41
42 public void testSsh() {
43 try {
44 File source = new File("/Users/jeffcaddel/Downloads/foo.sh");
45 String destination = "root@env11.ks.kuali.org:/home/tomcat/foo.sh";
46 UnixUtils.sshsu("root@env11.ks.kuali.org", "tomcat", "/home/tomcat/foo.sh");
47 UnixUtils.sshchown("root@env11.ks.kuali.org", "tomcat", "tomcat", "/home/tomcat/foo.sh");
48 UnixUtils.sshchownr("root@env11.ks.kuali.org", "tomcat", "tomcat", "/home/tomcat/foo.sh");
49 UnixUtils.scp(destination, source);
50 UnixUtils.sshrm("root@env11.ks.kuali.org", "/home/tomcat/foo.sh");
51 UnixUtils.scp(source, destination);
52 UnixUtils.sshmkdir("root@env11.ks.kuali.org", "/home/tomcat/foo.sh");
53 String newDestination = "root@env11.ks.kuali.org:/home/tomcat/foo/bar.sh";
54 UnixUtils.scp(source, newDestination);
55 FileUtils.deleteDirectory(new File("/tmp/tomcat"));
56 UnixUtils.rsync(Arrays.asList("-r", "--stats", "-a"), "root@env11.ks.kuali.org:/home/tomcat/", "/tmp/tomcat");
57 } catch (Exception e) {
58 e.printStackTrace();
59 }
60 }
61
62
63 public void testScp() throws IOException {
64 try {
65 File localFile1 = new File("/Users/jeffcaddel/Downloads/jjj.zip");
66 File localFile2 = new File("/Users/jeffcaddel/Downloads/foo/xyz/jjj.zip");
67 UnixUtils.scp(localFile1, "root@ci.fn.kuali.org:/root/jjj.zip");
68 UnixUtils.scp("root@ci.fn.kuali.org:/root/jjj.zip", localFile2);
69 } catch (Exception e) {
70 e.printStackTrace();
71 }
72 }
73 }